Skip to content

[java] Merge unused declaration rules #2972

@oowekyala

Description

@oowekyala

The rules UnusedLocalVariable, UnusedPrivateField, UnusedFormalParameter, and UnusedPrivateMethod could be merged together in pmd 7, eg in a new rule UnusedDeclaration. This would make them easier to include, and centralize their doc and configuration.

Also removing the "private" from the name of UnusedPrivateMethod and UnusedPrivateField would make it possible to also check members with other visibilities. Eg a package-private field of a private class is effectively private and could be checked as well.

In later improvements to that rule, we could also flag

  • unused constructors
  • unused type parameters
  • unused type declarations

Category: I think design is more appropriate than bestpractices

Additional context

#2957

Metadata

Metadata

Assignees

No one assigned

    Labels

    an:enhancementAn improvement on existing features / rules

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions