View Javadoc
1   /*
2   RightCurly
3   option = ALONE
4   tokens = LITERAL_CASE
5   
6   */
7   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
8   
9   public class InputRightCurlyCaseBlocksInSwitchStatementAlone2 {
10       public static void test9() {
11          int mode = 0;
12          switch (mode) {
13              case 0: int x = 1;
14              case 1: x = 1; break;
15              case 2: {
16                  x =
17              1;} default : x = 5;         // violation '}' at column 15 should be alone on a line'
18          }
19      }
20  
21      public static void test10() {
22          int mode = 0;
23          switch (mode) {
24              case 0: {
25  
26              } case 1: int x = 1; break;    // violation '}' at column 13 should be alone on a line'
27              case 2: {
28  
29              }
30              default : x = 5;
31          }
32      }
33       public static void test11() {
34          int mode = 0;
35          switch (mode) {
36              case 0: {
37  
38              } case 1: int x = 1; break;   // violation '}' at column 13 should be alone on a line'
39              case 2: {
40  
41              } default : x = 5;            // violation '}' at column 13 should be alone on a line'
42          }
43      }
44      public static void test12() {
45          int mode = 0;
46          switch (mode) {
47              case 0: {
48  
49              int x = 1; } case 1: {int x = 1;} break;  // 2 violations
50          }
51      }
52      public static void test13() {
53          int mode = 0;
54          switch (mode) {
55              case 0: { int x = 1;
56  
57              } case 1: { // violation '}' at column 13 should be alone on a line'
58  
59              }
60              default : break;
61          }
62      }
63      public static void test14() {
64          int mode = 0;
65          switch (mode) {
66              case 0: {
67  
68              } case 1: {  }         // 2 violations
69              default : {break;}
70          }
71      }
72  
73      public static void test15() {
74          int mode = 0;
75          switch (mode) {case 0: { } case 1: {  } } // 2 violations
76      }
77  
78      public static void test16() {
79          int mode = 0;
80          switch (mode) {
81              case 0: int x = 1; { } break;  // ok, the braces is not a first child of case
82              case 1: { } int y = 1; break;
83              // violation above '}' at column 23 should be alone on a line'
84              case 2: int t = 1; { };
85          }
86      }
87  
88      public static void test17() {
89          int mode = 0;
90          switch (mode) {
91              case 0:
92              int x = 1;
93              {  }  // ok, the braces is not a first child of case
94              case 1:
95              mode++;
96              {
97  
98              } int y; // ok, the braces is not a first child of case
99              case 3:
100             {
101 
102             } int z = 1;  // violation '}' at column 13 should be alone on a line'
103         }
104     }
105 
106     public static void test18() {
107         int mode = 0;
108         switch (mode) {
109             case 0: {
110             }
111             int x;
112             case 1:
113             int z;
114             {
115 
116             }break; default: break; // ok, the braces is not a first child of case
117         }
118     }
119 }
120