A RetroSearch Logo

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

Search Query:

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

false-positive in an enum that uses its own static variables · Issue #5263 · pmd/pmd · GitHub

Affects PMD Version: 7.6.0

Rule:

UnnecessaryFullyQualifiedName

Description:

Code Sample demonstrating the issue:

package org.apache.commons.io;

public enum EnumX {

    VALUE_X(EnumX.X); // MUST qualify the name or the file won't compile

    static final String X = "X";

    private final String v;

    EnumX(final String v) {
        this.v = v;
    }

    public String getV() {
        return v;
    }
}

Incorrectly generates:

<violation beginline="5" endline="5" begincolumn="13" endcolumn="18" rule="UnnecessaryFullyQualifiedName" ruleset="Code Style" package="org.apache.commons.io" class="EnumX" externalInfoUrl="https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname" priority="4">
Unnecessary qualifier 'EnumX': 'X' is already in scope because it is declared in an enclosing type
</violation>

Expected outcome:

PMD reports a violation at line 5, but that's wrong. That's a false positive.

Running PMD through: Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)


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