我有一个 Go 项目,我想使用 SonarRunner 导入到 SonarQube 5.1 中。
我知道它不是 SonarQube 支持的语言之一,所以我设置了属性
sonar.import_unknown_files=true
完成一些基本级别的导入 - 它完成了工作。该项目还具有 Cobertura 格式的代码覆盖率,使用 https://github.com/axw/gocov/ 生成和 https://github.com/AlekSi/gocov-xml .
我没有成功地让这个 XML 导入设置:
sonar.core.codeCoveragePlugin=cobertura
sonar.cobertura.reportPath=coverage.xml
因此,该项目在 Sonar 仪表板上显示为灰色框。有没有人做过类似的事情并让它工作?是因为 Go 是一种不受支持的语言吗?
非常感谢!
安迪
最佳答案
自 SonarQube 7.9 (2019年7月),正式支持go语言。
这包括 code coverage for Go .
它在 community edition 中受支持!
40 rules for Go were present since SonarQube 6.7 .
但遗产SonarSource/sonar-go
,SonarQube 的 Go 分析器,现在是 SonarQube LTS) SonarSource/slang
的一部分(SonarSource Language),这是一个为SonarQube快速开发代码分析器的框架。
参见 MMF-1670 (迁移到 SLANG)
SonarGo is relying on the UAST technology developed early in the ideation phase of an unified language to write language parsers, which later led to the creation of SLANG.
In order to unify the technologies we use, reduce the maintain cost, and benefit from more features, we need to migrate the current SonarGO implementation to a GO plugin relying solely on the SLANG framework.
参见 its Go code coverage SLang issues ,特别是:SONARSLANG-399
sonarqube {
properties {
property 'sonar.sources', '.'
property 'sonar.exclusions', '**/*_test.go,**/generate_source.go,**/*_generated.go,**/build/**,**/.gogradle/**'
property 'sonar.tests', '.'
property 'sonar.test.inclusions', '**/*_test.go'
property 'sonar.test.exclusions', '**/build/**,**/.gogradle/**'
property 'sonar.go.tests.reportPaths', "${project.projectDir}/.gogradle/reports/test-report.out"
property 'sonar.go.coverage.reportPaths', "${project.projectDir}/.gogradle/reports/coverage/profiles/github.com%2FSonarSource%2Fsonar-go%2Fuast-generator-go.out"
}
}
SONARSLANG-408 ([Go] Import Go Cover report") 仍在进行中。
(但在撰写本文时只有 4 小时)
关于go - 将 Go 源代码和覆盖率导入 SonarQube,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30606175/