-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
org.openrewrite.java.RemoveUnusedImports
should not removed imports for public static inner class usage
#3283
Labels
bug
Something isn't working
test provided
Already replicated with a unit test, using JUnit pioneer's ExpectedToFail
Comments
Hi, thanks for reporting this issue! Would you be open to contribute to write a unit test for it or even a fix? |
timtebeek
changed the title
org.openrewrite.java.RemoveUnusedImports should not removed imports for public static inner class usage
Feb 5, 2024
org.openrewrite.java.RemoveUnusedImports
should not removed imports for public static inner class usage
Confirmed with this (slightly different) test. @Test
void nestedImports() {
rewriteRun(
java(
"""
package foo;
public interface J {
final class One implements J {}
final class Two implements J {}
final class Three implements J {}
final class Four implements J {}
final class Five implements J {}
final class Six implements J {}
}
"""
),
java(
"""
package bar;
import foo.J;
import foo.J.*;
class Quz {
void test() {
J j = null;
One one = null;
Two two = null;
Three three = null;
Four four = null;
Five five = null;
Six six = null;
}
}
"""
)
);
} |
timtebeek
added
the
test provided
Already replicated with a unit test, using JUnit pioneer's ExpectedToFail
label
Feb 5, 2024
@Laurens-W Since you evaluated RemoveUnusedImports in #4450 it might make sense to briefly look at this one as well. The test is already there; perhaps the fix is similar? |
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
test provided
Already replicated with a unit test, using JUnit pioneer's ExpectedToFail
org.openrewrite.java.RemoveUnusedImports doesn't appear to spot static public inner class usage that's used with wildcard imports statements.
What version of OpenRewrite are you using?
I am using version: 7.40.6
What is the smallest, simplest way to reproduce the problem?
Consider the following class
Which is then used in the following class
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: