GeezerVison is showing github.com — [java] TooManyMethods ignores "real" methods which are named like getters or setters · Issue #3729 · pmd/pmd
[java] TooManyMethods ignores "real" methods which are named like getters or setters #3729DescriptionAffects PMD Version: any
Rule: TooManyMethods
Description:
This false negative is from a source code comment.
Currently the rule ignores methods, that start with "get", "set", or "is" - which are considered simple getter/setter methods. But if these methods do more complex things (despite they are named like setters, e.g. if the setter contains validating logic), then this should maybe count towards the total method count...
Original comment:
FIXME: Refine XPath to discard 'get' and 'set' methods with Block no more than 3 lines,
something like this:
not (
(
starts-with(@Name,'get')
or
starts-with(@Name,'set')
or
starts-with(@Name,'is')
)
and (
(
(../Block/attribute::endLine)
-
(../Block/attribute::beginLine)
) <= 3
)
)
This will avoid discarding 'real' methods...
Activityoowekyala commented on Jan 15, 2022 I think this makes sense. I wouldn't use line numbers though. We can check that there is a single statement. 341816041 commented on May 29, 2022 Hi @oowekyala !
I'm new here, and I want to contribute to this. adangel commented on Jun 2, 2022 Note: This is actually a false-negative (I labeled it wrong...).
When the class has too many methods, we should get a violation, even if the methods are all called like getters, as long as these are not "real" getters...
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|