GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #3729

New issue
Copy link
New issue
Copy link
Closed
#3994
Closed
[java] TooManyMethods ignores "real" methods which are named like getters or setters#3729
#3994
Copy link
Assignees
341816041
Labels
a:false-negativePMD doesn't flag a problematic piece of code
Milestone
6.48.0

Description

@adangel
adangel
opened on Jan 14, 2022
Issue body actions

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

Activity

  1. adangel
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on Jan 14, 2022
  2. oowekyala commented on Jan 15, 2022

    @oowekyala
    oowekyala
    on Jan 15, 2022
    Member
    More actions

    I think this makes sense. I wouldn't use line numbers though. We can check that there is a single statement.

  3. 341816041 commented on May 29, 2022

    @341816041
    341816041
    on May 29, 2022
    Contributor
    More actions

    Hi @oowekyala !
    I'm new here, and I want to contribute to this.

  4. adangel
    assigned
    341816041
    on Jun 2, 2022
  5. adangel
    added
    a:false-negativePMD doesn't flag a problematic piece of code
    and removed
    a:false-positivePMD flags a piece of code that is not problematic
    on Jun 2, 2022
  6. adangel commented on Jun 2, 2022

    @adangel
    adangel
    on Jun 2, 2022
    MemberAuthor
    More actions

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

  7. adangel
    added this to the 6.48.0 milestone on Jul 7, 2022
  8. adangel
    added 2 commits that reference this issue on Jul 7, 2022

    [doc] Update release notes (pmd#3729, pmd#3994)

    71b5855

    Merge pull request #3994 from 341816041:handling_issue_3729

    c83987f
  9. adangel
    closed this as completedin #3994on Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @341816041
    341816041

Labels

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

Type

No type

Projects

No projects

    Milestone

    • 6.48.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.