Gcov Coverage Data for Pull Request Is Not Accurate

Enterprise EditionVersion 10.3 (build 82913) (also happens to SonarQube 9)
Jenkins plugin: SonarQube Scanner Version2.16.1

For GitHub pull request builds, we generated .gcov files for a CPP project and fed them to our SonarQube server. Then a SonarQube scan report was generated successfully.

Everything looked good except the coverage data report somehow counted the lines not touched in the pull request. This issue happens to us frequently and happens to different lines of different files. The .gcov file contents are correct.

Our observation is that it might be related to GitHub integration in the SonarQube server because previously the data was correct when we forgot to set the integration to api.github.com.

Sometimes this can happen if the scanner doesn’t correctly detect changed lines. Do you see any warnings in your analysis logs?

Hi Colin,

Thanks for helping out. Do you mean the log from our CI Jenkins console printed by Sonarqube Jenkins plugin? I can only see these WARNs that show the source files not specified in sonar.inclusions. E.g.

02/12/2024 13:11:03   WARN: File not analysed by Sonar, so ignoring coverage: /usr/include/c++/11.3.0/bits/stl_pair.h

Is there any update?

Hey @xiaoyzhang

I’m sorry this thread fell off my radar.

I think there are two things that would be important to figuring out what’s going on:

  • DEBUG level analysis logs (sonar-scanner -X)
  • A screenshot demonstrating the issue (lines untouched in the PR being counted for coverage in the PR)