[java] Update rule UnnecessaryImport#3718
Conversation
a04a284 to
0871b5a
Compare
Generated by 🚫 Danger |
|
Thanks for updating this rule - it looks good. While looking through the regression tester report, I found some possible false positives: a) https://github.com/checkstyle/checkstyle/blob/checkstyle-9.1/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeTestStaticImports.java#L20 pmd/.ci/files/project-list.xml Line 27 in 1952954 b) https://github.com/checkstyle/checkstyle/blob/checkstyle-9.1/src/test/java/com/puppycrawl/tools/checkstyle/AbstractXmlTestSupport.java#L22 Unless we have a problem with our classpath, since both methods would come in through a 3rd party library... c) https://github.com/openjdk/jdk/blob/jdk-11%2B28/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java#L40 d) https://github.com/openjdk/jdk/blob/jdk-11%2B28/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java#L49 In this (big) file SubmissionPublisher, the interface "Subscription" is mostly referenced via "Flow.Subscription", but on Line 886 just with "Subscription". |
|
Thanks for the review! I think I'll add additional logic to be more conservative when an import is unresolved. The rule already handles unresolved type imports gracefully, thanks to the unresolved symbols of the symbol API. I think we should also be more intelligent with unresolved static imports. |
|
Actually let's do this in a followup PR. I'll investigate the FP (d) you found in this PR. |
|
I think the new FP should be fixed with #3748. This PR is ready to merge IMO |
Describe the PR
Part of #2701
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)