Apply Kotlin collection shorthands

Proprietary

Replaces round-trip conversions (asSequence().toList(), toList().toSet(), toSet().toList(), …) with the dedicated stdlib operator they're imitating.

org.openrewrite.kotlin.stdlib.CollectionShorthands$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.stdlib.CollectionShorthands$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. Use take(n) instead of subList(0, n)
  2. Use toList() instead of asSequence().toList()
  3. Use toSet() instead of toList().toSet()
  4. Use distinct() instead of toSet().toList()
  5. Use distinct() instead of toHashSet().toList()
  6. Use toList() instead of toMutableList().toList()
  7. Use toSet() instead of toMutableSet().toSet()
  8. Use distinct().toMutableList() instead of toSet().toMutableList()