Find data class declarations with var properties

Proprietary

data class generates equals and hashCode over the primary-constructor properties. Mutating a var property after the instance is stored in a hash-based collection breaks the invariant — the entry can no longer be found by lookup. Prefer val; if mutation is needed, model it through copy(...).

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