Find scope-function correctness swaps

Proprietary

The 12 well-known scope-function correctness rules: with(x) used as a receiver expression vs x.run { }, ?.apply { } whose result is discarded vs ?.also { }, apply { } without mutation vs also { }, also { } with mutation vs apply { }, redundant this. inside apply { }, run without this references.

org.openrewrite.kotlin.idiom.FindScopeFunctionSwaps$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.idiom.FindScopeFunctionSwaps$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 with(x) { ... } used as an expression
  2. Find redundant this. inside apply { } blocks
  3. Find apply { } blocks that perform no mutation
  4. Find also { } blocks that mutate the receiver
  5. Find ?.apply { } whose result is discarded
  6. Find x.run { ... } that doesn't use the receiver