A RetroSearch Logo

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

Search Query:

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

[java] UnnecessaryImport false positive for on-demand imports of nested classes · Issue #4082 · pmd/pmd · GitHub

Affects PMD Version:
6.48.0 (but works fine in 5.8.1)

Rule:
UnnecessaryImports

Description:
Nested classes (non-static and static) can be imported using on-demand import and static nested classes can be imported with on-demand static import. For both cases PMD will show 'Unused import X.X.X`

Code Sample demonstrating the issue:

package net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.package2;

public class C {
    private C() { }

    public class IC {}

    public static class ISC {}
}
package net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.package1;

import net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.package2.C.*;

public class U {
    IC c;
}
package net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.package1;

import static net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.package2.C.*;

public class U {
    ISC sc;
}

Expected outcome:
PMD reports a violation Unused net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.package2.C, but that's wrong. That's a false positive.

Running PMD through:
Ant


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