Pull Requests get a real Quality Gate status

Hi SonarCloud users,

when we added the support for PRs (Pull Requests), we first started to report only issues - because this is what brings the most useful information to development teams. At that time, a PR was considered “failed” if there was at least one open issue on it.

Since yesterday, PRs now display a real Quality Gate Status, based on the quality gate defined for the project they belong to. So if you have a condition on the coverage on your new code, it will now be taken into account!

Visible changes on the PRs

In GitHub, the SonarCloud page now displays the status of the quality gate as the first entry, with details of failed conditions if any:

On Bitbucket Cloud, a similar status overview is visible - the analysis details being collapsed by default to not eat too much space:

On Azure DevOps, there is no space to display an overview of the quality gate status, so mainly the following label was updated:

In SonarCloud, PRs get a brand new page

PRs would not be considered as first class citizen if they did not get a dedicated page inside SonarCloud. This is now done. Clicking on the quality gate status link from GitHub / Bitbucket Cloud / Azure DevOps will lead to a brand new page which looks like this:

Quality Gate conditions checked on PRs

One important detail to keep in mind: the conditions used to compute the quality gate status are the ones define on new code only. And this works perfectly out of the box with the built-in “Sonar way” quality gate since it focuses on the new code (“Fix the leak!”). For custom quality gates, some conditions might be ignored. For instance, the first condition on this custom quality gate will not be checked (the second is the one which be used instead):

Hope you will enjoy all this!

10 Likes

Great addition! This was the missing piece from PR decoration. Status page looks really nice too :slight_smile:

7 Likes

So if i’m using a custom quality gate with all of the rules pointing to the overall code metrics - then every PR will automatically pass the quality gate? I think it will be misleading, especially as i’m using Bitbucket Cloud the actual metrics are collapsed…

1 Like

That’s a very good feedback @Roy_Sela, this point needs to be clarified! I’ll create a ticket on our end.

Thanks!

Whilst this is a welcome change, since it’s introduction the PR quality gate failure rate has spiked causing frustration to our developers.

Upon inspection, the main cause seems to be that the duplication on new code check is picking up duplicate code on unchanged lines. We are using a clone of the Sonar way quality gate with all the same conditions.

Is this an issue or do I have a misunderstanding of how the duplication check is meant to work? It appears to be checking the entire file, even if one (unduplicated) line has changed.

1 Like

Brett, can you open a dedicated thread about this? Thanks!