A data class has an array property, which its equals and hashCode compare by identity

tx0/kotlin:data-class-array-propertyrecommendedwarningreliability/object-contractsdepth fastbug

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.

Example from the rule's tests
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()}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

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.