Add "Control flow with empty body" inspection
#KT-30970 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
d2fcb8cc6a
commit
65f06454be
@@ -3374,7 +3374,16 @@
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ControlFlowWithEmptyBodyInspection"
|
||||
displayName="Control flow with empty body"
|
||||
groupPath="Kotlin"
|
||||
groupName="Probable bugs"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<referenceImporter implementation="org.jetbrains.kotlin.idea.quickfix.KotlinReferenceImporter"/>
|
||||
|
||||
<fileType.fileViewProviderFactory filetype="KJSM" implementationClass="com.intellij.psi.ClassFileViewProviderFactory"/>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
This inspection reports that <b>if</b>, <b>when</b>, <b>for</b>, <b>while</b> and also expressions has empty body.
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.inspections
|
||||
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.inspections.collections.isCalling
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
|
||||
class ControlFlowWithEmptyBodyInspection : AbstractKotlinInspection() {
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean) = object : KtVisitorVoid() {
|
||||
override fun visitIfExpression(expression: KtIfExpression) {
|
||||
if (expression.then.isEmptyBodyOrNull()) {
|
||||
holder.registerProblem(expression, expression.ifKeyword)
|
||||
}
|
||||
val elseKeyword = expression.elseKeyword
|
||||
if (elseKeyword != null && expression.`else`.isEmptyBodyOrNull()) {
|
||||
holder.registerProblem(expression, elseKeyword)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitWhenExpression(expression: KtWhenExpression) {
|
||||
if (expression.entries.isNotEmpty()) return
|
||||
holder.registerProblem(expression, expression.whenKeyword)
|
||||
}
|
||||
|
||||
override fun visitForExpression(expression: KtForExpression) {
|
||||
if (expression.body.isEmptyBodyOrNull()) {
|
||||
holder.registerProblem(expression, expression.forKeyword)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitWhileExpression(expression: KtWhileExpression) {
|
||||
val keyword = expression.allChildren.firstOrNull { it.node.elementType == KtTokens.WHILE_KEYWORD } ?: return
|
||||
if (expression.body.isEmptyBodyOrNull()) {
|
||||
holder.registerProblem(expression, keyword)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitDoWhileExpression(expression: KtDoWhileExpression) {
|
||||
val keyword = expression.allChildren.firstOrNull { it.node.elementType == KtTokens.DO_KEYWORD } ?: return
|
||||
if (expression.body.isEmptyBodyOrNull()) {
|
||||
holder.registerProblem(expression, keyword)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitCallExpression(expression: KtCallExpression) {
|
||||
val callee = expression.calleeExpression ?: return
|
||||
if (!expression.isCalling(controlFlowFunctions)) return
|
||||
val body = when (val argument = expression.valueArguments.singleOrNull()?.getArgumentExpression()) {
|
||||
is KtLambdaExpression -> argument.bodyExpression
|
||||
is KtNamedFunction -> argument.bodyBlockExpression
|
||||
else -> return
|
||||
}
|
||||
if (body.isEmptyBodyOrNull()) {
|
||||
holder.registerProblem(expression, callee)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun KtExpression?.isEmptyBodyOrNull(): Boolean = if (this == null) true else this is KtBlockExpression && statements.isEmpty()
|
||||
|
||||
private fun ProblemsHolder.registerProblem(expression: KtExpression, keyword: PsiElement) {
|
||||
val keywordText = if (expression is KtDoWhileExpression) "do while" else keyword.text
|
||||
registerProblem(
|
||||
expression,
|
||||
keyword.textRange.shiftLeft(expression.startOffset),
|
||||
"'$keywordText' has empty body"
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val controlFlowFunctions = listOf("kotlin.also").map { FqName(it) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.ControlFlowWithEmptyBodyInspection
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'also' has empty body
|
||||
// FIX: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
42.<caret>also(fun(it: Int) {
|
||||
})
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
// FIX: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
42.<caret>also(fun(it: Int) {
|
||||
println(it)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'also' has empty body
|
||||
// FIX: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(i: Int) {
|
||||
i.<caret>also {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'also' has empty body
|
||||
// FIX: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
42.<caret>also({ })
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: 'also' has empty body
|
||||
// FIX: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(i: Int) {
|
||||
i.<caret>also {
|
||||
// comment
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(i: Int) {
|
||||
i.<caret>also {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
42.<caret>also({ println(it) })
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
42.<caret>also(::println)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'also' has empty body
|
||||
// FIX: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun String.test() {
|
||||
<caret>also { }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'do while' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>do {
|
||||
} while (i == 1)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'do while' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>do {
|
||||
// comment
|
||||
} while (i == 1)
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>do {
|
||||
foo()
|
||||
} while (i == 1)
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: 'do while' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>do while (i == 1)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>do foo() while (i == 1)
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'for' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test() {
|
||||
<caret>for (i in 1..10) {
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'for' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test() {
|
||||
<caret>for (i in 1..10) {
|
||||
// comment
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test() {
|
||||
<caret>for (i in 1..10) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: 'for' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test() {
|
||||
<caret>for (i in 1..10);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test() {
|
||||
<caret>for (i in 1..10) foo()
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'if' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>if (i == 1) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'if' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>if (i == 1) {
|
||||
// comment
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: 'if' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>if (i == 1) {
|
||||
} else if (i == 2) {
|
||||
} else if (i == 3) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>if (i == 1) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'if' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
if (i == 1) {
|
||||
} else <caret>if (i == 2) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'if' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>if (i == 1) else {
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>if (i == 1) foo() else {
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'else' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
if (i == 1) {
|
||||
} <caret>else {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: 'else' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
if (i == 1) {
|
||||
} <caret>else {
|
||||
// comment
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
if (i == 1) {
|
||||
} <caret>else {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: 'else' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
if (i == 1) {}<caret>else {};
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
if (i == 1) {
|
||||
} <caret>else foo()
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'when' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>when (i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'when' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test() {
|
||||
<caret>when (val i = 1) {
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'when' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>when (i) {
|
||||
// comment
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>when (i) {
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: 'while' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>while (i == 1) {
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'while' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>while (i == 1) {
|
||||
// comment
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>while (i == 1) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: 'while' has empty body
|
||||
// FIX: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>while (i == 1);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(i: Int) {
|
||||
<caret>while (i == 1) foo()
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
+304
@@ -1780,6 +1780,310 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/controlFlowWithEmptyBody")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ControlFlowWithEmptyBody extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInControlFlowWithEmptyBody() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/controlFlowWithEmptyBody"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Also extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInAlso() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousFunction.kt")
|
||||
public void testAnonymousFunction() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/anonymousFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousFunctionHasStatement.kt")
|
||||
public void testAnonymousFunctionHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/anonymousFunctionHasStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("block.kt")
|
||||
public void testBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/block.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("block2.kt")
|
||||
public void testBlock2() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/block2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasComment.kt")
|
||||
public void testBlockHasComment() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/blockHasComment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasStatement.kt")
|
||||
public void testBlockHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/blockHasStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasStatement2.kt")
|
||||
public void testBlockHasStatement2() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/blockHasStatement2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionReference.kt")
|
||||
public void testFunctionReference() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/functionReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("implicitReceiver.kt")
|
||||
public void testImplicitReceiver() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/also/implicitReceiver.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/doWhile")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class DoWhile extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDoWhile() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/doWhile"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("block.kt")
|
||||
public void testBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/doWhile/block.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasComment.kt")
|
||||
public void testBlockHasComment() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/doWhile/blockHasComment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasStatement.kt")
|
||||
public void testBlockHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/doWhile/blockHasStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("single.kt")
|
||||
public void testSingle() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/doWhile/single.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleHasStatement.kt")
|
||||
public void testSingleHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/doWhile/singleHasStatement.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/for")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class For extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInFor() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/for"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("block.kt")
|
||||
public void testBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/for/block.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasComment.kt")
|
||||
public void testBlockHasComment() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/for/blockHasComment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasStatement.kt")
|
||||
public void testBlockHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/for/blockHasStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("single.kt")
|
||||
public void testSingle() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/for/single.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleHasStatement.kt")
|
||||
public void testSingleHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/for/singleHasStatement.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class If extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIf() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("block.kt")
|
||||
public void testBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if/block.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasComment.kt")
|
||||
public void testBlockHasComment() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if/blockHasComment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasElse.kt")
|
||||
public void testBlockHasElse() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if/blockHasElse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasStatement.kt")
|
||||
public void testBlockHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if/blockHasStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("elseIf.kt")
|
||||
public void testElseIf() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if/elseIf.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("single.kt")
|
||||
public void testSingle() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if/single.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleHasStatement.kt")
|
||||
public void testSingleHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/if/singleHasStatement.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/ifElse")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class IfElse extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIfElse() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/ifElse"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("block.kt")
|
||||
public void testBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/ifElse/block.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasComment.kt")
|
||||
public void testBlockHasComment() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/ifElse/blockHasComment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasStatement.kt")
|
||||
public void testBlockHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/ifElse/blockHasStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("single.kt")
|
||||
public void testSingle() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/ifElse/single.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleHasStatement.kt")
|
||||
public void testSingleHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/ifElse/singleHasStatement.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/when")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class When extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInWhen() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/when"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("block.kt")
|
||||
public void testBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/when/block.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("block2.kt")
|
||||
public void testBlock2() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/when/block2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasComment.kt")
|
||||
public void testBlockHasComment() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/when/blockHasComment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasStatement.kt")
|
||||
public void testBlockHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/when/blockHasStatement.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/while")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class While extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInWhile() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/while"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("block.kt")
|
||||
public void testBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/while/block.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasComment.kt")
|
||||
public void testBlockHasComment() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/while/blockHasComment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasStatement.kt")
|
||||
public void testBlockHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/while/blockHasStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("single.kt")
|
||||
public void testSingle() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/while/single.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleHasStatement.kt")
|
||||
public void testSingleHasStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/controlFlowWithEmptyBody/while/singleHasStatement.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/conventionNameCalls")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user