Discrepancy between feature branch and master branch code coverage

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension): Enterprise Edition v2025.1 (102418)
  • how is SonarQube deployed: zip, Docker, Helm: Helm
  • what are you trying to achieve:
    1. The default Sonar way quality gate requires that new code coverage be at least 80%. During the feature branch analysis, coverage was 80.3%, but after merging into the master branch, it dropped to 79.9%, causing the quality gate to fail. Could you explain why this discrepancy occurs on the master branch?

    2. Can SonarQube’s calculation of new code metrics be affected by factors such as large code changes, modifications to the project structure, or changes in SonarQube configuration?

  • what have you tried so far to achieve this:

Hi,

Welcome to the community!

This is likely related to what I call the “fudge factor.” More here:

I suspect that before merge, your main branch had <20 new lines with low coverage. The new merge bumped that over the fudge factor threshold so the Quality Gate condition was evaluated for the first time.

 
HTH,
Ann