Sonar Cloud Quality Gate

How can I change the Quality gate. I tried to add new and after this set as default also down on the Project box I checked on With -> projectname, but still use Sonar way. I want to test also overall code not only new. Can I edit Sonar way because I don’t see the edit button when I am on Sonar way?

Hey there.

  • You cannot edit the Sonar Way, it’s built-in. You have to create a new Quality Gate (which it sounds like you’ve done)
  • Once assigning the Quality Gate to a project, you will need to reanalyze the project

What you mean by reanalyzing? Can you explain me step by step?

Hey there.

Presumably, you’ve already analysed some code. Is that right?

  • If you manually configured that analysis (to occur during your build, for example), you should execute it again.
  • If you’re using Automatic Analysis, I think you’ll need to add a new commit on the branch being analyzed

I use Gitlab CI but the result is the same.

Ah – I see now. You’re scanning a short-lived branch (where only New Code is ever represented or evaluated against the Quality Gate). Let me suggest you start reading the documentation here to understand more.

How must I proceed in this case?

If you want the Overall Code to be examined on those branches (so, to be scanned as long-lived branches), you will need to delete them from SonarCloud and adjust the Long Living Branches Pattern RegEx to account for them. Then, you would analyze again.

Keep in mind that we really think New Code should be the focus for branches/pull requests, while Overall Code is more appropriate for the Main Branch.

1 Like

Thanks

Ok I deleted XOC-82 after that I refreshed the sonacloud-check stage on gitlab but the result was the same.Do you think the ReGex patern is correct or something else?


I’d encourage you to test out your RegEx on https://regex101.com/ against your branch name

Ok, Colin one last question why is not computed?

Hello @vladimir_petukhov,

Your next scan is going to compute the Quality Gate. If there are conditions on new code in the Quality Gate then we need to have at least two scans to calculate it (so that the comparison works).