Find x.takeIf { p }?.let { ... } patterns

Proprietary

x.takeIf { p }?.let { … } is a guard-then-transform expressed as two calls plus a safe-call. if (p) x.let { … } else null (or x.takeIf(p)?.run { … }) is the same in one operator without the implicit null bridge.

org.openrewrite.kotlin.idiom.FindTakeIfChainedLet$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.idiom.FindTakeIfChainedLet$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.