Find Boolean-conditional smells
Proprietaryif (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$KtRecipemod 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.
- Find
if (x) true else falsepatterns - Find
if (x) false else truepatterns - Find
if (x == null) null else x.foo()patterns - Find
if (x != null) x.foo()patterns - Find
!x.isEmpty()calls - Find
!x.isNotEmpty()calls - Find
!x.isBlank()calls - Find
!x.isNotBlank()calls - Find
x.isNotEmpty()onStringwhereisNotBlank()might be wanted - Find
if (x) { return … } else { … }patterns