Use distinct() instead of toSet().toList()

Proprietary

distinct() returns a List with duplicates removed in one pass. toSet().toList() allocates a set and then copies its contents into a list — two allocations to do the same job, and the order semantics differ subtly because hash-based sets don't preserve insertion order across all platforms.

org.openrewrite.kotlin.bestpractices.UseToListForToSetThenToList$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.bestpractices.UseToListForToSetThenToList$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.