KT-17888 Inspection to warn about suspicious combination of == and ===
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Suspicious combination of == and ===</problem_class>
|
||||
<description>Suspicious combination of == and ===</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Suspicious combination of == and ===</problem_class>
|
||||
<description>Suspicious combination of == and ===</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>7</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Suspicious combination of == and ===</problem_class>
|
||||
<description>Suspicious combination of == and ===</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>9</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Suspicious combination of == and ===</problem_class>
|
||||
<description>Suspicious combination of == and ===</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+1
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.SuspiciousEqualsCombination
|
||||
@@ -0,0 +1,15 @@
|
||||
object Main {
|
||||
fun test() {
|
||||
val type1 = Main
|
||||
val type = Main
|
||||
if (type === CONST1 || type == CONST2 && type === CONST3) return
|
||||
if (type === CONST1 || type == CONST2 && (type === CONST3)) return
|
||||
if (type === CONST1 || type == CONST2 && !(type === CONST3)) return
|
||||
if (type === CONST1 || type1 == CONST2 && type === CONST3) return
|
||||
if (type === CONST1 || type1 == CONST1 && type === CONST3) return
|
||||
}
|
||||
|
||||
val CONST1 = Main;
|
||||
val CONST2 = Main;
|
||||
val CONST3 = Main;
|
||||
}
|
||||
Reference in New Issue
Block a user