sonarqube执行sonar-scanner出现过的错误

1.ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for ‘Unknown’: sonar.projectKey
原因1.:sonar-project.properties文件里sonar写成onar
解决方法:将sonar-project.properties,文件改对
原因2:没有在sonar-project.properties文件所在位置执行命令/home/sona/sonar-scanner/bin/sonar-scanner

2.ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
原因:没有对sonar-scanner进行变量配置
解决方法:vim /etc/profile,添加export PATH="$PATH:/home/sona/sonar-scanner/bin"
sonarqube执行sonar-scanner出现过的错误_第1张图片
然后source /etc/profile,使文件生效

3.java.lang.IllegalStateException: Failed to create lock in /home/.scannerwork/.sonar_lock
原因:隐形文件.sonar_lock的所属用户为root,用普通账号去运行就会出错
解决方法:将.sonar_lock的所属用户改成普通账户,或切换为root账号去执行命令

4.org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
原因:sonar-project.properties文件配置错误
之前的配置如下:

sonar.projectKey=项目名
sonar.projectName=项目名
sonar.sources=文件路径
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8

正确配置应该如下:

sonar.projectKey=项目名
sonar.projectName=项目名
sonar.projectVersion=1.0-SNAPSHOT
sonar.sourceEncoding=UTF-8
sonar.modules=java-module

# Java module
java-module.sonar.projectName=Java Module
java-module.sonar.language=java
java-module.sonar.sources=src
java-module.sonar.projectBaseDir=.
sonar.java.binaries=target/

5.ERROR: Error during SonarQube Scanner execution

ERROR: Not authorized. Analyzing this project requires to be authenticated. Please provide the values of the properties sonar.login and sonar.password.

ERROR:

ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
原因:sonarqube设置了强制登录
解决方法:关闭强制登录设置就可以了
sonarqube执行sonar-scanner出现过的错误_第2张图片
6.

ERROR: Error when running: 'node -v'. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: 'node -v'. Is Node.js available during analysis?
	at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:77)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:171)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:144)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:120)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.initNodeCommand(EslintBridgeServerImpl.java:129)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServer(EslintBridgeServerImpl.java:105)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServerLazily(EslintBridgeServerImpl.java:145)
	at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.execute(EslintBasedRulesSensor.java:92)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:392)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
	at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:154)
	at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:73)
	... 38 common frames omitted
Caused by: java.io.IOException: error=2, No such file or directory
	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
	at java.base/java.lang.ProcessImpl.(Unknown Source)
	at java.base/java.lang.ProcessImpl.start(Unknown Source)
	... 42 common frames omitted

原因:没有安装node
解决方法:输入命令node -v,没有安装的话会自动提示你是否要安装,根据提示一步步安装就好

ERROR: Unable to parse file: file:///home/unismart_web/ep_uspms/src/components/calendarComponent/calendar-component.vue
ERROR: Parse error at line 10 column 1:

sonarqube执行sonar-scanner出现过的错误_第3张图片

你可能感兴趣的:(sonarqube,代码质量,代码规范)