A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3694 below:

[java] SingularField ignores static variables · Issue #3694 · pmd/pmd · GitHub

Affects PMD Version:
6.41.0+
7.0.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:
Hi, I found two false negatives about the rule SingularField. Please refer to the following case, PMD should have reported a false negative at line 2 and 3. I think these cases are caused by modifiers of var1 and var2.

Code Sample demonstrating the issue:

class Impl {
  final private int var1 = 10;  // should report a warning here
  static private int var2 = 10; // also should report a warning here
  public int foo() {
    return var1;
  }
  public int foo(int y) {
    var2 = y + 5;
    return var2;
  }
}

Expected outcome:

PMD should report violations at line 2 and 3, but doesn't. This is a false-negative.

Running PMD through: [Maven]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4