Lately we upgraded to SonarQube 22.214.171.124397, 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.