Apply Kotlin collection shorthands
ProprietaryReplaces round-trip conversions (asSequence().toList(), toList().toSet(), toSet().toList(), …) with the dedicated stdlib operator they're imitating.
org. openrewrite. kotlin. stdlib. CollectionShorthands$KtRecipemod 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.
- Use
take(n)instead ofsubList(0, n) - Use
toList()instead ofasSequence().toList() - Use
toSet()instead oftoList().toSet() - Use
distinct()instead oftoSet().toList() - Use
distinct()instead oftoHashSet().toList() - Use
toList()instead oftoMutableList().toList() - Use
toSet()instead oftoMutableSet().toSet() - Use
distinct().toMutableList()instead oftoSet().toMutableList()