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:

https://travis-ci.org/SAP/cloud-commerce-spartacus-storefront/builds/632407158

INFO: Sensor SonarJS Coverage [javascript]

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

763WARN: Could not resolve 1 file paths in [/home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/cds/lcov.info, /home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/core/lcov.info, /home/travis/build/SAP/cloud-commerce-spartacus-storefront/coverage/storefront/lcov.info], 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%.

https://sonarcloud.io/dashboard?id=sap_cloud-commerce-spartacus-storefront

Here are our sonar settings: https://github.com/SAP/cloud-commerce-spartacus-storefront/blob/develop/sonar-project.properties

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 sonar-project.properties 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 sonar-project.properties is correctly resolved, and that should make the coverage import correctly.

Tom

1 Like

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

2 Likes