Skip to content

[java] Make SingularField consider nested classes by default #3629

@Zustin

Description

@Zustin

Affects PMD Version:6.39.0

Rule:SingularField

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

Description:
PMD should report a warning at line 3, but it doesn't. Actually, it is a SingualrField a. So, I think it is a false negative. Thanks for your consideration and I am happy to help fix this issue.

Code Sample demonstrating the issue:

class Tester {
  class nestedClass {
      private int a;
      public int func(int b) {
          a = b + 5;
          return a;
      }
  }
}

Expected outcome: A warning

PMD should report a violation at line 3, 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