Improve inspection message for NullableBooleanElvisInspection
Also report as "should" or "can" depending on severity So #KT-19006 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
c41c5f1916
commit
3ff5c95419
@@ -2305,7 +2305,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.NullableBooleanElvisInspection"
|
<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"
|
groupPath="Kotlin"
|
||||||
groupName="Style issues"
|
groupName="Style issues"
|
||||||
enabledByDefault="true"
|
enabledByDefault="true"
|
||||||
|
|||||||
@@ -50,11 +50,13 @@ class NullableBooleanElvisInspection : AbstractKotlinInspection(), CleanupLocalI
|
|||||||
is KtWhileExpressionBase -> parentIfOrWhile.condition
|
is KtWhileExpressionBase -> parentIfOrWhile.condition
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
val highlightType =
|
val (highlightType, verb) = if (condition != null && condition in expression.parentsWithSelf)
|
||||||
if (condition != null && condition in expression.parentsWithSelf) GENERIC_ERROR_OR_WARNING else INFORMATION
|
GENERIC_ERROR_OR_WARNING to "should"
|
||||||
|
else
|
||||||
|
INFORMATION to "can"
|
||||||
|
|
||||||
holder.registerProblem(expression,
|
holder.registerProblem(expression,
|
||||||
"Equality check can be used instead of elvis",
|
"Equality check $verb be used instead of elvis for nullable boolean check",
|
||||||
highlightType,
|
highlightType,
|
||||||
ReplaceWithEqualityCheckFix())
|
ReplaceWithEqualityCheckFix())
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -4,48 +4,48 @@
|
|||||||
<line>4</line>
|
<line>4</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="test.kt"/>
|
<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>
|
<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</description>
|
<description>Equality check should be used instead of elvis for nullable boolean check</description>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
<problem>
|
||||||
<file>test.kt</file>
|
<file>test.kt</file>
|
||||||
<line>7</line>
|
<line>7</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="test.kt"/>
|
<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>
|
<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</description>
|
<description>Equality check should be used instead of elvis for nullable boolean check</description>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
<problem>
|
||||||
<file>test.kt</file>
|
<file>test.kt</file>
|
||||||
<line>10</line>
|
<line>10</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="test.kt"/>
|
<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>
|
<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</description>
|
<description>Equality check should be used instead of elvis for nullable boolean check</description>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
<problem>
|
||||||
<file>test.kt</file>
|
<file>test.kt</file>
|
||||||
<line>10</line>
|
<line>10</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="test.kt"/>
|
<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>
|
<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</description>
|
<description>Equality check should be used instead of elvis for nullable boolean check</description>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
<problem>
|
||||||
<file>test.kt</file>
|
<file>test.kt</file>
|
||||||
<line>13</line>
|
<line>13</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="test.kt"/>
|
<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>
|
<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</description>
|
<description>Equality check can be used instead of elvis for nullable boolean check</description>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
<problem>
|
||||||
<file>test.kt</file>
|
<file>test.kt</file>
|
||||||
<line>14</line>
|
<line>14</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="test.kt"/>
|
<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>
|
<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</description>
|
<description>Equality check can be used instead of elvis for nullable boolean check</description>
|
||||||
</problem>
|
</problem>
|
||||||
|
|
||||||
</problems>
|
</problems>
|
||||||
Reference in New Issue
Block a user