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

Avoid parenthesis only cleanup in SimplifyConstantIfBranchExecution #287

Merged

Conversation

Bananeweizen
Copy link
Contributor

What's changed?

Recognize when the recipe cannot optimize to a constant condition and return the if-condition as before all attempted optimizations.

What's your motivation?

Fixes #286.

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

Recognize when the recipe cannot optimize to a constant condition and
return the if-condition as before all attempted optimizations.

Fixes openrewrite#286.
@timtebeek timtebeek added the bug Something isn't working label Apr 26, 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.

Nice and clean solution, thanks!

@timtebeek timtebeek merged commit c2fffaf into openrewrite:main Apr 26, 2024
2 checks passed
@Bananeweizen Bananeweizen deleted the simplify_constant_if_branch_286 branch April 26, 2024 17:54
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.

SimplifyConstantIfBranchExecution unconditionally removes braces
2 participants