Sonar qualilty gate demands code coverage 25k of line but I have modified few hundreds LOC only?

I will explain this issue with a hypothetical example, I have file ‘’ with 2000 lines of code, when I go there and add a new method with 10 lines of code and a junit test against it, then the sonar expects me to write/cover 2000 lines of code.

My quatlity gates is like this:

coverage on new code : is less than 11%

It appears that sonar consider the whole file as new one, even if a single line of code is modified. Is there a way to configure sonar to take in account on ‘new lines’ (which may not be feasible) or at least limit it’s scope to ‘methods’ on which lines modified or added?

Also it expects me to write test on getters/setters and expression like

private Logger logger = LoggerFactory.getLoggger(this.getClass().getClassName());


When you look at the files in SonarQube, are the entire files marked as new (yellow highlight) or just a few lines?

It seems that other users have experienced problems with autocrlf Git settings. That’s fixed in version 1.9.0 of the Git SCM plugin, but you would need to manually update that though the Marketplace (Administration > Marketplace) because it was released after 7.9 was shipped.


1 Like