sonar-kotlin icon indicating copy to clipboard operation
sonar-kotlin copied to clipboard

SONARKT-379 Fix false positive in S6218

Open fellmann opened this issue 2 years ago • 1 comments

Overriding equals and hashCode is not necessary for data classes that have array fields in their body, because only arguments of the primary constructor are included in the generated equals and hashCode for data classes.

This should not be trigger the rule:

data class ArrayInBody(val age: Int) { // Compliant
    val employers = arrayOf("SonarSource")
}

fellmann avatar Nov 01 '23 13:11 fellmann

Hello @fellmann, thanks for your contribution! I've created a ticket to track this issue.