Skip to content

ReplaceInitMockToOpenMock: Ensure unique name for added tearDown method #725

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 1 commit into
base: main
Choose a base branch
from

Conversation

amishra-u
Copy link
Contributor

What's changed?

This pr updates the ReplaceInitMockToOpenMock recipe to avoid creating duplicate tearDown methods. Previously, the recipe would unconditionally add a tearDown method, potentially causing conflicts if one already existed in the class. The new logic checks for existing methods named tearDown and appends the next available numeric suffix (e.g., tearDown0, tearDown1, etc.) to ensure method name uniqueness.

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 May 9, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/resources/META-INF/rewrite/examples.yml
    • lines 2583-2598
    • lines 3392-3391
    • lines 3427-3445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant