Polish KT-22011 inspection: message, level, group, range, etc.

This commit is contained in:
Mikhail Glukhikh
2018-02-28 12:10:24 +03:00
parent 7d6cb7805c
commit 664a25ce81
4 changed files with 10 additions and 8 deletions
@@ -1,5 +1,6 @@
<html>
<body>
This inspection reports immutable Kotlin collection may be changed with Java Collections method.
This inspection report calls of Java mutator methods (like fill, reverse, shuffle, sort) on immutable Kotlin collection.
This will likely produce UnsupportedOperationException at runtime.
</body>
</html>
+3 -3
View File
@@ -2624,11 +2624,11 @@
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.JavaCollectionsStaticMethodOnImmutableListInspection"
displayName="Immutable Kotlin collection may be changed with Java Collections method"
displayName="Call of Java mutator method on immutable Kotlin collection"
groupPath="Kotlin"
groupName="Probable bugs"
groupName="Java interop issues"
enabledByDefault="true"
level="WEAK WARNING"
level="WARNING"
language="kotlin"
/>
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.intentions.callExpression
import org.jetbrains.kotlin.psi.dotQualifiedExpressionVisitor
class JavaCollectionsStaticMethodOnImmutableListInspection : AbstractKotlinInspection() {
@@ -14,8 +15,8 @@ class JavaCollectionsStaticMethodOnImmutableListInspection : AbstractKotlinInspe
return dotQualifiedExpressionVisitor(fun(expression) {
val (methodName, firstArg) = JavaCollectionsStaticMethodInspection.getTargetMethodOnImmutableList(expression) ?: return
holder.registerProblem(
expression,
"The '${firstArg.text}' may be changed with Java Collections method '$methodName'"
expression.callExpression?.calleeExpression ?: expression,
"Call of Java mutator '$methodName' on immutable Kotlin collection '${firstArg.text}'"
)
})
}
@@ -4,7 +4,7 @@
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Immutable Kotlin collection may be changed with Java Collections method</problem_class>
<description>The 'immutableList' may be changed with Java Collections method 'reverse'</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Call of Java mutator method on immutable Kotlin collection</problem_class>
<description>Call of Java mutator 'reverse' on immutable Kotlin collection 'immutableList'</description>
</problem>
</problems>