How to scan when we have multiple lcov.info files in a UI project

  • which versions are you using : SonarQube 8
  • what are you trying to achieve: I am having multiple angular library projects, and each of them are run separately for the code coverage. So the coverage paths look like this
    reports/coverage/**/lcov.info

The ** I put because I have multiple folders each for my angular libraries.

How can I make sonar scan multiple lcov.info files

sonar.javascript.lcov.reportPaths=$(System.DefaultWorkingDirectory)/$(ProjectFolder)/reports/coverage/**/lcov.info

Above is what I tried. But then the scanner says it can not find any lcov.info

Hi @mukund26 ,

Welcome to SonarSource Community! :sonarsource:

Are you using SonarQube 4? Please upgrade to the latest version of SonarQube and try again. Yes, SonarQube can handle multiple lcov.info files. If it fails again, please run Sonar scanner analysis with sonar.verbose=true analysis parameer and share logs here.

Sorry. I was using sonar server 8.9
The azure devops yml task version I was using was 4. The verbose mode logs are here.

07:34:57.205 DEBUG: Not enough content in ‘flare.docs/projects/we-skeleton-loader/src/index.ts’ to have CPD blocks, it will not be part of the duplication detection
07:34:57.206 DEBUG: ‘flare.docs/projects/we-skeleton-loader/src/flare-skeleton-loader/flare-skeleton-loader.ts’ generated metadata with charset ‘UTF-8’
07:34:57.364 INFO: 499/499 source files have been analyzed
07:34:57.364 INFO: Sensor TypeScript analysis [javascript] (done) | time=60172ms
07:34:57.364 INFO: Sensor JavaScript/TypeScript Coverage [javascript]
07:34:57.365 INFO: Analysing [D:\work\75\s\flare.docs\reports\coverage\ng-outer-click\lcov.info, D:\work\75\s\flare.docs\reports\coverage\components\lcov.info]
07:34:57.398 DEBUG: Problem during processing LCOV report: can’t save DA data for line 613 of coverage report file (java.lang.IllegalArgumentException: Line with number 34 doesn’t belong to file group-base.component.ts).
07:34:57.398 DEBUG: Problem during processing LCOV report: can’t save DA data for line 661 of coverage report file (java.lang.IllegalArgumentException: Line with number 13 doesn’t belong to file control-group-content-template.directive.ts).
07:34:57.398 DEBUG: Problem during processing LCOV report: can’t save DA data for line 662 of coverage report file (java.lang.IllegalArgumentException: Line with number 16 doesn’t belong to file control-group-content-template.directive.ts).
07:34:57.398 DEBUG: Problem during processing LCOV report: can’t save DA data for line 663 of coverage report file (java.lang.IllegalArgumentException: Line with number 19 doesn’t belong to file control-group-content-template.directive.ts).
07:34:57.399 DEBUG: Problem during processing LCOV report: can’t save DA data for line 718 of coverage report file (java.lang.IllegalArgumentException: Line with number 13 doesn’t belong to file control-group-footer-template.directive.ts).
07:34:57.399 DEBUG: Problem during processing LCOV report: can’t save DA data for line 719 of coverage report file (java.lang.IllegalArgumentException: Line with number 16 doesn’t belong to file control-group-footer-template.directive.ts).
07:34:57.488 WARN: Could not resolve 1 file paths in [D:\work\75\s\flare.docs\reports\coverage\ng-outer-click\lcov.info, D:\work\75\s\flare.docs\reports\coverage\components\lcov.info]

When I use the ** wildcard, this is what I get

Sensor JavaScript/TypeScript Coverage [javascript]
08:15:11.845 WARN: No coverage information will be saved because LCOV file cannot be found.
08:15:11.845 WARN: Provided LCOV file path: ***D:\work\102\s/flare.docs/reports/coverage/**/lcov.info. Seek file with path: D:\work\102\s\flare.docs\reports\coverage\**\lcov.info***
08:15:11.845 WARN: No coverage information will be saved because all LCOV files cannot be found.
08:15:11.845 INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=1ms

Hi @mukund26 ,

Can you try setting sonar.javascript.lcov.reportPaths=**/lcov.info instead?

Also, is your project a mono-repo?

I get this then

Provided LCOV file path: **\lcov.info. Seek file with path: D:\work\75\s**\lcov.info

08:45:31.030 WARN: No coverage information will be saved because all LCOV files cannot be found.

08:45:31.030 INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=1ms

My project is a monorepo. With several angular libraries. The PR decoration for the sonar is also not working.

Does anyone has any idea about this?

Hi @mukund26 ,

I think you have run into this issue: Support wildcards for coverage report paths · Issue #578 · SonarSource/SonarJS · GitHub Please confirm if this is the case. This issue will be fixed in SonarJS 8.3, which will release in SonarQube 9.1.

We are using sonar server 8.9.1. When can we expect 9.1?

It is planned for late-September 2021.

You can simply use this command to merge multiple lcov.info files into one until this feature is live:

npm test (part1)
cd coverage && mv lcov.info lcov_1.info
npm test (part2)
cd coverage && mv lcov.info lcov_2.info
npx lcov-result-merger 'coverage/lcov_*.info' 'coverage/lcov.info'
2 Likes