Coverage Mismatch with Nodejs & Typescript

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 file (genericized a bit for security) as well:

sonar.projectName=My Project Name

Here’s version info for reference:

INFO: Scanner configuration file: C:\sonarscanner\bin\..\conf\
INFO: Project root configuration file: C:\github\<my-project>\
11:03:13.358 INFO: SonarScanner
11:03:13.364 INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
11:03:13.365 INFO: Windows 10 10.0 amd64

SonarQube (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!

This looks like it may be a mono-repo problem.

When I remove the additional project directories from sonar.sources and stick to just one of the 3 TypeScript directories in this repository, I don’t get these same errors and the coverage more or less aligns with what I have locally (with the exception of two root files that are for whatever reason don’t contribute to overall coverage locally at the moment).

I did in my searching see that monorepo support is a roadmap item, I can work around by reporting each directory as a separate project.

1 Like