New Sonarqube implementation here, and we’re struggling a bit with the inconsistencies in the coverage reporting. I’ve checked through everything I can find on Google, GitHub, and in the forums here and a few of the suggested solutions that worked for others just aren’t working for me.
I’ve got a Typescript project with a few source directories as specified in the sonar.Sources
property. I am also specifying the coverage locations with the sonar.javascript.lcov.reportPaths
property.
If I go view the HTML coverage report that’s generated by NYC I have 100% coverage. When running the SonarScanner we end up in the 96% ish range.
Running the SonarScanner with debug logs, I do see why this is happening:
10:48:20.566 DEBUG: Problem during processing LCOV report: can't save DA data for line 8608 of coverage report file (java.lang.IllegalArgumentException: Line with number 4 doesn't belong to file index.ts).
Typical fixes suggested here are:
- Ensure
sourceMaps
are on in the tsconfig.json, which they are - Ensure the
sonar.sources
are set correctly, which they are (if they aren’t typically you get a 0% coverage in Sonar) - Ensure the
sonar.javascript.lcov.reportPaths
property is set which is
None of these fixes seem to be getting me any closer, or helping me get through this LCOV report processing issue.
I’m at a bit of a loss at this point and hoping someone has another magic bullet config change that worked for them.
Here’s my sonar-project.properties
file (genericized a bit for security) as well:
sonar.projectKey=myProjectKey
sonar.projectName=My Project Name
sonar.sourceEncoding=UTF-8
sonar.language=ts
sonar.tests=project1/test,project2/test,project3/test
sonar.test.inclusions=project1/test/*.ts,project2/test/*.ts,project3/test/*.ts
sonar.sources=project1/src,project2/src,project3/src
sonar.javascript.lcov.reportPaths=project1/build/coverage/lcov.info,project2/build/coverage/lcov.info,project3/build/coverage/lcov.info
sonar.ts.tslint.path=tslint.json
sonar.log.level=DEBUG
sonar.verbose=TRUE
Here’s version info for reference:
SonarScanner
INFO: Scanner configuration file: C:\sonarscanner\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\github\<my-project>\sonar-project.properties
11:03:13.358 INFO: SonarScanner 4.3.0.2102
11:03:13.364 INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
11:03:13.365 INFO: Windows 10 10.0 amd64
SonarQube 8.3.1.34397 (Community Edition)
SonarJS 6.2 (build 12043)
SonarTS 2.1 (build 4359)
NodeJS 12.13.1
Typescript 3.8.3 (I do get the not officially supported message, I have the same problem with Typescript 3.7.5 which is supported)
Thanks folks!