Skip to content
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

CleanupMockitoImports should not remove used mockito kotlin imports #539

Conversation

gideon-sunbit
Copy link
Contributor

What's changed?

Add a NoMissingTypes Precondition to CleanupMockitoImports, to prevent changes if types are missing

What's your motivation?

Fix issue where org.mockito.kotlin imports were being removed although they were in use.
Following suggestion by @timtebeek in Slack channel.

Anything in particular you'd like reviewers to focus on?

Possibly the unit test should use a Kotlin code block and not a Java one? not sure about this.

Anyone you would like to review specifically?

@timtebeek

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@timtebeek timtebeek self-requested a review June 26, 2024 07:19
@timtebeek timtebeek added the bug Something isn't working label Jun 26, 2024
@timtebeek timtebeek marked this pull request as ready for review June 26, 2024 07:19
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting this started! Didn't realize in Slack that it was Mockito Kotlin imports that were incorrectly removed. With that knowledge I've now added special handling, as we kind of expect missing types when it comes to converting Mockito test classes. Hope this works for your real use case too; do let me know when you try our snapshot versions.

@timtebeek timtebeek merged commit fd0eb2d into openrewrite:main Jun 26, 2024
2 checks passed
@timtebeek timtebeek changed the title Add a NoMissingTypes Precondition to CleanupMockitoImports CleanupMockitoImports should not remove used mockito kotlin imports Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants