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

Hi Carine,
i do not get the option for selecting the new code and overall code in sonarqube.
PFB snnipet.

Hi @ranid,

my screenshot was from the very last version of SonarQube.
As you are on 7.7, when you type “Coverage” in your interface, you’ll find a simple criteria called “Coverage” and that means Coverage on all code.

And I encourage you to upgrade to the latest version 7.9 LTS to benefit from all new features :slight_smile:

Carine

Hi Carine,
is there any other way to resolve this issue. as we are getting this in only one project not in rest of the projects. right now we cannot upgrade the version of sonarqube.

can you please suggest.

Hi @ranid,

not sure to understand why you can’t upgrade from 7.7 to 7.9?
And your Quality Gate is the same for your projects, so if you don’t have this criteria for one project, you’ll miss it for the entire bunch of projects onboarded in SQ.

Carine

Just a quick question.
i have * Community Edition Version 7.7 (build 23042) LGPL v3 .
can i upgrade to 7.9 LTS. is it free and open source

7.9 LTS version exists in Community and Commercial Editions.
The Community version is the free and open source one.