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

Fix bug adding import to a list of imports containing duplicate imports. #4197

Merged
merged 4 commits into from
May 18, 2024
Merged

Conversation

nguyenhoan
Copy link
Contributor

@nguyenhoan nguyenhoan commented May 17, 2024

What's changed?

Problem:

  • The presence check does not take the member of static imports into consideration
  • The comparison by size cannot handle the case where the original imports contain duplicated imports making its the size be equal to that of the ideally ordered, distinct imports even after adding a new import

Fix: check the presence using the fully qualified names of imports.

What's your motivation?

Fix #4196

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

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Any additional context

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

Problem:
- The presence check does not take the member of static imports into consideration
- The comparison by size cannot handle the case where the original imports contain duplicated imports making its the size be equal to that of the ideally ordered, distinct imports even after adding a new import

Fix: check the presence using the fully qualified names of imports.
@timtebeek timtebeek self-requested a review May 17, 2024 07:58
@timtebeek timtebeek added the bug Something isn't working label May 18, 2024
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 working out the fix! In hind sight comparing the original and ideal number of imports seems strange. I like your suggestion to explicitly check for presence better, thanks!

@timtebeek timtebeek merged commit 46d21d6 into openrewrite:main May 18, 2024
1 check passed
@nguyenhoan
Copy link
Contributor Author

Thank you!

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.

Bug adding import to a list of imports containing duplicate imports
2 participants