Code Coverage different without changing code

  • SonarQube V9.9.2.77730
  • CI system: Bamboo
  • bitbucket as repository management system
  • Language of the repository => .Net / C#

Code coverage is different without or with minor changes in code (not affecting the test code base or even changing code which is excluded from code coverage) leading to failed builds not reaching the defined quality gates for code coverage.

How does the ‘New code’ detection works? Which is the code base to be compared with? Why can the code coverage be different just by reanalyzing the branch?

Hi,

Welcome to the community!

At a guess, you’ve set your New Code definition to previous_version, and you’re passing something that changes with every run, probably your build string, in as your sonar.projectVersion value. That would reset what’s considered “new” with each analysis, and explain what you seem to be seeing.

 
HTH,
Ann

Hi Ann,
thanks for your quick response.

As new code definition we are using the ‘Reference Branch’ setting:

Hi,

Then this is probably about the SCM data that’s available to analysis. This part of the docs was written for PRs, but applies here too.

 
HTH,
Ann