Search code examples
javasonarqubecommentsgetter-settersonarqube-5.4

SonarQube: avoid counting comments percentage for getters and setter in java


After searching for a while here and in the web I found the property sonar.squid.analyse.property.accessors which was documentated here: https://docs.sonarqube.org/display/SONAR/Metrics+-+Public+API

This looks like what we want but the documentation is outdated. In the current documentation this property is not mentioned any more.

We have in some big java projects a lot of utility classes which usually only contains properties with their corresponding getters and setter methods.

This is drawing our percentage of comments down just remarkably.

Is there a way (besides adding //NOSONAR to every method or excluding all files manually by configuration) to avoid counting missing comments in the getter/setter-methods to the comments percentage?


Solution

  • The property sonar.squid.analyse.property.accessors was dropped in a previous version of SonarJava (and dropped from the documentation as well). As such the getters and setters were counted as undocumented API but this has been fixed already: https://jira.sonarsource.com/browse/SONARJAVA-1857

    Please consider upgrading SonarJava to the latest version (4.6 at time of writing, requiring SonarQube LTS 5.6 and java 8 )