Do not include LOC from Test classes while counting 'New Lines'

We are using sonarqube enterprise edition 9.9.7.
We have added the following condition in our quality gate
“Lines is greater than 2,000”
but when devs raise PR with, let’s say 1500 lines of java code and another 1500 lines of unit tests, the sonarqube failing the quality gate saying new lines is greater than 2000.
Is there way to configure sonarqube to only count the LOC from actual code and exclude test classes while counting the new lines?

Hey @Vishal_TK

We really don’t think it makes sense to set a Quality Gate condition like this – as it doesn’t relate to the quality of the code being written, but instead development processes (prefer small PRs) which is not what SonarQube is meant to enforce.

You can exclude test code entirely, but you cannot stop it from being counted towards the new lines metric while otherwise being analyzed.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.