I will explain this issue with a hypothetical example, I have file ‘LegacyCode.java’ 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());