Use toSet() instead of toList().toSet()
ProprietaryMaterializing a List first and then a Set allocates one collection that's thrown away. toSet() builds the deduplicating collection directly.
org. openrewrite. kotlin. stdlib. UseToSetForToListToSet$KtRecipemod run . --recipe= 'org. openrewrite. kotlin. stdlib. UseToSetForToListToSet$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.