Simplify ternary expressions

MSAL

Simplifies various types of ternary expressions to improve code readability. Ternaries that simply select between true and false are redundant wrappers around the condition itself and add unnecessary complexity.

org.openrewrite.staticanalysis.SimplifyTernaryRecipes
mod run . --recipe=org.openrewrite.staticanalysis.SimplifyTernaryRecipes

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Replace booleanExpression ? true : false with booleanExpression
  2. Replace booleanExpression ? false : true with !booleanExpression