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

Simplify constant ternary expressions too #4617

Merged
merged 2 commits into from
Oct 27, 2024

Conversation

timtebeek
Copy link
Contributor

What's changed?

Expand SimplifyBooleanExpressionVisitor to also clear out ternary expressions with a hardcoded true/false

What's your motivation?

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

Didn't want to duplicate or recurse too much for parentheses, instead assuming this is often combined with remove unnecessary parentheses already.

@timtebeek timtebeek merged commit 4e2eae9 into main Oct 27, 2024
2 checks passed
@timtebeek timtebeek deleted the simplify-constant-ternary-expressions branch October 27, 2024 14:30
timtebeek added a commit to JLLeitschuh/rewrite-static-analysis that referenced this pull request Oct 27, 2024
timtebeek added a commit to openrewrite/rewrite-static-analysis that referenced this pull request Oct 27, 2024
* Add Two Recipes

 - BufferedWriterCreation
 - SimplifyConstantTernaryExecution

Signed-off-by: Jonathan Leitschuh <[email protected]>

* Apply auto formatting to owning LST element

* Apply formatter and best practices

* Drop unnecessary UsesType

* Minor polish

* Drop now unnecessary SimplifyConstantTernaryExecution

Following openrewrite/rewrite#4617

* Restore private `cleanupBooleanExpression`

* Convert to regular Refaster recipe

Following openrewrite/rewrite-templating#114

---------

Signed-off-by: Jonathan Leitschuh <[email protected]>
Co-authored-by: Knut Wannheden <[email protected]>
Co-authored-by: Tim te Beek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant