SonarQube Developer Edition Version 8.7.1 (build 42226)
Hello Experts!
We would want so SonarQube fails the build if Overall Code Coverage is being decreased after a pull request.
The goal is to have non decreasing code coverage in the project. It should be the same or grow.
Such approach works good for legacy products.
Example:
Before a pull request project has 50% of code coverage.
If after this pull request Overall code coverage becomes 51% or more - build OK, if it becomes 49% or less - build fails.
At my previous job it was possible to do in SonarQube (years ago)
At the current version I cannot find how I can do it. Conditions have no such options.
Please tell is it possible?
If not, why it was removed from the previous version of SonarQube?
I have found a couple of topics regarding this issue but they do not answer on my question:
Exactly what you describe isn’t possible. What is possible is to enforce coverage on new code. Make sure that new code is always covered and organically over time your overall coverage will naturally increase.
If you want to enforce this strictly, you’ll need to disable ‘Ignore duplication and coverage on small changes’ (Administration → General).
Hello Ann!
Thank you for the answer.
This flag means that SonarQube will check on duplication and code coverage even on small pieces of code (less than 20 lines).
Does it mean that even when this flag is ON the SonarQube automatically checks New Code on duplications and code coverage when lines more than 20?
It actually means that SonarQube already does this action. So it fails New Code when code coverage is not enough.
But what I see, that even when New Code build fails the Overall Code build is OK. And that’s the issue. In other words, we do allow a Team to decrease the Overall Code coverage.
Whether my understanding it correct or I misunderstand?
SonarQube will always calculate those things on new and overall code. What the flag does is determine whether the result of the the calculation will fail the Quality Gate for small changesets.