Inspections: Add inspection on equals()/hashCode()
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">equals() and hashCode() not paired</problem_class>
|
||||
<description>Class has <code>equals()</code> defined but does not define <code>hashCode()</code></description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">equals() and hashCode() not paired</problem_class>
|
||||
<description>Class has <code>hashCode()</code> defined but does not define <code>equals()</code></description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>14</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">equals() and hashCode() not paired</problem_class>
|
||||
<description>equals()/hashCode() in object declaration</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>18</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">equals() and hashCode() not paired</problem_class>
|
||||
<description>equals()/hashCode() in object declaration</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>22</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">equals() and hashCode() not paired</problem_class>
|
||||
<description>equals()/hashCode() in object declaration</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.EqualsOrHashCodeInspection
|
||||
@@ -0,0 +1,39 @@
|
||||
class C1 {
|
||||
override fun equals(other: Any?) = true
|
||||
}
|
||||
|
||||
class C2 {
|
||||
override fun hashCode() = 0
|
||||
}
|
||||
|
||||
class C3 {
|
||||
override fun equals(other: Any?) = true
|
||||
override fun hashCode() = 0
|
||||
}
|
||||
|
||||
object O1 {
|
||||
override fun equals(other: Any?) = true
|
||||
}
|
||||
|
||||
object O2 {
|
||||
override fun hashCode() = 0
|
||||
}
|
||||
|
||||
object O3 {
|
||||
override fun equals(other: Any?) = true
|
||||
override fun hashCode() = 0
|
||||
}
|
||||
|
||||
class C4 {
|
||||
override fun equals(other: С4) = true
|
||||
}
|
||||
|
||||
interface I {
|
||||
override fun equals(other: Any?) = true
|
||||
override fun hashCode() = 0
|
||||
}
|
||||
|
||||
enum E {
|
||||
override fun equals(other: Any?) = true
|
||||
override fun hashCode() = 0
|
||||
}
|
||||
Reference in New Issue
Block a user