SonarCloud not reading lcov reports

In our open source project, SonarCloud is not reflecting the right coverage. I just added multiple lcov reports for our code repository (we have a monorepo) and the coverage is 0 now. I did a PR to track it down and the paths to the reports are correct and the reports are there. Here is the travis build log that proves it:

INFO: Sensor SonarJS Coverage [javascript]

762INFO: Analysing [/home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/cds/, /home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/core/, /home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/storefront/]

763WARN: Could not resolve 1 file paths in [/home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/cds/, /home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/core/, /home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/storefront/], first unresolved path: /home/travis/build/SAP/cloud-commerce-spartacus-storefront/projects/core/src/asm/store/selectors/csagent-token.selectors.js

764INFO: Sensor SonarJS Coverage [javascript] (done) | time=404ms

But on the main Sonar scan (our develop branch) the SonarJS step is skipped altogether, and therefore our main coverage is 0%.

Here are our sonar settings:

Any help would be much appreciated. Thanks!

1 Like

Hello @hackergil, welcome to the community forum!

I can see the following log line in your travis-ci job for the develop branch:

INFO: Project root configuration file: NONE

This means that the file was not resolved, and that leads me to believe that you are not in the correct directory when you execute sonar-scanner.

If I look at the following line:

cd projects/schematics && yarn && yarn test && cd ..

then the working directory will be projects instead of the project root directory when you launch the sonar analysis. Changing this should make it so that the is correctly resolved, and that should make the coverage import correctly.


1 Like

That was the problem. Coverage is looking good now. Thank you for taking the time to look into this Tom.