Multiple LCOV files are not providing coverage as expected

We have multi module project and having multiple LCOV. After scanning we are not getting correct coverage. I analysed LCOV report on https://lcov-viewer.netlify.app/ but sonar is not producing coverage inline to lcov-viewer display.

On our jenkins agent mudule structure is as below

Workclient/target
→ coverage-report → lcof.info
→ coverage-data
-----> server → lcof.info
-----> backup-agent → lcof.info
-----> cloud9 → lcof.info
-----> dmp-manager → lcof.info
-----> model-runner → lcof.info
-----> om-client → lcof.info

Workclient/target is a parent directorory and coverage-report and coverage-date are child directories of target directory. -----> are child directories of coverage-date which contains lcov.info respectively.

Given this structure. we are not getting coverage data on sonar inline to what Lcov.info file produced the result

However, jenkins build logs implies that all above given locv.info files analylsed successfully.

12:06:59** [e[1;34mINFOe[m] Analysing [/home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-report/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/cloud9/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/server/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/om-client/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/dmp-manager/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/model-runner/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/backup-agent/lcov.info]

**14:44:24** [e[1;33mWARNINGe[m]Could not resolve 220 file paths in [/home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/model-runner/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/client-coverage-report/Chrome Headless 134.0.0.0 (Linux x86_64)/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/backup-agent/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/om-client/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/dmp-manager/lcov.info, /home/ec2-user/workspace/ture_TOD-2291-migration-to-sonar/workclient/target/coverage-data/cloud9/lcov.info]

Could you please suggest how to handle these multiple lcov.info to get correct coverage on sonar scanning?

Hi,

The paths in the coverage reports don’t match the paths analysis is seeing. You’ll need to resolve that.

 
HTH,
Ann

Hi Ann,

Not sure how to fix those paths as lcove.info files are being found correctly from the given path. I also tried with avoiding wildcard and provided absolute patch of each lcov file comma separated.

like this

<sonar.javascript.lcov.reportPaths>
           ${project.basedir}/workclient/target/client-coverage-report/Chrome Headless 134.0.0.0 (Linux x86_64)/lcov.info,
            ${project.basedir}/workclient/target/coverage-data/backup-agent/lcov.info,
            ${project.basedir}/workclient/target/coverage-data/cloud9/lcov.info,
            ${project.basedir}/workclient/target/coverage-data/dmp-manager/lcov.info,
            ${project.basedir}/workclient/target/coverage-data/model-runner/lcov.info,
            ${project.basedir}/workclient/target/coverage-data/om-client/lcov.info,
            ${project.basedir}/workclient/target/coverage-data/server/lcov.info
</sonar.javascript.lcov.reportPaths>`

Any suggestions?

Hi,

Are you moving the lcov files around after creation? If so, it may be that that’s what’s throwing it off. Otherwise, you may need to add a step to adjust the paths in the reports.

 
HTH,
Ann

We are doining sonar scan in post action in CI(Jenkins) pipeline and all reports generate under workclien/target directory at run time in jenkins agents and we provide the path of each lcov in pom (as mentioned in earlier post)

Hi,

What do the paths in those reports look like?

 
Ann

I am putting some of paths from lcov reports

backup-agent/lib
dmp-manager/lib
mosel-runner/lib
local/js/browser

I missed to pasted log line from my original post

 [e[1;33mWARNINGe[m] First unresolved path: ../local/js/browser/browser-context.js (Run in DEBUG mode to get full list of unresolved paths)

Hi,

From the analysis base directory, where does ../local/js/browser... get you?

Again, you need to look at the paths in the reports and compare them to the paths analysis is seeing. Probably the paths in the reports should be relative from the project / analysis base directory.

 
HTH,
Ann

Hi Ann

It looks like this blog explaing our issue but just wanted to know is this blog still relevant being it was published in 2018?

What we have noticed it that in one of the modules model-runner we are doing coverage on only one directory model-runner/libs and sonar producing correct coverage 74% uder code section which is inline to lcov.info but overall coverage (on overview page) to this module is dropping to just 24.1%. Does that mean sonar is generating overall coverage to all the directories/files that reside under model-runner and not only on model-runner/libs directory?

Hi,

Your issue is not that the coverage is imported but the totals don’t match. It’s that it’s not imported.

You still need to sort out those path differences, I’m afraid.

 
Ann