I'm using PMD for analyse a Java 8 project and I'me getting an unexpected result.
In one method I have a Stream s:
s.collect(Collectors.toList());
and I receive an error: Unnecessary use of fully qualified name 'Collectors.toList' due to existing import 'java.util.stream.Collectors', but as far as I have tested, it is not possible to not include the Collectors prefix.
The code is available at https://github.com/FenixEdu/fenixedu-learning/blob/master/src/main/java/org/fenixedu/learning/domain/executionCourse/components/InitialPageComponent.java#L50
Hi,
that's actually correct - you have also a static import of
Collectors.toList()which means you can call "toList" directly without the class name...However, the message is not entirely clear about this... it should better say "... due to existing static import 'java.util.stream.Collectors.toList".
I'll change the message to be:
Thanks,
Andreas
Was not aware of that. Thanks, and sorry.
Commit: https://github.com/pmd/pmd/commit/ad1ffa583559f314214ce022d4572f2bc04fd581