How to determine if my change will pass coverage on new code QG

  • which versions are you using SonarQube
    • Sonarqube
  • what are you trying to achieve
    • How can a developer quickly determine if their latest code changes will pass a quality gate containing a “80% or higher code coverage on new code” rule.
  • what have you tried so far to achieve this
    • Thought of implementing PR analysis in Git to pass/fail the MR CI gate. Curious if there’s an easier way for the developer though.

Hello there,

If I setup a quality gate with the following rule:

  • 80% or > code coverage on new code

What would be the easiest way for a developer to determine if the changes they’re making will pass this quality gate rule?

Some ideas I had:

  • Would the team need to add the SonarScanner to their project and run the scan locally?
  • Or maybe we’d need to integrate PR Analysis and have an MR created to scan the new changes? (but I read in another post that PR analysis will not follow a specified quality gate?)

Thank you!

Marco C.

Hi Marco,

That post you read was old. All the project’s QG conditions that are “on New Code” are now applied to PRs in recent versions of SonarQube. It’s true that that didn’t happen in 6.7.*, but that version is past EOL. The current version is 8.2 and the current LTS is 7.9.3. You should upgrade at your earliest convenience.


Thanks Ann!

Is that the easiest way? Is there no way to determine this locally without having to commit and push the code.

Yes, that’s the easiest way.