Skip to content

Conversation

Jenson3210
Copy link
Contributor

What's changed?

By storing (reducing) the variables declared in the first block, we can see that the usages in the second block not refer to them. By using map.remove we make sure that we only replace the first statement in the second block (if any)

What's your motivation?

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

@Jenson3210 Jenson3210 self-assigned this Aug 5, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Aug 5, 2025
@Jenson3210 Jenson3210 added the bug Something isn't working label Aug 5, 2025
@Jenson3210 Jenson3210 changed the title Fixed the provided failing test Redeclare variables in new blocks when running MinimumSwitchCases Aug 5, 2025
Jenson3210 and others added 2 commits August 5, 2025 12:39
…s.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@Jenson3210 Jenson3210 moved this from In Progress to Ready to Review in OpenRewrite Aug 5, 2025
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
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

MinimumSwitchCases does not redeclare variables in new blocks
2 participants