Improve inspection message for NullableBooleanElvisInspection

Also report as "should" or "can" depending on severity
So #KT-19006 Fixed
This commit is contained in:
Kirill Rakhman
2017-07-21 16:17:43 +03:00
committed by Mikhail Glukhikh
parent c41c5f1916
commit 3ff5c95419
3 changed files with 18 additions and 16 deletions
+1 -1
View File
@@ -2305,7 +2305,7 @@
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.NullableBooleanElvisInspection"
displayName="Equality check can be used instead of elvis"
displayName="Equality check can be used instead of elvis for nullable boolean check"
groupPath="Kotlin"
groupName="Style issues"
enabledByDefault="true"
@@ -50,11 +50,13 @@ class NullableBooleanElvisInspection : AbstractKotlinInspection(), CleanupLocalI
is KtWhileExpressionBase -> parentIfOrWhile.condition
else -> null
}
val highlightType =
if (condition != null && condition in expression.parentsWithSelf) GENERIC_ERROR_OR_WARNING else INFORMATION
val (highlightType, verb) = if (condition != null && condition in expression.parentsWithSelf)
GENERIC_ERROR_OR_WARNING to "should"
else
INFORMATION to "can"
holder.registerProblem(expression,
"Equality check can be used instead of elvis",
"Equality check $verb be used instead of elvis for nullable boolean check",
highlightType,
ReplaceWithEqualityCheckFix())
}
@@ -4,48 +4,48 @@
<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_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis for nullable boolean check</problem_class>
<description>Equality check should be used instead of elvis for nullable boolean check</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_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis for nullable boolean check</problem_class>
<description>Equality check should be used instead of elvis for nullable boolean check</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_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis for nullable boolean check</problem_class>
<description>Equality check should be used instead of elvis for nullable boolean check</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_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis for nullable boolean check</problem_class>
<description>Equality check should be used instead of elvis for nullable boolean check</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_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis for nullable boolean check</problem_class>
<description>Equality check can be used instead of elvis for nullable boolean check</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_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Equality check can be used instead of elvis for nullable boolean check</problem_class>
<description>Equality check can be used instead of elvis for nullable boolean check</description>
</problem>
</problems>