-
Notifications
You must be signed in to change notification settings - Fork 80
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
Add failing test for CleanupMockitoImports #336
Add failing test for CleanupMockitoImports #336
Conversation
…tchers are being cleaned up while used. I have reproduced the problem with a new failing test. I needed to add junit-pioneer as it was not yet present, I added with a fixed version as it looks like it is not part of the platform.
src/test/java/org/openrewrite/java/testing/mockito/CleanupMockitoImportsTest.java
Outdated
Show resolved
Hide resolved
Related to openrewrite/rewrite#3111 |
while I can "fix" this issue by adding a redundant "cast to self", I have not been able to reproduce this with lombok in these tests. That seems to be a secondary problem.
keeps the import while
removes it |
Yes that also ties into openrewrite/rewrite#1297; full support for Lombok is a difficult one unfortunately. Let's hope we can add something quickly to at least take out the pain here. |
import lombok.RequiredArgsConstructor; | ||
@RequiredArgsConstructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These annotations are not supported in the input strings; not sure how it affects the test, but if we can replicate the issue without these that'd be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import lombok.RequiredArgsConstructor; | |
@RequiredArgsConstructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like my issue is related to combination of lombok + var
so that would make it hard to write a test to reproduce it :/
The following work:
|
@pstreef I'm doubting a bit what to do about this PR; I think the underlying problem is mostly separately tracked in openrewrite/rewrite#3111. Would you be OK with closing this one in favor of that other one? I'm also open to alternatives to create exceptions here, as the recipe does aim to not remove any imports when uncertain about types: Line 44 in 79690a9
Perhaps org.openrewrite.java.NoMissingTypes could be added as a precondition here? That would certainly restrict when we make changes.
|
@timtebeek I'm fine with closing it as duplicate 👍 |
Recipe
CleanupMockitoImports
cleans too much. My argument matchers are being cleaned up while used. I have reproduced the problem with a new failing test.I needed to add junit-pioneer as it was not yet present, I added with a fixed version as it looks like it is not part of the platform.