diff --git a/idea/resources/META-INF/plugin-common.xml b/idea/resources/META-INF/plugin-common.xml index da36b94ce5a..a3079454a76 100644 --- a/idea/resources/META-INF/plugin-common.xml +++ b/idea/resources/META-INF/plugin-common.xml @@ -2233,12 +2233,21 @@ language="kotlin" /> - + + diff --git a/idea/resources/inspectionDescriptions/ComplexRedundantLet.html b/idea/resources/inspectionDescriptions/ComplexRedundantLet.html new file mode 100644 index 00000000000..ff2da5d99c0 --- /dev/null +++ b/idea/resources/inspectionDescriptions/ComplexRedundantLet.html @@ -0,0 +1,5 @@ + + +This inspection detects a redundant let when it includes only one call with lambda parameter. + + diff --git a/idea/resources/inspectionDescriptions/ReplaceSingleLineLet.html b/idea/resources/inspectionDescriptions/SimpleRedundantLet.html similarity index 100% rename from idea/resources/inspectionDescriptions/ReplaceSingleLineLet.html rename to idea/resources/inspectionDescriptions/SimpleRedundantLet.html diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceSingleLineLetInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantLetInspection.kt similarity index 79% rename from idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceSingleLineLetInspection.kt rename to idea/src/org/jetbrains/kotlin/idea/inspections/RedundantLetInspection.kt index fc76b2c41dd..05e6bf52188 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceSingleLineLetInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantLetInspection.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections import com.intellij.codeInspection.ProblemHighlightType import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall @@ -26,44 +27,36 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -class ReplaceSingleLineLetInspection : AbstractApplicabilityBasedInspection( +abstract class RedundantLetInspection : AbstractApplicabilityBasedInspection( KtCallExpression::class.java ) { - override fun inspectionText(element: KtCallExpression) = "Replace single line .let" + override fun inspectionText(element: KtCallExpression) = "Redundant `let` call could be removed" - override fun inspectionHighlightRangeInElement(element: KtCallExpression) = element.calleeExpression?.textRangeIn(element) + final override fun inspectionHighlightRangeInElement(element: KtCallExpression) = element.calleeExpression?.textRangeIn(element) - override fun inspectionHighlightType(element: KtCallExpression): ProblemHighlightType = if (isSingleLine(element)) - ProblemHighlightType.GENERIC_ERROR_OR_WARNING - else - ProblemHighlightType.INFORMATION + final override val defaultFixText = "Remove `let` call" - override val defaultFixText = "Remove redundant '.let' call" - - override fun isApplicable(element: KtCallExpression): Boolean { + final override fun isApplicable(element: KtCallExpression): Boolean { if (!element.isLetMethodCall()) return false val lambdaExpression = element.lambdaArguments.firstOrNull()?.getLambdaExpression() ?: return false val parameterName = lambdaExpression.getParameterName() ?: return false - return when (val bodyExpression = lambdaExpression.bodyExpression?.children?.singleOrNull() ?: return false) { - is KtBinaryExpression -> - element.parent !is KtSafeQualifiedExpression && bodyExpression.isApplicable(parameterName) - is KtDotQualifiedExpression -> - bodyExpression.isApplicable(parameterName) - is KtCallExpression -> - if (element.parent is KtSafeQualifiedExpression) { - false - } else { - val count = lambdaExpression.functionLiteral.valueParameterReferences(bodyExpression).count() - val destructuringDeclaration = lambdaExpression.functionLiteral.valueParameters.firstOrNull()?.destructuringDeclaration - count == 0 || (count == 1 && destructuringDeclaration == null) - } - else -> - false - } + return myIsApplicable( + element, + lambdaExpression.bodyExpression?.children?.singleOrNull() ?: return false, + lambdaExpression, + parameterName + ) } - override fun applyTo(element: KtCallExpression, project: Project, editor: Editor?) { + protected abstract fun myIsApplicable( + element: KtCallExpression, + bodyExpression: PsiElement, + lambdaExpression: KtLambdaExpression, + parameterName: String + ): Boolean + + final override fun applyTo(element: KtCallExpression, project: Project, editor: Editor?) { val lambdaExpression = element.lambdaArguments.firstOrNull()?.getLambdaExpression() ?: return when (val bodyExpression = lambdaExpression.bodyExpression?.children?.singleOrNull() ?: return) { is KtDotQualifiedExpression -> bodyExpression.applyTo(element) @@ -73,6 +66,42 @@ class ReplaceSingleLineLetInspection : AbstractApplicabilityBasedInspection + element.parent !is KtSafeQualifiedExpression && bodyExpression.isApplicable(parameterName) + is KtCallExpression -> + if (element.parent is KtSafeQualifiedExpression) { + false + } else { + val count = lambdaExpression.functionLiteral.valueParameterReferences(bodyExpression).count() + val destructuringDeclaration = lambdaExpression.functionLiteral.valueParameters.firstOrNull()?.destructuringDeclaration + count == 0 || (count == 1 && destructuringDeclaration == null) + } + else -> + false + } + + override fun inspectionHighlightType(element: KtCallExpression): ProblemHighlightType = if (isSingleLine(element)) + ProblemHighlightType.GENERIC_ERROR_OR_WARNING + else + ProblemHighlightType.INFORMATION +} + private fun KtBinaryExpression.applyTo(element: KtCallExpression) { val left = left ?: return val factory = KtPsiFactory(element.project) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt index 5bbcc358faf..85d0b8248c8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.core.replaced -import org.jetbrains.kotlin.idea.inspections.ReplaceSingleLineLetInspection +import org.jetbrains.kotlin.idea.inspections.ComplexRedundantLetInspection import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.convertToIfNotNullExpression import org.jetbrains.kotlin.idea.intentions.branchedTransformations.introduceValueForCondition @@ -87,9 +87,9 @@ class SafeAccessToIfThenIntention : SelfTargetingRangeIntention Int) + +fun bar(foo: Foo?) { + foo?.let { it.bar.invoke() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt b/idea/testData/inspectionsLocal/complexRedundantLet/in.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/in.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/in.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/in.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithMultipleParam.kt b/idea/testData/inspectionsLocal/complexRedundantLet/inWithMultipleParam.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/inWithMultipleParam.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/inWithMultipleParam.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt b/idea/testData/inspectionsLocal/complexRedundantLet/inWithRange.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/inWithRange.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/inWithRange.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/inWithRange.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRangeMultipleParam.kt b/idea/testData/inspectionsLocal/complexRedundantLet/inWithRangeMultipleParam.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRangeMultipleParam.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/inWithRangeMultipleParam.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt b/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/invokeCall.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/invokeCall.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt b/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall2.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/invokeCall2.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall2.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/invokeCall2.kt.after diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall3.kt b/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall3.kt new file mode 100644 index 00000000000..1875370c1e0 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall3.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME +class A { + operator fun invoke() {} +} + +fun foo(a: A) { + a.let { b -> b.invoke() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall4.kt b/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall4.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall4.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/invokeCall4.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall5.kt b/idea/testData/inspectionsLocal/complexRedundantLet/invokeCall5.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall5.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/invokeCall5.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression.kt b/idea/testData/inspectionsLocal/complexRedundantLet/lambdaWithBinaryExpression.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/lambdaWithBinaryExpression.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression2.kt b/idea/testData/inspectionsLocal/complexRedundantLet/lambdaWithBinaryExpression2.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression2.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/lambdaWithBinaryExpression2.kt diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/let.kt b/idea/testData/inspectionsLocal/complexRedundantLet/let.kt new file mode 100644 index 00000000000..0343b1f7546 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/let.kt @@ -0,0 +1,10 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo() { + val foo: String? = null + foo?.let { + it.length + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letMultipleLines.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letMultipleLines.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letMultipleLines.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letMultipleLines.kt diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/letNoSafeCall.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letNoSafeCall.kt new file mode 100644 index 00000000000..4ecbae17342 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/letNoSafeCall.kt @@ -0,0 +1,10 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo() { + val foo: String = "" + foo.let { + it.length + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseParameterReceiver.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letNotUseParameterReceiver.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseParameterReceiver.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letNotUseParameterReceiver.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseReceiver.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letNotUseReceiver.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseReceiver.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letNotUseReceiver.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseIt.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letUseIt.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letUseIt.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letUseIt.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItAsParamWithBinaryExpression.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letUseItAsParamWithBinaryExpression.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItAsParamWithBinaryExpression.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letUseItAsParamWithBinaryExpression.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithBinaryExpression.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithBinaryExpression.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression2.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithBinaryExpression2.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression2.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithBinaryExpression2.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall1.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall1.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall1.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall1.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall2.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall2.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall2.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall2.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall3.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall3.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall3.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall3.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseParameter.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letUseParameter.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letUseParameter.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letUseParameter.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letWithBinaryExpression.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letWithBinaryExpression.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/letWithBinaryExpression.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/letWithBinaryExpression.kt.after diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/letWithMethodCall.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letWithMethodCall.kt new file mode 100644 index 00000000000..868e8456859 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/letWithMethodCall.kt @@ -0,0 +1,10 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo() { + val foo: String? = null + foo?.let { + it.to("") + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/letWithMultipleMethodCall.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letWithMultipleMethodCall.kt new file mode 100644 index 00000000000..be64b1ed2e9 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/letWithMultipleMethodCall.kt @@ -0,0 +1,10 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo() { + val foo: String? = null + foo?.let { + it.hashCode().hashCode() + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/letWithParameter.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letWithParameter.kt new file mode 100644 index 00000000000..e57dd1a940d --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/letWithParameter.kt @@ -0,0 +1,11 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo() { + val foo: String? = null + foo?.let { + text -> + text.length + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letWithSimpleBinaryExpression.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letWithSimpleBinaryExpression.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/letWithSimpleBinaryExpression.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/letWithSimpleBinaryExpression.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letWithThisBinaryExpression.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letWithThisBinaryExpression.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/letWithThisBinaryExpression.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/letWithThisBinaryExpression.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt b/idea/testData/inspectionsLocal/complexRedundantLet/letWithThisShortBinaryExpression.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/letWithThisShortBinaryExpression.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/letWithThisShortBinaryExpression.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/letWithThisShortBinaryExpression.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt b/idea/testData/inspectionsLocal/complexRedundantLet/longCallChain.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/longCallChain.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt.after b/idea/testData/inspectionsLocal/complexRedundantLet/longCallChain.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt.after rename to idea/testData/inspectionsLocal/complexRedundantLet/longCallChain.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver.kt b/idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver2.kt b/idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver2.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver2.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver2.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver3.kt b/idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver3.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver3.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver3.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleUsages.kt b/idea/testData/inspectionsLocal/complexRedundantLet/multipleUsages.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/multipleUsages.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/multipleUsages.kt diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/noReceiver.kt b/idea/testData/inspectionsLocal/complexRedundantLet/noReceiver.kt new file mode 100644 index 00000000000..45846bb7355 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/noReceiver.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun String.test(): Int { + return let { + it.length + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/plusNullable.kt b/idea/testData/inspectionsLocal/complexRedundantLet/plusNullable.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/plusNullable.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/plusNullable.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda.kt b/idea/testData/inspectionsLocal/complexRedundantLet/receiverWithLambda.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/receiverWithLambda.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda2.kt b/idea/testData/inspectionsLocal/complexRedundantLet/receiverWithLambda2.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda2.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/receiverWithLambda2.kt diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/sameLets.kt b/idea/testData/inspectionsLocal/complexRedundantLet/sameLets.kt new file mode 100644 index 00000000000..a5760ea5049 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/sameLets.kt @@ -0,0 +1,12 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo() { + val foo: String? = null + foo?.toString()?.let { + it.to("") + }?.let { + it.to("") + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/simple.kt b/idea/testData/inspectionsLocal/complexRedundantLet/simple.kt new file mode 100644 index 00000000000..92b7ee1b8bf --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/simple.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun test(s: String?): Int? { + return s?.let { + it.length + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/smartCastInBody.kt b/idea/testData/inspectionsLocal/complexRedundantLet/smartCastInBody.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/smartCastInBody.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/smartCastInBody.kt diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/this.kt b/idea/testData/inspectionsLocal/complexRedundantLet/this.kt new file mode 100644 index 00000000000..3369224a719 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/this.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun Int.foo(): Int { + return let { it.hashCode().hashCode() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/complexRedundantLet/thisShort.kt b/idea/testData/inspectionsLocal/complexRedundantLet/thisShort.kt new file mode 100644 index 00000000000..5ef09818ca4 --- /dev/null +++ b/idea/testData/inspectionsLocal/complexRedundantLet/thisShort.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun Int.foo(): Int { + return let { it.hashCode() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/typeChecks.kt b/idea/testData/inspectionsLocal/complexRedundantLet/typeChecks.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/typeChecks.kt rename to idea/testData/inspectionsLocal/complexRedundantLet/typeChecks.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/.inspection b/idea/testData/inspectionsLocal/replaceSingleLineLet/.inspection deleted file mode 100644 index 619d64ccc72..00000000000 --- a/idea/testData/inspectionsLocal/replaceSingleLineLet/.inspection +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.inspections.ReplaceSingleLineLetInspection \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/.inspection b/idea/testData/inspectionsLocal/simpleRedundantLet/.inspection new file mode 100644 index 00000000000..baa1f3cb246 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/.inspection @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.inspections.SimpleRedundantLetInspection \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/assignment.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/assignment.kt new file mode 100644 index 00000000000..47027fb4c59 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/assignment.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun withAssign(arg: String?): String { + var result: String = "" + arg?.let { result = it } + return result +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/binarySafeCall.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/binarySafeCall.kt new file mode 100644 index 00000000000..fde54d62b62 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/binarySafeCall.kt @@ -0,0 +1,5 @@ +// PROBLEM: none +// WITH_RUNTIME + +val x = 1 +val y = x.let { it + it?.hashCode() } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/callChain.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/callChain.kt new file mode 100644 index 00000000000..d48e9243ece --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/callChain.kt @@ -0,0 +1,6 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.filter { it > 2 }.let { println(it) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/callChain2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/callChain2.kt new file mode 100644 index 00000000000..08fc467df33 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/callChain2.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.filter { it > 2 } + .let { println(it) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/callChain3.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/callChain3.kt new file mode 100644 index 00000000000..ab8782e6385 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/callChain3.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.filter { it > 2 }.let { + println(it) + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/callChainWithLineBreak.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/callChainWithLineBreak.kt new file mode 100644 index 00000000000..7b22a3c92af --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/callChainWithLineBreak.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME +// HIGHLIGHT: INFORMATION + +fun test(list: List) { + list.filter { it > 1 } + .filter { it > 2 } + .let { println(it) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/comparisons.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/comparisons.kt new file mode 100644 index 00000000000..965d929d6bd --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/comparisons.kt @@ -0,0 +1,4 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun isAlphaOrBeta(str: String) = str.let { it == "Alpha" || it == "Beta" } diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration.kt new file mode 100644 index 00000000000..4d69ba3176d --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun test() { + (1 to 2).let { (i, j) -> foo() } +} + +fun foo() = 0 \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration2.kt new file mode 100644 index 00000000000..85f1a6102c9 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration2.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun test() { + (1 to 2).let { (i, j) -> foo(1, 2) } +} + +fun foo(i: Int, j: Int) = i + j \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration3.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration3.kt new file mode 100644 index 00000000000..da297683870 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration3.kt @@ -0,0 +1,8 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun test() { + (1 to 2).let { (i, j) -> foo(i, 3) } +} + +fun foo(i: Int, j: Int) = i + j \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration4.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration4.kt new file mode 100644 index 00000000000..41a00afaab8 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration4.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun test(k: Int) { + (1 to 2).let { (i, j) -> i + k } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration5.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration5.kt new file mode 100644 index 00000000000..bb26cfe0ca9 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration5.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun test() { + (1 to 2).let { (i, j) -> i.toLong() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/dotWithComparison.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/dotWithComparison.kt new file mode 100644 index 00000000000..24c6ed0c802 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/dotWithComparison.kt @@ -0,0 +1,6 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun main(args: Array) { + args[0].let { it.isBlank() && it.toByteOrNull() != null } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall1.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall1.kt new file mode 100644 index 00000000000..e3fb769bc5a --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall1.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun foo(s: String, i: Int) = s.length + i + +fun test() { + val s = "" + s.let { foo("", 1) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall2.kt new file mode 100644 index 00000000000..c806d1a0e10 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall2.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun foo(s: String, i: Int) = s.length + i + +fun test() { + val s = "" + s.let { foo(it, 1) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall3.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall3.kt new file mode 100644 index 00000000000..2928696b1d3 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall3.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun foo(s: String, i: Int) = s.length + i + +fun test() { + val s = "" + s.let { foo("", it.length) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall4.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall4.kt new file mode 100644 index 00000000000..474afb48eef --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall4.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun foo(s: String, i: Int) = s.length + i + +fun test() { + val s = "" + s.let { x -> foo("", x.length) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall5.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall5.kt new file mode 100644 index 00000000000..f86bbcbfc1e --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall5.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun foo(s: String, i: Int) = s.length + i + +fun test() { + val s = "" + s.length.let { foo("", it) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall6.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall6.kt new file mode 100644 index 00000000000..26564f102c7 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall6.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun foo(s: String, i: Int) = s.length + i + +fun test() { + fun bar() = "" + bar().let { foo(it, 1) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall7.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall7.kt new file mode 100644 index 00000000000..e289957ee5f --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCall7.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo(s: String, i: Int) = s.length + i + +fun test() { + val s = "" + s.let { foo(it, it.length) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCallInExtension.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCallInExtension.kt new file mode 100644 index 00000000000..a7e831eb77a --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCallInExtension.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun foo(s: String, i: Int) = s.length + i + +fun String.baz(): Int { + return let { foo(it, 1) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionCallOnSafeCall.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCallOnSafeCall.kt new file mode 100644 index 00000000000..467aa7baf44 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionCallOnSafeCall.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo(s: String, i: Int) = s.length + i + +fun test() { + val nullable: String? = null + nullable?.let { foo(it, 1) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableCall.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableCall.kt new file mode 100644 index 00000000000..1340729dbca --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableCall.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME +class Foo(val bar: () -> Int) + +fun bar(foo: Foo?) { + foo?.let { it.bar() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableInvokeCall.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableInvokeCall.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableInvokeCall.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableInvokeCall.kt.after diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/in.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/in.kt new file mode 100644 index 00000000000..30f2aeb5b89 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/in.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo(list: List) { + list.filter { it.let { it in 1000..3000 } } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/inWithMultipleParam.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/inWithMultipleParam.kt new file mode 100644 index 00000000000..9e257d0885f --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/inWithMultipleParam.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo(list: List) { + list.filter { it.let { value -> value in value..3000 } } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/inWithRange.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/inWithRange.kt new file mode 100644 index 00000000000..849c4041a1c --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/inWithRange.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo(list: List) { + list.filter { it.let { it in IntRange(1, 10) } } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/inWithRangeMultipleParam.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/inWithRangeMultipleParam.kt new file mode 100644 index 00000000000..6b7ed9d85c3 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/inWithRangeMultipleParam.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo(list: List) { + list.filter { it.let { it in IntRange(it - 1, 10) } } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall.kt new file mode 100644 index 00000000000..db9ce710c1a --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME +class A { + operator fun invoke() {} +} + +fun foo(a: A) { + a.let { it() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall2.kt new file mode 100644 index 00000000000..59a5321acee --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall2.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME +class A { + operator fun invoke() {} +} + +fun foo(a: A) { + a.let { b -> b() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall3.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall3.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall3.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall3.kt.after diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall4.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall4.kt new file mode 100644 index 00000000000..c65abc1d33d --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall4.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME +class A { + operator fun invoke(a: A, i: Int) {} +} + +fun foo(a: A) { + a.let { it(it, 1) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall5.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall5.kt new file mode 100644 index 00000000000..c1f848c977f --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall5.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME +class A { + operator fun invoke() {} +} + +fun foo(a: A) { + (1 to a).let { (i, b) -> b() } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/lambdaWithBinaryExpression.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/lambdaWithBinaryExpression.kt new file mode 100644 index 00000000000..c969dbfab90 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/lambdaWithBinaryExpression.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun baz(foo: String) { + foo.let { it.indexOfLast { c -> c == it[0] } + 1 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/lambdaWithBinaryExpression2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/lambdaWithBinaryExpression2.kt new file mode 100644 index 00000000000..884a6f3c82b --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/lambdaWithBinaryExpression2.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun baz(foo: String) { + foo.let { it.length + "".indexOfLast { c -> c == it[0] } } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/let.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/let.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/let.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/let.kt.after diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letMultipleLines.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letMultipleLines.kt new file mode 100644 index 00000000000..5032dc961a9 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letMultipleLines.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + val foo: String? = null + foo?.let { + it.length + it.length + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letNoSafeCall.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/letNoSafeCall.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/letNoSafeCall.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/letNoSafeCall.kt.after diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letNotUseParameterReceiver.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letNotUseParameterReceiver.kt new file mode 100644 index 00000000000..e12a770cc93 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letNotUseParameterReceiver.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + val foo: String? = null + foo?.let { + text -> + "".to("") + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letNotUseReceiver.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letNotUseReceiver.kt new file mode 100644 index 00000000000..f4fcf8a9919 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letNotUseReceiver.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + val foo: String? = null + foo?.let { + "".to("") + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letUseIt.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseIt.kt new file mode 100644 index 00000000000..a2423ec4d4a --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseIt.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + val foo: String? = null + foo?.let { + it.to(it) + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItAsParamWithBinaryExpression.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItAsParamWithBinaryExpression.kt new file mode 100644 index 00000000000..b8bf79bb237 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItAsParamWithBinaryExpression.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + "".let { it.length + "".indexOf(it) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithBinaryExpression.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithBinaryExpression.kt new file mode 100644 index 00000000000..f49ef207cae --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithBinaryExpression.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + "".let { it.length + it.length } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithBinaryExpression2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithBinaryExpression2.kt new file mode 100644 index 00000000000..5fd8404ab80 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithBinaryExpression2.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + "".let { it.substring(0, 1) + it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall1.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall1.kt new file mode 100644 index 00000000000..05fddfe9c0d --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall1.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + val foo: String? = null + foo?.let { + it.to(it).to("").to("") + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall2.kt new file mode 100644 index 00000000000..12064396a0c --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall2.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + val foo: String? = null + foo?.let { + it.to("").to(it).to("") + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall3.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall3.kt new file mode 100644 index 00000000000..bd963a6660e --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall3.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + val foo: String? = null + foo?.let { + it.to("").to("").to(it) + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letUseParameter.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseParameter.kt new file mode 100644 index 00000000000..cb69fc48841 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letUseParameter.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun foo() { + val foo: String? = null + foo?.let { + text -> + text.to(text) + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letWithBinaryExpression.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithBinaryExpression.kt new file mode 100644 index 00000000000..3062a62aaff --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithBinaryExpression.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo() { + "".let { it.length + 1 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithMethodCall.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/letWithMethodCall.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithMethodCall.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/letWithMethodCall.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithMultipleMethodCall.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/letWithMultipleMethodCall.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithMultipleMethodCall.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/letWithMultipleMethodCall.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithParameter.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/letWithParameter.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithParameter.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/letWithParameter.kt.after diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letWithSimpleBinaryExpression.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithSimpleBinaryExpression.kt new file mode 100644 index 00000000000..c22edad08f9 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithSimpleBinaryExpression.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun foo() { + "".let { it + 1 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letWithThisBinaryExpression.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithThisBinaryExpression.kt new file mode 100644 index 00000000000..d62148668fb --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithThisBinaryExpression.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun Int.foo() { + let { it.dec() + 1 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/letWithThisShortBinaryExpression.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithThisShortBinaryExpression.kt new file mode 100644 index 00000000000..0fed4c95b44 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/letWithThisShortBinaryExpression.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME + + +fun Int.foo() { + let { it + 1 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/longCallChain.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/longCallChain.kt new file mode 100644 index 00000000000..e16783bc3f8 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/longCallChain.kt @@ -0,0 +1,7 @@ +// PROBLEM: none +// WITH_RUNTIME +// HIGHLIGHT: INFORMATION + +fun test(list: List) { + list.filter { it > 1 }.filter { it > 2 }.filter { it > 3 }.let { println(it) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver.kt new file mode 100644 index 00000000000..afa1d6a16a6 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun baz(foo: String) { + foo.let { it.substringAfterLast(it.capitalize()) } +} diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver2.kt new file mode 100644 index 00000000000..ce7973f7ff5 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver2.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun baz(foo: String) { + foo.let { it.substringAfterLast("".equals(it).toString()) } +} diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver3.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver3.kt new file mode 100644 index 00000000000..b7370b83e6a --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver3.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun baz(foo: String) { + foo.let { it.substring(0, it.length) } +} diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/multipleUsages.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/multipleUsages.kt new file mode 100644 index 00000000000..a624c9d591f --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/multipleUsages.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun foo(s: String) { + if (s.substring(1).let { it.startsWith("a") || it[1].isLowerCase() }) { + + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/noReceiver.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/noReceiver.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/noReceiver.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/noReceiver.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/noReceiver.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/noReceiver.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/noReceiver.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/noReceiver.kt.after diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/plusNullable.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/plusNullable.kt new file mode 100644 index 00000000000..e194ff9b290 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/plusNullable.kt @@ -0,0 +1,4 @@ +// PROBLEM: none +// WITH_RUNTIME + +fun plusNullable(arg: String?) = arg?.let { it + "#" } ?: "" \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/receiverWithLambda.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/receiverWithLambda.kt new file mode 100644 index 00000000000..750f2aeb2bf --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/receiverWithLambda.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// PROBLEM: none + +fun baz(foo: String) { + foo.let { it.indexOfLast { c -> c == it[0] } } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/receiverWithLambda2.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/receiverWithLambda2.kt new file mode 100644 index 00000000000..d14367fde03 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/receiverWithLambda2.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// PROBLEM: none +// This should be reported. However, in order to avoid too complicate logic, the intention ignore this case. + +import java.util.* + +fun baz2(foo: List) { + foo.let { it.binarySearch("", Comparator { o1, o2 -> 0 }) } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/sameLets.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/sameLets.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/sameLets.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/sameLets.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/simple.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/simple.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/simple.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/simple.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/simple.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/simple.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/simple.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/simple.kt.after diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/smartCastInBody.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/smartCastInBody.kt new file mode 100644 index 00000000000..9262320b54f --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/smartCastInBody.kt @@ -0,0 +1,15 @@ +// PROBLEM: none +// WITH_RUNTIME + +interface A + +interface B : A { + val bar: Any? +} + +class Foo { + private val a: A = object : A {} + + val isB: Boolean + get() = a.let { it is B && it.bar != null } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/this.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/this.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/this.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/this.kt.after diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/thisShort.kt similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt rename to idea/testData/inspectionsLocal/simpleRedundantLet/thisShort.kt diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt.after b/idea/testData/inspectionsLocal/simpleRedundantLet/thisShort.kt.after similarity index 100% rename from idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt.after rename to idea/testData/inspectionsLocal/simpleRedundantLet/thisShort.kt.after diff --git a/idea/testData/inspectionsLocal/simpleRedundantLet/typeChecks.kt b/idea/testData/inspectionsLocal/simpleRedundantLet/typeChecks.kt new file mode 100644 index 00000000000..064f36d2ec3 --- /dev/null +++ b/idea/testData/inspectionsLocal/simpleRedundantLet/typeChecks.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME + +interface Base + +class A : Base +class B : Base + +fun isAB(arg: Base) = arg.let { it is A || it is B } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 2d9d29c87d6..5aafa257b22 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -2021,6 +2021,369 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/complexRedundantLet") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ComplexRedundantLet extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInComplexRedundantLet() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/complexRedundantLet"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("assignment.kt") + public void testAssignment() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/assignment.kt"); + } + + @TestMetadata("binarySafeCall.kt") + public void testBinarySafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/binarySafeCall.kt"); + } + + @TestMetadata("callChain.kt") + public void testCallChain() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/callChain.kt"); + } + + @TestMetadata("callChain2.kt") + public void testCallChain2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/callChain2.kt"); + } + + @TestMetadata("callChain3.kt") + public void testCallChain3() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/callChain3.kt"); + } + + @TestMetadata("callChainWithLineBreak.kt") + public void testCallChainWithLineBreak() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/callChainWithLineBreak.kt"); + } + + @TestMetadata("comparisons.kt") + public void testComparisons() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/comparisons.kt"); + } + + @TestMetadata("destructuringDeclaration.kt") + public void testDestructuringDeclaration() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/destructuringDeclaration.kt"); + } + + @TestMetadata("destructuringDeclaration2.kt") + public void testDestructuringDeclaration2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/destructuringDeclaration2.kt"); + } + + @TestMetadata("destructuringDeclaration3.kt") + public void testDestructuringDeclaration3() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/destructuringDeclaration3.kt"); + } + + @TestMetadata("destructuringDeclaration4.kt") + public void testDestructuringDeclaration4() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/destructuringDeclaration4.kt"); + } + + @TestMetadata("destructuringDeclaration5.kt") + public void testDestructuringDeclaration5() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/destructuringDeclaration5.kt"); + } + + @TestMetadata("dotWithComparison.kt") + public void testDotWithComparison() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/dotWithComparison.kt"); + } + + @TestMetadata("functionCall1.kt") + public void testFunctionCall1() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCall1.kt"); + } + + @TestMetadata("functionCall2.kt") + public void testFunctionCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCall2.kt"); + } + + @TestMetadata("functionCall3.kt") + public void testFunctionCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCall3.kt"); + } + + @TestMetadata("functionCall4.kt") + public void testFunctionCall4() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCall4.kt"); + } + + @TestMetadata("functionCall5.kt") + public void testFunctionCall5() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCall5.kt"); + } + + @TestMetadata("functionCall6.kt") + public void testFunctionCall6() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCall6.kt"); + } + + @TestMetadata("functionCall7.kt") + public void testFunctionCall7() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCall7.kt"); + } + + @TestMetadata("functionCallInExtension.kt") + public void testFunctionCallInExtension() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCallInExtension.kt"); + } + + @TestMetadata("functionCallOnSafeCall.kt") + public void testFunctionCallOnSafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionCallOnSafeCall.kt"); + } + + @TestMetadata("functionInVariableCall.kt") + public void testFunctionInVariableCall() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionInVariableCall.kt"); + } + + @TestMetadata("functionInVariableInvokeCall.kt") + public void testFunctionInVariableInvokeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/functionInVariableInvokeCall.kt"); + } + + @TestMetadata("in.kt") + public void testIn() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/in.kt"); + } + + @TestMetadata("inWithMultipleParam.kt") + public void testInWithMultipleParam() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/inWithMultipleParam.kt"); + } + + @TestMetadata("inWithRange.kt") + public void testInWithRange() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/inWithRange.kt"); + } + + @TestMetadata("inWithRangeMultipleParam.kt") + public void testInWithRangeMultipleParam() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/inWithRangeMultipleParam.kt"); + } + + @TestMetadata("invokeCall.kt") + public void testInvokeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/invokeCall.kt"); + } + + @TestMetadata("invokeCall2.kt") + public void testInvokeCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/invokeCall2.kt"); + } + + @TestMetadata("invokeCall3.kt") + public void testInvokeCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/invokeCall3.kt"); + } + + @TestMetadata("invokeCall4.kt") + public void testInvokeCall4() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/invokeCall4.kt"); + } + + @TestMetadata("invokeCall5.kt") + public void testInvokeCall5() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/invokeCall5.kt"); + } + + @TestMetadata("lambdaWithBinaryExpression.kt") + public void testLambdaWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/lambdaWithBinaryExpression.kt"); + } + + @TestMetadata("lambdaWithBinaryExpression2.kt") + public void testLambdaWithBinaryExpression2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/lambdaWithBinaryExpression2.kt"); + } + + @TestMetadata("let.kt") + public void testLet() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/let.kt"); + } + + @TestMetadata("letMultipleLines.kt") + public void testLetMultipleLines() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letMultipleLines.kt"); + } + + @TestMetadata("letNoSafeCall.kt") + public void testLetNoSafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letNoSafeCall.kt"); + } + + @TestMetadata("letNotUseParameterReceiver.kt") + public void testLetNotUseParameterReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letNotUseParameterReceiver.kt"); + } + + @TestMetadata("letNotUseReceiver.kt") + public void testLetNotUseReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letNotUseReceiver.kt"); + } + + @TestMetadata("letUseIt.kt") + public void testLetUseIt() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letUseIt.kt"); + } + + @TestMetadata("letUseItAsParamWithBinaryExpression.kt") + public void testLetUseItAsParamWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letUseItAsParamWithBinaryExpression.kt"); + } + + @TestMetadata("letUseItWithBinaryExpression.kt") + public void testLetUseItWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithBinaryExpression.kt"); + } + + @TestMetadata("letUseItWithBinaryExpression2.kt") + public void testLetUseItWithBinaryExpression2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithBinaryExpression2.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall1.kt") + public void testLetUseItWithMultipleMethodCall1() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall1.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall2.kt") + public void testLetUseItWithMultipleMethodCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall2.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall3.kt") + public void testLetUseItWithMultipleMethodCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letUseItWithMultipleMethodCall3.kt"); + } + + @TestMetadata("letUseParameter.kt") + public void testLetUseParameter() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letUseParameter.kt"); + } + + @TestMetadata("letWithBinaryExpression.kt") + public void testLetWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letWithBinaryExpression.kt"); + } + + @TestMetadata("letWithMethodCall.kt") + public void testLetWithMethodCall() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letWithMethodCall.kt"); + } + + @TestMetadata("letWithMultipleMethodCall.kt") + public void testLetWithMultipleMethodCall() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letWithMultipleMethodCall.kt"); + } + + @TestMetadata("letWithParameter.kt") + public void testLetWithParameter() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letWithParameter.kt"); + } + + @TestMetadata("letWithSimpleBinaryExpression.kt") + public void testLetWithSimpleBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letWithSimpleBinaryExpression.kt"); + } + + @TestMetadata("letWithThisBinaryExpression.kt") + public void testLetWithThisBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letWithThisBinaryExpression.kt"); + } + + @TestMetadata("letWithThisShortBinaryExpression.kt") + public void testLetWithThisShortBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/letWithThisShortBinaryExpression.kt"); + } + + @TestMetadata("longCallChain.kt") + public void testLongCallChain() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/longCallChain.kt"); + } + + @TestMetadata("multipleReceiver.kt") + public void testMultipleReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver.kt"); + } + + @TestMetadata("multipleReceiver2.kt") + public void testMultipleReceiver2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver2.kt"); + } + + @TestMetadata("multipleReceiver3.kt") + public void testMultipleReceiver3() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver3.kt"); + } + + @TestMetadata("multipleUsages.kt") + public void testMultipleUsages() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/multipleUsages.kt"); + } + + @TestMetadata("noReceiver.kt") + public void testNoReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/noReceiver.kt"); + } + + @TestMetadata("plusNullable.kt") + public void testPlusNullable() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/plusNullable.kt"); + } + + @TestMetadata("receiverWithLambda.kt") + public void testReceiverWithLambda() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/receiverWithLambda.kt"); + } + + @TestMetadata("receiverWithLambda2.kt") + public void testReceiverWithLambda2() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/receiverWithLambda2.kt"); + } + + @TestMetadata("sameLets.kt") + public void testSameLets() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/sameLets.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/simple.kt"); + } + + @TestMetadata("smartCastInBody.kt") + public void testSmartCastInBody() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/smartCastInBody.kt"); + } + + @TestMetadata("this.kt") + public void testThis() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/this.kt"); + } + + @TestMetadata("thisShort.kt") + public void testThisShort() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/thisShort.kt"); + } + + @TestMetadata("typeChecks.kt") + public void testTypeChecks() throws Exception { + runTest("idea/testData/inspectionsLocal/complexRedundantLet/typeChecks.kt"); + } + } + @TestMetadata("idea/testData/inspectionsLocal/constantConditionIf") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -9298,369 +9661,6 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } - @TestMetadata("idea/testData/inspectionsLocal/replaceSingleLineLet") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ReplaceSingleLineLet extends AbstractLocalInspectionTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); - } - - public void testAllFilesPresentInReplaceSingleLineLet() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/replaceSingleLineLet"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); - } - - @TestMetadata("assignment.kt") - public void testAssignment() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/assignment.kt"); - } - - @TestMetadata("binarySafeCall.kt") - public void testBinarySafeCall() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/binarySafeCall.kt"); - } - - @TestMetadata("callChain.kt") - public void testCallChain() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/callChain.kt"); - } - - @TestMetadata("callChain2.kt") - public void testCallChain2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/callChain2.kt"); - } - - @TestMetadata("callChain3.kt") - public void testCallChain3() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/callChain3.kt"); - } - - @TestMetadata("callChainWithLineBreak.kt") - public void testCallChainWithLineBreak() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/callChainWithLineBreak.kt"); - } - - @TestMetadata("comparisons.kt") - public void testComparisons() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/comparisons.kt"); - } - - @TestMetadata("destructuringDeclaration.kt") - public void testDestructuringDeclaration() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration.kt"); - } - - @TestMetadata("destructuringDeclaration2.kt") - public void testDestructuringDeclaration2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration2.kt"); - } - - @TestMetadata("destructuringDeclaration3.kt") - public void testDestructuringDeclaration3() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration3.kt"); - } - - @TestMetadata("destructuringDeclaration4.kt") - public void testDestructuringDeclaration4() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration4.kt"); - } - - @TestMetadata("destructuringDeclaration5.kt") - public void testDestructuringDeclaration5() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration5.kt"); - } - - @TestMetadata("dotWithComparison.kt") - public void testDotWithComparison() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/dotWithComparison.kt"); - } - - @TestMetadata("functionCall1.kt") - public void testFunctionCall1() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall1.kt"); - } - - @TestMetadata("functionCall2.kt") - public void testFunctionCall2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall2.kt"); - } - - @TestMetadata("functionCall3.kt") - public void testFunctionCall3() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall3.kt"); - } - - @TestMetadata("functionCall4.kt") - public void testFunctionCall4() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall4.kt"); - } - - @TestMetadata("functionCall5.kt") - public void testFunctionCall5() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall5.kt"); - } - - @TestMetadata("functionCall6.kt") - public void testFunctionCall6() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall6.kt"); - } - - @TestMetadata("functionCall7.kt") - public void testFunctionCall7() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall7.kt"); - } - - @TestMetadata("functionCallInExtension.kt") - public void testFunctionCallInExtension() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallInExtension.kt"); - } - - @TestMetadata("functionCallOnSafeCall.kt") - public void testFunctionCallOnSafeCall() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallOnSafeCall.kt"); - } - - @TestMetadata("functionInVariableCall.kt") - public void testFunctionInVariableCall() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableCall.kt"); - } - - @TestMetadata("functionInVariableInvokeCall.kt") - public void testFunctionInVariableInvokeCall() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt"); - } - - @TestMetadata("in.kt") - public void testIn() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt"); - } - - @TestMetadata("inWithMultipleParam.kt") - public void testInWithMultipleParam() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/inWithMultipleParam.kt"); - } - - @TestMetadata("inWithRange.kt") - public void testInWithRange() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt"); - } - - @TestMetadata("inWithRangeMultipleParam.kt") - public void testInWithRangeMultipleParam() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRangeMultipleParam.kt"); - } - - @TestMetadata("invokeCall.kt") - public void testInvokeCall() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt"); - } - - @TestMetadata("invokeCall2.kt") - public void testInvokeCall2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt"); - } - - @TestMetadata("invokeCall3.kt") - public void testInvokeCall3() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt"); - } - - @TestMetadata("invokeCall4.kt") - public void testInvokeCall4() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall4.kt"); - } - - @TestMetadata("invokeCall5.kt") - public void testInvokeCall5() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall5.kt"); - } - - @TestMetadata("lambdaWithBinaryExpression.kt") - public void testLambdaWithBinaryExpression() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression.kt"); - } - - @TestMetadata("lambdaWithBinaryExpression2.kt") - public void testLambdaWithBinaryExpression2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression2.kt"); - } - - @TestMetadata("let.kt") - public void testLet() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt"); - } - - @TestMetadata("letMultipleLines.kt") - public void testLetMultipleLines() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letMultipleLines.kt"); - } - - @TestMetadata("letNoSafeCall.kt") - public void testLetNoSafeCall() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt"); - } - - @TestMetadata("letNotUseParameterReceiver.kt") - public void testLetNotUseParameterReceiver() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseParameterReceiver.kt"); - } - - @TestMetadata("letNotUseReceiver.kt") - public void testLetNotUseReceiver() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseReceiver.kt"); - } - - @TestMetadata("letUseIt.kt") - public void testLetUseIt() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseIt.kt"); - } - - @TestMetadata("letUseItAsParamWithBinaryExpression.kt") - public void testLetUseItAsParamWithBinaryExpression() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItAsParamWithBinaryExpression.kt"); - } - - @TestMetadata("letUseItWithBinaryExpression.kt") - public void testLetUseItWithBinaryExpression() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression.kt"); - } - - @TestMetadata("letUseItWithBinaryExpression2.kt") - public void testLetUseItWithBinaryExpression2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression2.kt"); - } - - @TestMetadata("letUseItWithMultipleMethodCall1.kt") - public void testLetUseItWithMultipleMethodCall1() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall1.kt"); - } - - @TestMetadata("letUseItWithMultipleMethodCall2.kt") - public void testLetUseItWithMultipleMethodCall2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall2.kt"); - } - - @TestMetadata("letUseItWithMultipleMethodCall3.kt") - public void testLetUseItWithMultipleMethodCall3() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall3.kt"); - } - - @TestMetadata("letUseParameter.kt") - public void testLetUseParameter() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseParameter.kt"); - } - - @TestMetadata("letWithBinaryExpression.kt") - public void testLetWithBinaryExpression() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt"); - } - - @TestMetadata("letWithMethodCall.kt") - public void testLetWithMethodCall() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt"); - } - - @TestMetadata("letWithMultipleMethodCall.kt") - public void testLetWithMultipleMethodCall() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt"); - } - - @TestMetadata("letWithParameter.kt") - public void testLetWithParameter() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt"); - } - - @TestMetadata("letWithSimpleBinaryExpression.kt") - public void testLetWithSimpleBinaryExpression() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt"); - } - - @TestMetadata("letWithThisBinaryExpression.kt") - public void testLetWithThisBinaryExpression() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt"); - } - - @TestMetadata("letWithThisShortBinaryExpression.kt") - public void testLetWithThisShortBinaryExpression() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt"); - } - - @TestMetadata("longCallChain.kt") - public void testLongCallChain() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt"); - } - - @TestMetadata("multipleReceiver.kt") - public void testMultipleReceiver() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver.kt"); - } - - @TestMetadata("multipleReceiver2.kt") - public void testMultipleReceiver2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver2.kt"); - } - - @TestMetadata("multipleReceiver3.kt") - public void testMultipleReceiver3() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver3.kt"); - } - - @TestMetadata("multipleUsages.kt") - public void testMultipleUsages() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/multipleUsages.kt"); - } - - @TestMetadata("noReceiver.kt") - public void testNoReceiver() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/noReceiver.kt"); - } - - @TestMetadata("plusNullable.kt") - public void testPlusNullable() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/plusNullable.kt"); - } - - @TestMetadata("receiverWithLambda.kt") - public void testReceiverWithLambda() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda.kt"); - } - - @TestMetadata("receiverWithLambda2.kt") - public void testReceiverWithLambda2() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda2.kt"); - } - - @TestMetadata("sameLets.kt") - public void testSameLets() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt"); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/simple.kt"); - } - - @TestMetadata("smartCastInBody.kt") - public void testSmartCastInBody() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/smartCastInBody.kt"); - } - - @TestMetadata("this.kt") - public void testThis() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt"); - } - - @TestMetadata("thisShort.kt") - public void testThisShort() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt"); - } - - @TestMetadata("typeChecks.kt") - public void testTypeChecks() throws Exception { - runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/typeChecks.kt"); - } - } - @TestMetadata("idea/testData/inspectionsLocal/replaceStringFormatWithLiteral") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -10546,6 +10546,369 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/simpleRedundantLet") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleRedundantLet extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInSimpleRedundantLet() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/simpleRedundantLet"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("assignment.kt") + public void testAssignment() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/assignment.kt"); + } + + @TestMetadata("binarySafeCall.kt") + public void testBinarySafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/binarySafeCall.kt"); + } + + @TestMetadata("callChain.kt") + public void testCallChain() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/callChain.kt"); + } + + @TestMetadata("callChain2.kt") + public void testCallChain2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/callChain2.kt"); + } + + @TestMetadata("callChain3.kt") + public void testCallChain3() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/callChain3.kt"); + } + + @TestMetadata("callChainWithLineBreak.kt") + public void testCallChainWithLineBreak() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/callChainWithLineBreak.kt"); + } + + @TestMetadata("comparisons.kt") + public void testComparisons() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/comparisons.kt"); + } + + @TestMetadata("destructuringDeclaration.kt") + public void testDestructuringDeclaration() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration.kt"); + } + + @TestMetadata("destructuringDeclaration2.kt") + public void testDestructuringDeclaration2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration2.kt"); + } + + @TestMetadata("destructuringDeclaration3.kt") + public void testDestructuringDeclaration3() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration3.kt"); + } + + @TestMetadata("destructuringDeclaration4.kt") + public void testDestructuringDeclaration4() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration4.kt"); + } + + @TestMetadata("destructuringDeclaration5.kt") + public void testDestructuringDeclaration5() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/destructuringDeclaration5.kt"); + } + + @TestMetadata("dotWithComparison.kt") + public void testDotWithComparison() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/dotWithComparison.kt"); + } + + @TestMetadata("functionCall1.kt") + public void testFunctionCall1() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCall1.kt"); + } + + @TestMetadata("functionCall2.kt") + public void testFunctionCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCall2.kt"); + } + + @TestMetadata("functionCall3.kt") + public void testFunctionCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCall3.kt"); + } + + @TestMetadata("functionCall4.kt") + public void testFunctionCall4() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCall4.kt"); + } + + @TestMetadata("functionCall5.kt") + public void testFunctionCall5() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCall5.kt"); + } + + @TestMetadata("functionCall6.kt") + public void testFunctionCall6() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCall6.kt"); + } + + @TestMetadata("functionCall7.kt") + public void testFunctionCall7() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCall7.kt"); + } + + @TestMetadata("functionCallInExtension.kt") + public void testFunctionCallInExtension() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCallInExtension.kt"); + } + + @TestMetadata("functionCallOnSafeCall.kt") + public void testFunctionCallOnSafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionCallOnSafeCall.kt"); + } + + @TestMetadata("functionInVariableCall.kt") + public void testFunctionInVariableCall() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableCall.kt"); + } + + @TestMetadata("functionInVariableInvokeCall.kt") + public void testFunctionInVariableInvokeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/functionInVariableInvokeCall.kt"); + } + + @TestMetadata("in.kt") + public void testIn() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/in.kt"); + } + + @TestMetadata("inWithMultipleParam.kt") + public void testInWithMultipleParam() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/inWithMultipleParam.kt"); + } + + @TestMetadata("inWithRange.kt") + public void testInWithRange() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/inWithRange.kt"); + } + + @TestMetadata("inWithRangeMultipleParam.kt") + public void testInWithRangeMultipleParam() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/inWithRangeMultipleParam.kt"); + } + + @TestMetadata("invokeCall.kt") + public void testInvokeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall.kt"); + } + + @TestMetadata("invokeCall2.kt") + public void testInvokeCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall2.kt"); + } + + @TestMetadata("invokeCall3.kt") + public void testInvokeCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall3.kt"); + } + + @TestMetadata("invokeCall4.kt") + public void testInvokeCall4() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall4.kt"); + } + + @TestMetadata("invokeCall5.kt") + public void testInvokeCall5() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/invokeCall5.kt"); + } + + @TestMetadata("lambdaWithBinaryExpression.kt") + public void testLambdaWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/lambdaWithBinaryExpression.kt"); + } + + @TestMetadata("lambdaWithBinaryExpression2.kt") + public void testLambdaWithBinaryExpression2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/lambdaWithBinaryExpression2.kt"); + } + + @TestMetadata("let.kt") + public void testLet() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/let.kt"); + } + + @TestMetadata("letMultipleLines.kt") + public void testLetMultipleLines() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letMultipleLines.kt"); + } + + @TestMetadata("letNoSafeCall.kt") + public void testLetNoSafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letNoSafeCall.kt"); + } + + @TestMetadata("letNotUseParameterReceiver.kt") + public void testLetNotUseParameterReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letNotUseParameterReceiver.kt"); + } + + @TestMetadata("letNotUseReceiver.kt") + public void testLetNotUseReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letNotUseReceiver.kt"); + } + + @TestMetadata("letUseIt.kt") + public void testLetUseIt() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letUseIt.kt"); + } + + @TestMetadata("letUseItAsParamWithBinaryExpression.kt") + public void testLetUseItAsParamWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letUseItAsParamWithBinaryExpression.kt"); + } + + @TestMetadata("letUseItWithBinaryExpression.kt") + public void testLetUseItWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithBinaryExpression.kt"); + } + + @TestMetadata("letUseItWithBinaryExpression2.kt") + public void testLetUseItWithBinaryExpression2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithBinaryExpression2.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall1.kt") + public void testLetUseItWithMultipleMethodCall1() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall1.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall2.kt") + public void testLetUseItWithMultipleMethodCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall2.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall3.kt") + public void testLetUseItWithMultipleMethodCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letUseItWithMultipleMethodCall3.kt"); + } + + @TestMetadata("letUseParameter.kt") + public void testLetUseParameter() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letUseParameter.kt"); + } + + @TestMetadata("letWithBinaryExpression.kt") + public void testLetWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letWithBinaryExpression.kt"); + } + + @TestMetadata("letWithMethodCall.kt") + public void testLetWithMethodCall() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letWithMethodCall.kt"); + } + + @TestMetadata("letWithMultipleMethodCall.kt") + public void testLetWithMultipleMethodCall() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letWithMultipleMethodCall.kt"); + } + + @TestMetadata("letWithParameter.kt") + public void testLetWithParameter() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letWithParameter.kt"); + } + + @TestMetadata("letWithSimpleBinaryExpression.kt") + public void testLetWithSimpleBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letWithSimpleBinaryExpression.kt"); + } + + @TestMetadata("letWithThisBinaryExpression.kt") + public void testLetWithThisBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letWithThisBinaryExpression.kt"); + } + + @TestMetadata("letWithThisShortBinaryExpression.kt") + public void testLetWithThisShortBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/letWithThisShortBinaryExpression.kt"); + } + + @TestMetadata("longCallChain.kt") + public void testLongCallChain() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/longCallChain.kt"); + } + + @TestMetadata("multipleReceiver.kt") + public void testMultipleReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver.kt"); + } + + @TestMetadata("multipleReceiver2.kt") + public void testMultipleReceiver2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver2.kt"); + } + + @TestMetadata("multipleReceiver3.kt") + public void testMultipleReceiver3() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/multipleReceiver3.kt"); + } + + @TestMetadata("multipleUsages.kt") + public void testMultipleUsages() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/multipleUsages.kt"); + } + + @TestMetadata("noReceiver.kt") + public void testNoReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/noReceiver.kt"); + } + + @TestMetadata("plusNullable.kt") + public void testPlusNullable() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/plusNullable.kt"); + } + + @TestMetadata("receiverWithLambda.kt") + public void testReceiverWithLambda() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/receiverWithLambda.kt"); + } + + @TestMetadata("receiverWithLambda2.kt") + public void testReceiverWithLambda2() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/receiverWithLambda2.kt"); + } + + @TestMetadata("sameLets.kt") + public void testSameLets() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/sameLets.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/simple.kt"); + } + + @TestMetadata("smartCastInBody.kt") + public void testSmartCastInBody() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/smartCastInBody.kt"); + } + + @TestMetadata("this.kt") + public void testThis() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/this.kt"); + } + + @TestMetadata("thisShort.kt") + public void testThisShort() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/thisShort.kt"); + } + + @TestMetadata("typeChecks.kt") + public void testTypeChecks() throws Exception { + runTest("idea/testData/inspectionsLocal/simpleRedundantLet/typeChecks.kt"); + } + } + @TestMetadata("idea/testData/inspectionsLocal/simplifyAssertNotNull") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)