diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/CascadeIfInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/CascadeIfInspection.kt index 0a9c0ac3367..b4de4510ef9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/CascadeIfInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/CascadeIfInspection.kt @@ -66,7 +66,7 @@ class CascadeIfInspection : AbstractKotlinInspection() { holder.registerProblem( expression.ifKeyword, - "Cascade if can be replaced with when", + "Cascade if should be replaced with when", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, IntentionWrapper(IfToWhenIntention(), expression.containingKtFile) ) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/JavaCollectionsStaticMethodCallInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/JavaCollectionsStaticMethodCallInspection.kt index 792b7d5f247..ee8d65ac711 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/JavaCollectionsStaticMethodCallInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/JavaCollectionsStaticMethodCallInspection.kt @@ -56,7 +56,7 @@ class JavaCollectionsStaticMethodInspection : AbstractKotlinInspection() { val methodName = fqName.split(".").last() holder.registerProblem(expression, - "Java Collections static method call can be replaced with Kotlin stdlib", + "Java Collections static method call should be replaced with Kotlin stdlib", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, ReplaceWithStdLibFix(methodName, firstArg.text)) } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/LiftReturnOrAssignmentInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/LiftReturnOrAssignmentInspection.kt index 0366355b1d7..1205fb634ea 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/LiftReturnOrAssignmentInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/LiftReturnOrAssignmentInspection.kt @@ -37,11 +37,13 @@ class LiftReturnOrAssignmentInspection : AbstractKotlinInspection() { val foldableReturns = BranchedFoldingUtils.getFoldableReturns(expression) if (foldableReturns?.isNotEmpty() == true) { val hasOtherReturns = expression.anyDescendantOfType { it !in foldableReturns } + val isSerious = !hasOtherReturns && foldableReturns.size > 1 + val verb = if (isSerious) "should" else "can" holder.registerProblemWithoutOfflineInformation( keyword, - "Return can be lifted out of '${keyword.text}'", + "Return $verb be lifted out of '${keyword.text}'", isOnTheFly, - if (!hasOtherReturns && foldableReturns.size > 1) ProblemHighlightType.GENERIC_ERROR_OR_WARNING + if (isSerious) ProblemHighlightType.GENERIC_ERROR_OR_WARNING else ProblemHighlightType.INFORMATION, LiftReturnOutFix(keyword.text) ) @@ -49,9 +51,10 @@ class LiftReturnOrAssignmentInspection : AbstractKotlinInspection() { } val assignmentNumber = BranchedFoldingUtils.getFoldableAssignmentNumber(expression) if (assignmentNumber > 0) { + val verb = if (assignmentNumber > 1) "should" else "can" holder.registerProblemWithoutOfflineInformation( keyword, - "Assignment can be lifted out of '${keyword.text}'", + "Assignment $verb be lifted out of '${keyword.text}'", isOnTheFly, if (assignmentNumber > 1) ProblemHighlightType.GENERIC_ERROR_OR_WARNING else ProblemHighlightType.INFORMATION, diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceArrayOfWithLiteralInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceArrayOfWithLiteralInspection.kt index 3e596134480..0d0c55564ee 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceArrayOfWithLiteralInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceArrayOfWithLiteralInspection.kt @@ -59,7 +59,7 @@ class ReplaceArrayOfWithLiteralInspection : AbstractKotlinInspection() { val calleeName = calleeExpression.getReferencedName() holder.registerProblem( calleeExpression, - "'$calleeName' call can be replaced with array literal [...]", + "'$calleeName' call should be replaced with array literal [...]", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, ReplaceWithArrayLiteralFix() ) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplacePutWithAssignmentInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplacePutWithAssignmentInspection.kt index d0937b772d7..5481b218eb6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplacePutWithAssignmentInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplacePutWithAssignmentInspection.kt @@ -60,7 +60,7 @@ class ReplacePutWithAssignmentInspection : AbstractApplicabilityBasedInspection< override fun inspectionTarget(element: KtDotQualifiedExpression) = element.callExpression?.calleeExpression ?: element - override fun inspectionText(element: KtDotQualifiedExpression): String = "map.put() can be converted to assignment" + override fun inspectionText(element: KtDotQualifiedExpression): String = "map.put() should be converted to assignment" override val defaultFixText = "Convert put to assignment" diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceRangeToWithUntilInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceRangeToWithUntilInspection.kt index 33a97814150..a91c86d4ac6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceRangeToWithUntilInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceRangeToWithUntilInspection.kt @@ -35,7 +35,7 @@ class ReplaceRangeToWithUntilInspection : AbstractPrimitiveRangeToInspection() { holder.registerProblem( expression, - "'rangeTo' or the '..' call can be replaced with 'until'", + "'rangeTo' or the '..' call should be replaced with 'until'", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, ReplaceWithUntilQuickFix() ) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/SimplifyAssertNotNullInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/SimplifyAssertNotNullInspection.kt index fef071551bd..b81f3e6ef2d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/SimplifyAssertNotNullInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/SimplifyAssertNotNullInspection.kt @@ -65,7 +65,7 @@ class SimplifyAssertNotNullInspection : AbstractApplicabilityBasedInspection - "Variable used only in following return and can be inlined" + "Variable used only in following return and should be inlined" Status.EXACT_COPY -> - "Variable is an exact copy of another variable and can be inlined" + "Variable is same as '${(element.initializer as? KtNameReferenceExpression)?.getReferencedName()}' and should be inlined" else -> "" } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/WhenWithOnlyElseInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/WhenWithOnlyElseInspection.kt index ed0f4b4218a..c5c5997337a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/WhenWithOnlyElseInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/WhenWithOnlyElseInspection.kt @@ -37,7 +37,7 @@ class WhenWithOnlyElseInspection : AbstractKotlinInspection() { val usedAsExpression = expression.isUsedAsExpression(expression.analyze()) holder.registerProblem(expression, - "'when' has only 'else' branch and can be simplified", + "'when' has only 'else' branch and should be simplified", SimplifyFix(usedAsExpression) ) } diff --git a/idea/testData/inspections/replaceRangeToWithUntil/inspectionData/expected.xml b/idea/testData/inspections/replaceRangeToWithUntil/inspectionData/expected.xml index 68c2ba1ecb5..389bd0bb1e2 100644 --- a/idea/testData/inspections/replaceRangeToWithUntil/inspectionData/expected.xml +++ b/idea/testData/inspections/replaceRangeToWithUntil/inspectionData/expected.xml @@ -5,7 +5,7 @@ light_idea_test_case 'rangeTo' or the '..' call can be replaced with 'until' - 'rangeTo' or the '..' call can be replaced with 'until' + 'rangeTo' or the '..' call should be replaced with 'until' test.kt @@ -13,6 +13,6 @@ light_idea_test_case 'rangeTo' or the '..' call can be replaced with 'until' - 'rangeTo' or the '..' call can be replaced with 'until' + 'rangeTo' or the '..' call should be replaced with 'until' \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/expected.xml b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/expected.xml index e0c1be3d269..3fd0b8e0540 100644 --- a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/expected.xml +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/expected.xml @@ -7,7 +7,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -17,7 +17,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -27,7 +27,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -37,7 +37,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -47,7 +47,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -57,7 +57,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -67,7 +67,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -77,7 +77,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -87,7 +87,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified @@ -97,7 +97,7 @@ Negated boolean expression that can be simplified - Negated expression can be simplified + Negated expression should be simplified \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt index 170f1c365bd..65e8cc6370d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.inspections import com.google.common.collect.Lists import com.intellij.codeInspection.ProblemDescriptor +import com.intellij.codeInspection.ProblemHighlightType import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.vfs.VirtualFile @@ -137,6 +138,12 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa "Expected at least one problem at caret", problemExpected == problemDescriptors.isNotEmpty()) if (!problemExpected) return false + problemDescriptors + .filter { it.highlightType != ProblemHighlightType.INFORMATION } + .forEach { + Assert.assertTrue("Problem description should not contain 'can': ${it.descriptionTemplate}", + " can " !in it.descriptionTemplate) + } if (problemExpectedString != null) { Assert.assertTrue("Expected the following problem at caret: $problemExpectedString\n" + "Active problems: ${problemDescriptors.joinToString { it.descriptionTemplate }}",