SonarQube and Lcov report Could not resolve file paths

纵然是瞬间 提交于 2019-11-29 07:23:25

My usecase was kind of similar, but for a different tech stack: Java + React+ Gradle. Here is what I had to do to get sonar to display the coverage information for my javascript module on sonarqube 5.6 + SonarJS 3.x:

Reading your research and snippets, I think the istanbul issue you are referencing does not apply, as the lcov file contains the absolute path. My guess is that you have to provide: sonar.sources and sonar.tests property.

For the sake of completeness I am posting the entire snippet of my gradle configuration below and will provide explanations for each property below it:

sonarqube {
    properties {
        property "sonar.javascript.file.suffixes", ".js,.jsx"
        property "sonar.sourceEncoding", "UTF-8"
        property 'sonar.sources', 'public, src'
        property 'sonar.tests', 'src'
        property 'sonar.coverage.exclusions', '**/__tests__/**'
        property 'sonar.test.inclusions', '**/__tests__/**'
        property 'sonar.javascript.lcov.reportPath', 'coverage/lcov.info'
        property 'sonar.genericcoverage.unitTestReportPaths', 'testResults/sonar-report.xml'
    }
}

sonar.javascript.file.suffixes : AFAIR I had to provide it to appease the gradle sonarqube plugin, as the defaults I see in sonarqube server are the same.

sonar.sourceEncoding : it was also causing errors in processing the files, but I think it was because of my local settings.

sonar.sources and sonar.tests : I remember I had to provide these as sonar was not able to find any of my sources to process without them. I remember this distinctly as I never had to provide any such information for my java sources.

sonar.coverage.exclusions : Was required to get the correct coverage information.

sonar.test.inclusions : Was required for the sonarjs plugin to identify my test files.

sonar.genericcoverage.unitTestReportPaths : I also wanted to see the unit tests contribution in my dashboard, so I had to process my jest reports into a generic sonar format.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!