Is there a setting in SonarQube dashboard that allows for ignoring getter and setters? This sounds like a better option then coding //nopmd on every method in your codebase.
My codebase has a lot of them and they are dramatically lowering my unit test coverage % being reported in the Sonarqube dashboard
With the cobertura-maven-plugin setters and getters can be excluded from code coverage using the ignoreTrivial option.
There's currently no way to do exclude specific methods from code coverage. For your second case, the problem is not on Sonar side but on the coverage tool that you use (Cobertura by default, but you may have changed it to Jacoco, Emma or Clover).
The reason for declaring the getters and setters private is to make the corresponding part of the object's abstract state (i.e. the values) private. That's largely independent of the decision to use getters and setters or not to hide the implementation types, prevent direct access, etc.
Given this, getters and setters are also known as accessors and mutators, respectively. The getter method returns the value of the attribute.
There is no option to ignore getters and setters. However, if you have classes you'd like omitted entirely from coverage calculations, you can easily do so with exclusions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With