View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="AvoidNestedBlocks">
5         <property name="allowInSwitchCase" value="true"/>
6       </module>
7     </module>
8   </module>
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.blocks.avoidnestedblocks;
12  
13  import static org.checkstyle.suppressionxpathfilter.interfaceistype.InputXpathInterfaceIsTypeAllowMarker.a;
14  
15  // xdoc section -- start
16  public class Example2 {
17    public void foo() {
18      int myInteger = 0;
19      {                      // violation 'Avoid nested blocks'
20        myInteger = 2;
21      }
22      System.out.println("myInteger = " + myInteger);
23  
24      switch (a) {
25        case 1: {
26          System.out.println("Case 1");
27          break;
28        }
29        case 2:
30          System.out.println("Case 2");
31          break;
32      }
33    }
34  }
35  // xdoc section -- end