View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
2   
3   /** some javadoc. */
4   public class InputRightCurlySwitchCasesBlocks {
5   
6     /** some javadoc. */
7     public static void test0() {
8       int mode = 0;
9       switch (mode) {
10        case 1:
11          { // violation ''{' at column 9 should be on the previous line.'
12            int x = 1;
13            break;
14          }
15        case 2:
16          { // violation ''{' at column 9 should be on the previous line.'
17            int x = 0;
18            break;
19          }
20        default:
21      }
22    }
23  
24    /** some javadoc. */
25    public static void test() {
26      int mode = 0;
27      switch (mode) {
28        case 1:
29          { // violation ''{' at column 9 should be on the previous line.'
30            int x = 1;
31            break;
32          } default:
33          int x = 0;
34          // 2 violations 2 lines above:
35          //  ''}' at column 9 should be alone on a line.'
36          //  ''case' child has incorrect indentation level 8, expected level should be 6.'
37      }
38    }
39  
40    /** some javadoc. */
41    public static void test1() {
42      int k = 0;
43      switch (k) {
44        case 1:
45          { // violation ''{' at column 9 should be on the previous line.'
46          int x = 1; } // violation ''}' at column 20 should be alone on a line.'
47          break;
48        case 2:
49          int x = 2;
50          break;
51        default:
52      }
53    }
54  
55    /** some javadoc. */
56    public static void test2() {
57      int mode = 0;
58      switch (mode) {
59        case 1:
60          int x = 1;
61          break;
62        case 2:
63          { // violation ''{' at column 9 should be on the previous line.'
64            break;
65          }
66        default:
67      }
68    }
69  
70    /** some javadoc. */
71    public static void test3() {
72      int k = 0;
73      switch (k) {
74        case 1:
75          { // violation ''{' at column 9 should be on the previous line.'
76            int x = 1;
77            break;
78          }
79        case 2:
80          { // violation ''{' at column 9 should be on the previous line.'
81          int x = 2; } // violation ''}' at column 20 should be alone on a line.'
82          break;
83        default:
84      }
85    }
86  }