Add Boolean? == const to elvis conversion and vice versa #KT-15368 Fixed

Convert elvis to equality check implemented as inspection due
code style guide
This commit is contained in:
Dimach
2017-06-10 02:39:48 +03:00
committed by Mikhail Glukhikh
parent 6e9c0a0fda
commit d369fa094a
36 changed files with 437 additions and 1 deletions
@@ -0,0 +1,51 @@
<problems>
<problem>
<file>test.kt</file>
<line>4</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis</problem_class>
<description>Equality check can be used instead of elvis</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">Equality check can be used instead of elvis</problem_class>
<description>Equality check can be used instead of elvis</description>
</problem>
<problem>
<file>test.kt</file>
<line>10</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis</problem_class>
<description>Equality check can be used instead of elvis</description>
</problem>
<problem>
<file>test.kt</file>
<line>10</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis</problem_class>
<description>Equality check can be used instead of elvis</description>
</problem>
<problem>
<file>test.kt</file>
<line>13</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis</problem_class>
<description>Equality check can be used instead of elvis</description>
</problem>
<problem>
<file>test.kt</file>
<line>14</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis</problem_class>
<description>Equality check can be used instead of elvis</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.NullableBooleanElvisInspection
+15
View File
@@ -0,0 +1,15 @@
fun foo() {
var a: Boolean? = null
var b: Boolean? = null
if (a ?: false) {
}
if (!(a ?: false)) {
}
if (a ?: false || !(b ?: true)) {
}
val x = a ?: false
val y = !(b ?: true)
}