In fact, that should be the default behavior! See the docs here.
Is it possible you have more than 20 New Lines in the PR, even if you only have 1 line to cover? You should see this info in the Size section of the same Measures page you shared a screenshot of.
I have total 75 lines of code in PR. One line in actual main code and 74 lines in test. The sonar configuration I have shared above.
If I just have under 20 lines in PR including both main and test code. It works. What I am looking for is only in main / non test code if I have less than 20 lines it should pass irrespective of how many lines are there in the test code. Is it possible?
I see what you’re saying now. And unfortunately 7 years ago we also recognized that it would be better to use “Lines to cover” as the 20 line threshold. SONAR-11283
And the ticket was recently closed.
I’m digging into it on my end, because the ticket makes a lot of sense.