SonarQube Quality Gate status report is not stable!

Hi guys,
We have an Angular project that SonarQube quality gate consider it as Passed but after a couple of runs and adding invalid codes, it’s reported as Failed (which makes sense).
After fixing the issues and sending it to SonarQube, the project is still in Failed mode! and SonarQube is not considering it as Passed!
If I create a new project in SonarQube and send the same code to SonarQube. It consider the project as Passed!
Why does it happen?
I don’t want to delete the project in SonarQube and create a new one and lose all our report history.

Thanks

Hi @soheils,

which version of SonarQube do you use? and which edition?
Why does the Quality Gate fail? (which criteria, which metrics)?
Can you share screenshots?

Thanks,
Carine

Hi Carine,
It’s Community Edition, Version 7.7 (build 23042).
We use SonarQube default Quality Profiles (Sonar way). Please find the screenshot.
CSO project is the main one that was Passed and now it Failed.
zCSO is the same source code but pushed into a new project in SonarQube.
Please find the attached screenshots.
There are more screenshots, but I can’t upload more than one as I’m a new user!
Please let me know if you need more details.

thanks,
Soheil

Main Project:

The same project source code but pushed into a brand new Sonar project.

Hi again,

this behaviour is 100% normal:

  • you set up a Quality Gate only on “New Code”. As you added, in your CSO Project, New Code lines without coverage, the Code Coverage on New Code criteria is failed --> Quality Gate failed

  • when you created your new project zCSO, you analysed it with the same Quality Gate which is only on New Code. And, by definition, there is no New Code on this project, as this is the 1st analysis. So yes, the Coverage is 0%, but there is no Coverage on New Code, so the Quality Gate criteria are all green. (because you don’t have any “New Code” and you don’t have a criteria set up on “Code Coverage on overall code”).

If you add new lines on this zCSO project and relaunch an analysis, you’ll see the same screenshot as you have on your 1st project, with 2 different parts: a white one, with all code, and a “yellow” one, for New Code. And the Quality Gate you’ve set up, which only on New Code, will then fail because code Coverage on New Code will not be at the right level, in case you don’t cover correctly these new lines.

Hope this is clear,
Carine

2 Likes

Thanks Carine!
I updated the Quality Gate configs and it’s all OK now.
Soheil

hi Carine,
i am using the same verison of sonarqube community 7.7, and has faced the same issue on some projects in sonar. i check for criteria “Code Coverage on overall code” in quality gate but unable to find it…can you please suggest.

soheil,
Can you please help me.

Hi @ranid

can you share some screenshots on how you set up your Quality Gates ?
You should have a button “Add a condition” and then be able to choose “New Code” or “Overall Code” with a list like this :

Carine