A RetroSearch Logo

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

Search Query:

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

[java] SingularField doesn't consider anonymous classes defined in non-private fields · Issue #3620 · pmd/pmd · GitHub

Affects PMD Version: 6.40.0

Rule: SingularField

Description: The rule skips all non-private fields, but these fields could define a nested anonymous class which itself has singular fields.

Code Sample demonstrating the issue:

public class Foo {
    Object field = new Object() {
        private int x; // singular field

        int bar(int y) {
            x = y + 5;
            return x;
        }
    };
}

Expected outcome:

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


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