Is it possible to disable failing PRs on New Code coverage, while keeping failing PRs if the entire project coverage drops below a set percentage?
i.e. we want to keep the project coverage to remain above 90%, but do not mind if individual PR decrease the coverage as long it would not drag the total coverage below the set threshold.
Let me rephrase your question to be sure I understand your point.
You have a target for main branch coverage set at XY% and you want the quality gate to fail if this objective is not met.
For PR you want a dynamic behaviour which understands the impacts on the main branch before it’s actually merged: if the coverage in the main branch is still above XY% you don’t want the quality gate of the PR to fail even if the new code in the PR has no coverage at all.
Is this correct?
That is correct @Olivier_Schmitt
SonarCloud implements an opinionated methodology about code quality.
This methodology is described here.
The use case you described is not really compatible with this methodology: Clean As You Code aims to prevent the accumulation of technical debt.
The use case you described is also likely to create a code quality ownership problem: if 2 PRs lowered the code coverage by 1% each and the third one by 0.5% but breaks the 90% when merged, who is responsible for this broken quality gate?
The latest PR even if the previous PRs degraded the coverage more? Or maybe the first PR which lowered the coverage from 1%, and but people behind PR 1 could argue that PR 2 dealt with more important changes and those shoud be covered and so on …
So, to answer your request: it’s not possible and we don’t consider this the way to go at this stage.