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