Find for (i in xs.indices) { val x = xs[i] } patterns

Proprietary

Iterating over xs.indices and indexing back into xs[i] is the explicit-index form of xs.forEachIndexed { i, x -> }. The indexed form is clearer and avoids re-resolving xs[i] on every access.

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