-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[java] UnnecessaryFullyQualifiedName false positive for the same name method #1216
Copy link
Copy link
Closed
Labels
a:false-positivePMD flags a piece of code that is not problematicPMD flags a piece of code that is not problematic
Milestone
Description
Affects PMD Version:
6.5.0
Rule:
category/java/codestyle.xml/UnnecessaryFullyQualifiedName
Description:
If an import statement using * notation and a method with the same name exists, a false positive is generated for the UnnecessaryFullyQualifiedName rule.
Example:
import java.util.stream.*;Arrays.stream(...)
import java.time.format.*;LocalDate#format(...)
import javax.swing.undo.*;UndoManager#undo()
Code Sample demonstrating the issue:
import java.awt.Component;
import java.awt.Container;
import java.util.Arrays;
import java.util.stream.*;
public final class Test {
public static Stream<Component> stream(Container parent) {
return Arrays.stream(parent.getComponents())
.filter(Container.class::isInstance)
.map(c -> stream(Container.class.cast(c)))
.reduce(Stream.of(parent), Stream::concat);
}
}
Running PMD through: CLI
> pmd.bat -dir C:\tmp\pmd -R category/java/codestyle.xml/UnnecessaryFullyQualifiedName
C:\tmp\pmd\Test.java:8: Unnecessary use of fully qualified name 'Arrays.stream' due to existing import 'java.util.stream.*'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a:false-positivePMD flags a piece of code that is not problematicPMD flags a piece of code that is not problematic