A RetroSearch Logo

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

Search Query:

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

[java] Make CompareObjectWithEquals allow comparing against constants · Issue #3205 · pmd/pmd · GitHub

Affects PMD Version: 6.33

Rule: CompareObjectsWithEquals

Description: CompareObjectsWithEquals would be less noisy if it would accept comparing against final fields which serve as sentinel values

Code Sample demonstrating the issue:

class MyClass {
    static final MyClass MISSING = new MyClass();

    public static void isMissing(MyClass obj) {
          return obj == MISSING; // no violation expected...
    }
}

Also see

Note that in many of those cases the constant is not static. So we should allow non-static constants, possibly, provided they have an all uppercase name.

Expected outcome:

Running PMD through: Any


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