Skip to content

[java] TooManyMethods ignores "real" methods which are named like getters or setters #3729

@adangel

Description

@adangel

Affects 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...

Metadata

Metadata

Assignees

Labels

a:false-negativePMD doesn't flag a problematic piece of code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions