我在Windows 10操作系统中有一个ReactJS Javascript项目工作区,我想使用 SonarScanner 来运行代码分析。我已设置并验证 SonarScanner 运行正常。我还在 SonarScanner/conf/sonar-scanner.properties 文件中设置了“sonar.host.url”。每次运行时,我都可以看到扫描结果。
然后我在我的工作区中添加了“sonar-project.properties”文件。这些是“sonar-project.properties”文件中的设置:
sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=Project1
# --- optional properties ---
# defaults to project key
sonar.projectName=React Webapp
# defaults to 'not provided'
#sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.projectBaseDir=C:/code/model-group-webapp
sonar.sources=src
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
然后我运行 sonar-scanner 命令,如“$sonar-scanner -X”。
我可以在日志中看到读取了 Javascript 文件,但这些文件是用语言“null”索引的。
13:56:46.764 INFO: Source paths: src
13:56:46.765 INFO: Source encoding: windows-1252, default locale: en_US
13:56:46.768 INFO: Index files
13:56:46.794 DEBUG: 'src/App.js' indexed with language 'null'
13:56:46.796 DEBUG: 'src/App.test.js' indexed with language 'null'
13:56:46.796 DEBUG: 'src/config/config.js' indexed with language 'null'
13:56:46.798 DEBUG: 'src/EditPanel.js' indexed with language 'null'
13:56:46.800 DEBUG: 'src/Filter.js' indexed with language 'null'
13:56:46.800 DEBUG: 'src/index.css' indexed with language 'null'
13:56:46.805 DEBUG: 'src/index.js' indexed with language 'null'
13:56:46.805 DEBUG: 'src/logo.svg' indexed with language 'null'
13:56:46.810 DEBUG: 'src/serviceWorker.js' indexed with language 'null'
我还注意到 Javascript 不在日志中的可用语言中。它只显示了 Java:
14:29:42.889 INFO: Load project repositories (done) | time=125ms
14:29:42.990 DEBUG: Available languages:
14:29:42.993 DEBUG: * Java => "java"
在 Sonarqube 服务器中,该项目显示 0 个错误和漏洞,没有源代码。
这里缺少什么配置?