Find mutableListOf<T>().also { it.add(x) } patterns

Proprietary

Building a list through mutableListOf<T>().also { it.add(...) } is the side-channel form of buildList { add(...) } (or just mutableListOf(x) if every element is known up front). The builder form makes intent explicit.

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