Quality Gate condition to check number of issues decreased

Hello,

I’m looking for help setting up quality gates which will promote fixing issues.
Using SonarQube 6.7 atm.

The project is in a bad state (215 total issues) and I’d like to fail the QG anytime a new analysis is run and the total number of issues hasn’t decreased.

When adding conditions to QG I don’t see any type of variables I can use to reference the number of issues, is this possible? It seems to always expect a fixed number.

For new issues I am assuming I can just use the ‘New Issues’ condition and set error to 1?

Thanks

Best and simplest approach there would be to leverage the default (and recommended) Quality Gate conditions: SonarQube (i.e. making sure that ratings on new code are pristine).

With respect to your ‘must-decrease’ policy:

I’d like to fail the QG anytime a new analysis is run and the total number of issues hasn’t decreased.

That’s a bit harsh, and is not doable with Quality Gate conditions out-of-the-box. I recommend you read about the recommended methodology: Fixing the Water Leak . And take the time to think about the perverse aspect of what you have in mind: I, as a developer, work on this project containing 215 issues, and implement a brand new Java class, independent from all other legacy code. If your policy was in place, then even if my code was ‘impeccable’ (no rule violated), then my changeset would be rejected because I still don’t decrease the number of overall issues. I lose confidence/sympathy towards this tool, and will find ways to cheat around it (or quickly get my change validated by fixing one of 215 issues without thinking much of it) :frowning_face:

Great article, thanks for your suggestion!

I did not realize the default conditions were applied to new code, mostly because the Quality Gate always fails.
Any idea why does that happen? The reliability and security rating conditions on new code never pass if set to A even when making minor changes.
Edit: Just realized this happening due to the leak period.

1 Like