Skip to content

fix: remove unused imports after deleting a method argument #5710

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pdelagrave
Copy link

@pdelagrave pdelagrave commented Jul 3, 2025

What's changed?

An import will now be removed if the argument deletion by the DeleteMethodArgument recipe leaves it unused.

What's your motivation?

So we can simplify recipes using DeleteMethodArgument, no need to explicitly call RemoveUnusedImports afterwards anymore.

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

Anyone you would like to review specifically?

@timtebeek

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

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jul 3, 2025
@pdelagrave pdelagrave changed the title The tests fix: remove unused imports after deleting a method argument Jul 3, 2025
@timtebeek
Copy link
Member

Tests look good so far. Thanks for getting this started.

@pdelagrave pdelagrave self-assigned this Jul 3, 2025
@pdelagrave pdelagrave marked this pull request as ready for review July 4, 2025 21:05
@pdelagrave pdelagrave force-pushed the delete-method-argument-and-remove-import branch from b1af25a to ead5faa Compare July 4, 2025 21:12
@timtebeek timtebeek marked this pull request as draft July 5, 2025 22:35
@timtebeek timtebeek marked this pull request as ready for review July 5, 2025 22:36
Copy link
Member

@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 the fix here! I like the variety you've used in your tests to guarantee we can remove various different styles of imports. The changes here are additive and mostly defensive, for a recipe that's up to now sparingly used in

With that I see not reason to hold off on a merge, such that we can unblock and simplify the work done on

Not merging right now myself, as I think that's best done when everyone is back to work Monday.

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Jul 5, 2025
@timtebeek timtebeek added enhancement New feature or request recipe Requested Recipe labels Jul 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request recipe Requested Recipe
Projects
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

2 participants