I wish to add a PMD check to ensure that a class does not have too many public methods, but I do not want constructors and getters/setters to be included in the check.
The ExcessivePublicCount check includes constructors, getters/setters and public variables, and I can't see a way to customise it.
The TooManyMethods check excludes getters/setters, but includes everything else (including private methods). The XPath code for the check is as follows.
//ClassOrInterfaceDeclaration/ClassOrInterfaceBody
[
count(descendant::MethodDeclarator[
not
(
starts-with(@Image,'get')
or
starts-with(@Image,'set')
)
]) > $maxmethods
]
Can anyone help me out with modifying this to achieve what I want, or suggest another way to do this with PMD?