Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube: Scanning process ignores lcov.info

I am scanning a ui project.

The source code is in typescript.

gulp test-coverage generates .js files (which are then scanned for coverage). (each .ts file gets a .js file right next to it, in the same location)

I am pointing the scanner to the lcov.info file as follows:

sonar.javascript.lcov.reportPaths=test-coverage/lcov.info

The problem:

The lcov.info, provides coverage information for .js files

For some reason, SonarQube also provides coverage information for the *.ts files (although not incorporated in the test coverage report).

Why is that?

If I explicitly use

sonar.inclusions=**/*.ts

or

sonar.language=ts

the .js files will be ignored from the coverage report

If I use

sonar.coverage.exclusions=**/*.ts

and no specific inclusions, this will lead to both the .ts and .js files being scanned for errors, which will end up in duplicate errors (after all, .js files are generated by their .ts counterparts.

Any suggestions?

The whole issue of course would just go away, if sonarqube took litteraly the lcov.info and did not take initiatives about scanning other files.)

like image 653
pkaramol Avatar asked Dec 07 '22 15:12

pkaramol


1 Answers

If your source code is written in TypeScript, the coverage report (lcov.info) must contain information about TypeScript files, and not compiled JavaScript. The property you must be using in this case is sonar.typescript.lcov.reportPaths.

You can check out this example (https://github.com/SonarSource/SonarTS-example) to get more details.

like image 164
Stas Vilchik Avatar answered Dec 26 '22 10:12

Stas Vilchik