Issue with new code vs overall code after upgrading Sonar

Lately we upgraded to SonarQube, and now all our quality gates stop working.

For example, we have quality gate of 90% for new code% and 90% for overall code (changed to 85% in order to fix the problem next to be described).
Those are the only gateway conditions we have:
Conditions on new code: overage is less than 85%.
Conditions on overall code: coverage is less than 90%.
All others conditions, for both new code and overall code, are the same (blocker, critical issue and major issues are all greater than 0).

On PR level, the sonar is running with a green status, so the developer merged the code:

But after the merge, the master branch failed on new line code coverage:

We believe this is because the time period is from Aug 11th while the branch itself has some older commits. i.e on PR branch level Sonar scans all the code, but on master branch it scans only the commits after this date.

What we are trying to achieve:
We were trying to configure the Sonar to be as followed, but failed to find the correct setting for it:
On PR branch: scan the new line of code → if this is under the NEW LINE threshold OR the estimated code coverage after merge is less than the OVERALL threshold → the scan should fail.
On branch level (i.e master or older releases): scan for OVERALL only. Should never fails as if coverage is under the threshold it shouldn’t have been merged. And in any case, once merged there is no point for any NEW CODE scan.

Hey there.

This is a very old, EOL version of SonarQube. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

8.3.1 → 8.9.10 → 9.9.1 → 10.1 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.