Lcov coverage file changes not picked up

  • ALM used: Gitlab

  • CI system used: Gitlab

  • Languages of the repository: Typescript

  • Error observed:
    There is no error but my coverage report is not updated accordingly to the lcov file.

The file is correctly picked up by the sonarQube job on Gitlab:

INFO: Sensor TypeScript analysis [javascript] (done) | time=16232ms

[123](https://gitlab.com/***/saas/microservice/user/-/jobs/1278651123#L123)INFO: Sensor JavaScript/TypeScript Coverage [javascript]

[124](https://gitlab.com/***/saas/microservice/user/-/jobs/1278651123#L124)INFO: Analysing [/builds/***/saas/microservice/user/coverage/lcov.info]

[125](https://gitlab.com/***/saas/microservice/user/-/jobs/1278651123#L125)INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=54ms
  • Steps to reproduce
    Link SonarCloud to gitlab project. Update lcov configuration. lcov.info file is updated when rebuilding but the sonarcloud project coverage is not updated

  • Potential workaround
    I tried to reset the configuration by going through the wizard on sonarcloud but the history is kept and no change is reflected

Welcome to the community!

Can you please clarify what you mean by that? What exactly changed?

How do you know this is really the case?

What kind of update did you expect exactly?

Hi, thanks for the welcome and for your reply!

Update lcov configuration details

I changed the configuration to remove the coverage of the test files
For example I added in jest configuration in package.json :

Summary

“coveragePathIgnorePatterns”: [
“test/**/*.(t|j)s”
],

How do you know this is really the case?

the coverage info is both generated as text and lcov file and I see the change. I also downloaded the lcov.info file from gitlab as an artifact and I see the change too (no more ‘test’ string appearing in the file)

What kind of update did you expect exactly?

I expected the coverage report to be updated. When I go in the details, I see that the test files are still there. They should not. As a result the coverage percentage displayed ni gitlab and in sonarQube are different, which is a problem.

Sorry for the late response!

Here’s what I understand:

  • Right after importing the project on SonarCloud, the coverage looks correct: what you see on SonarCloud is consistent with what’s in the lcov.info file.
  • After you make a change to your setup, the lcov.info file is correctly updated, what you see on SonarCloud is not updated.

Correct me if I missed something. If the above is correct, then it looks to me as if the SonarCloud analysis was not executed after you made the change to your setup. The project’s page on SonarCloud shows the time of the last analysis. You can also see the list of analyses on the Administration / Background Tasks page.

I suspect the issue is with your build pipeline: it looks like the SonarCloud analysis is not executed on code change. I hope this helps.