Collapse redundant collection / string conversions
ProprietaryDrops needless toList()/toMutableList()/toSet()/toTypedArray() round-trips and trimStart().trimEnd()-style chains that allocate one or more intermediate copies. The replacement performs the same conversion in one pass.
org. openrewrite. kotlin. bestpractices. CollapseRedundantConversions$KtRecipemod run . --recipe= 'org. openrewrite. kotlin. bestpractices. CollapseRedundantConversions$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
toSet()instead ofdistinct().toSet() - Use
toSet()instead oftoList().toSet() - Use
toList()instead oftoMutableList().toList() - Use
toTypedArray()instead oftoList().toTypedArray() - Use
distinct()instead oftoSet().toList() - Use
trim()instead oftrimStart().trimEnd() - Use
trim()instead oftrimEnd().trimStart() - Drop redundant
String.toString()