diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputNestedBlocks.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputNestedBlocks.java index 38da1b342..2fc6c03bd 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputNestedBlocks.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputNestedBlocks.java @@ -29,14 +29,33 @@ class InputNestedBlocks x = 2; } + // case statements are a bit complicated, + // they do not have its own variable scope by default. + // Hence it may be OK in some development teams to allow + // nested blocks if they are the complete case body. switch (x) { case 0: - x = 3; // OK + // OK + x = 3; break; + case 1: + // Not OK, SLIST is not complete case body + { + x = 1; + } + break; + case 2: + // OK if allowInSwitchCase is true, SLIST is complete case body + { + x = 1; + break; + } + case 3: // test fallthrough default: - { // should be marked, even if a switch - // case does not have its own scope + // Not OK, SLIST is not complete case body + System.out.println("Hello"); + { x = 2; } }