Find Boolean-conditional smells

Proprietary

if (x) true else false, its inverse, !x.isEmpty() / !x.isBlank() family negations, if (x == null) null else x.foo(), if (x != null) x.foo() patterns, and if (return …) else … early-return ladders — each is the long form of a single Kotlin operator or method.

org.openrewrite.kotlin.bestpractices.FindBooleanConditionalSmells$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.bestpractices.FindBooleanConditionalSmells$KtRecipe'

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. Find if (x) true else false patterns
  2. Find if (x) false else true patterns
  3. Find if (x == null) null else x.foo() patterns
  4. Find if (x != null) x.foo() patterns
  5. Find !x.isEmpty() calls
  6. Find !x.isNotEmpty() calls
  7. Find !x.isBlank() calls
  8. Find !x.isNotBlank() calls
  9. Find x.isNotEmpty() on String where isNotBlank() might be wanted
  10. Find if (x) { return … } else { … } patterns