Skip to content

[java] Make UnusedPrivateMethod consider enum classes #3633

@Zustin

Description

@Zustin

Affects PMD Version:
6.39.0

Rule:
UnusedPrivateField

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#unusedprivatefield

Description:
Hi, I think PMD should have reported a violation warning at line 5, but it does not. Actually, the method func is a unused private method. Hence, I think it is a false negative. I am happy to help fix this issue. Thanks for your consideration and help.

Code Sample demonstrating the issue:

class Impl {
  enum EnumClass {
      FOO;
      EnumClass() {}
      private void func(){};  // should report a warning here
  }
}

Expected outcome:A warning

PMD should report a violation at line 5, but doesn't. This is a false-negative.

Running PMD through: [Maven]

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions