Polish KT-22011 inspection: message, level, group, range, etc.
This commit is contained in:
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<body>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2624,11 +2624,11 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.JavaCollectionsStaticMethodOnImmutableListInspection"
|
<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"
|
groupPath="Kotlin"
|
||||||
groupName="Probable bugs"
|
groupName="Java interop issues"
|
||||||
enabledByDefault="true"
|
enabledByDefault="true"
|
||||||
level="WEAK WARNING"
|
level="WARNING"
|
||||||
language="kotlin"
|
language="kotlin"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
|
|||||||
|
|
||||||
import com.intellij.codeInspection.ProblemsHolder
|
import com.intellij.codeInspection.ProblemsHolder
|
||||||
import com.intellij.psi.PsiElementVisitor
|
import com.intellij.psi.PsiElementVisitor
|
||||||
|
import org.jetbrains.kotlin.idea.intentions.callExpression
|
||||||
import org.jetbrains.kotlin.psi.dotQualifiedExpressionVisitor
|
import org.jetbrains.kotlin.psi.dotQualifiedExpressionVisitor
|
||||||
|
|
||||||
class JavaCollectionsStaticMethodOnImmutableListInspection : AbstractKotlinInspection() {
|
class JavaCollectionsStaticMethodOnImmutableListInspection : AbstractKotlinInspection() {
|
||||||
@@ -14,8 +15,8 @@ class JavaCollectionsStaticMethodOnImmutableListInspection : AbstractKotlinInspe
|
|||||||
return dotQualifiedExpressionVisitor(fun(expression) {
|
return dotQualifiedExpressionVisitor(fun(expression) {
|
||||||
val (methodName, firstArg) = JavaCollectionsStaticMethodInspection.getTargetMethodOnImmutableList(expression) ?: return
|
val (methodName, firstArg) = JavaCollectionsStaticMethodInspection.getTargetMethodOnImmutableList(expression) ?: return
|
||||||
holder.registerProblem(
|
holder.registerProblem(
|
||||||
expression,
|
expression.callExpression?.calleeExpression ?: expression,
|
||||||
"The '${firstArg.text}' may be changed with Java Collections method '$methodName'"
|
"Call of Java mutator '$methodName' on immutable Kotlin collection '${firstArg.text}'"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -4,7 +4,7 @@
|
|||||||
<line>5</line>
|
<line>5</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">Immutable Kotlin collection may be changed with Java Collections method</problem_class>
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Call of Java mutator method on immutable Kotlin collection</problem_class>
|
||||||
<description>The 'immutableList' may be changed with Java Collections method 'reverse'</description>
|
<description>Call of Java mutator 'reverse' on immutable Kotlin collection 'immutableList'</description>
|
||||||
</problem>
|
</problem>
|
||||||
</problems>
|
</problems>
|
||||||
|
|||||||
Reference in New Issue
Block a user