I’m using SonarQube Enterprise 8.9.1 and I’ve got a question with regards to the Clean As You Code approach and Quality Gates for which I’ve been unable to find a solution.
I’ll start by trying to explain what my overall objective is and I hope it makes sense.
I have branch analysis set up and what I would like to accomplish, is a situation where each new code per branch is cleaner than its parent or previous version.
I’ve set my New Code definition to Previous Version, but this leads me to a question.
I can set my Quality Gate to fail if the number of Bugs is greater than 10, which means that with each new scan, as long I have less than 10 bugs, my Quality Gate passes.
But let’s assume I have run 10 builds or scans on a particular branch, each with 4 bugs and then I have build number 11 with 9 bugs.
Build number 11 will pass, because although it contains 9 bugs, it has not breached the Quality Gate threshold of 10 bugs, but it has now introduced 5 more bugs than builds 1 -10.
Ideally, I would like for build 11 to fail as it’s introducing more bugs than the previous builds.
This way, each new scan is either equal to or cleaner than its previous version, ultimately leading to a place where there are little or no bugs.
I hope this makes sense.
Is there a way to ensure that new code is always cleaner than the previous version and doesn’t introduce any new bugs or security vulnerabilities?
Can this somehow be accomplished using Quality Gates or is there some other mechanism in SonarQube for this, or does it not exist at all?