Collapse redundant collection / string conversions

Proprietary

Drops 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$KtRecipe
mod 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.

  1. Use toSet() instead of distinct().toSet()
  2. Use toSet() instead of toList().toSet()
  3. Use toList() instead of toMutableList().toList()
  4. Use toTypedArray() instead of toList().toTypedArray()
  5. Use distinct() instead of toSet().toList()
  6. Use trim() instead of trimStart().trimEnd()
  7. Use trim() instead of trimEnd().trimStart()
  8. Drop redundant String.toString()