A data class has an array property, which its equals and hashCode compare by identity
What it finds
The equals and hashCode that a data class generates compare an array property by reference, so two instances with equal contents are not equal. A List, or equals and hashCode written with contentEquals and contentHashCode, compares the elements.
From the rule's source, data_class_array.rs.
data class Packet( val id: Int, val payload: ByteArray,tx0 reports: the generated equals compares the array payload val tags: Array<String>,tx0 reports: compares the array tags) data class Checked(val payload: ByteArray) { override fun equals(other: Any?) = other is Checked && other.payload.contentEquals(payload) override fun hashCode() = payload.contentHashCode()} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:data-class-array-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:data-class-array-property] reason="..."tx0 explain tx0/kotlin:data-class-array-property shows the same in the terminal. Found a false positive? Report it.