A data class has a var property, so its equality and hash code change over time
What it finds
A data class compares and hashes by its properties. With a var, an instance put into a set or used as a map key can change its hash afterwards and get lost there. copy makes changed instances without that risk.
From the rule's source, mutable_data_class.rs.
data class Point(val x: Int, var y: Int)tx0 reports: y is a var in a data classclass Plain(var x: Int) Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:mutable-data-class-property" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:mutable-data-class-property] reason="..."tx0 explain tx0/kotlin:mutable-data-class-property shows the same in the terminal. Found a false positive? Report it.