View Javadoc
1   /*
2   RightCurly
3   option = SAME
4   tokens = LITERAL_SWITCH, LITERAL_IF
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
10  
11  public class InputRightCurlyTestSwitchCase5 {
12  
13      public void method() {
14          int x = 0;
15          switch (x) { }
16          switch (x) {
17          } int a; // violation ''}' at column 9 should be alone on a line'
18          switch (x) {
19              case(1): x = 0; break; } // violation ''}' at column 36 should have line break before'
20          switch (x)
21          {
22          }
23          switch (x)
24          {case(1): x=1;break;
25          } int b; // violation ''}' at column 9 should be alone on a line'
26          switch (x) {case(2): break; } int c;
27          // violation above ''}' at column 37 should be alone on a line'
28          switch (x) { } int d; // violation ''}' at column 22 should be alone on a line'
29          switch (x) { }
30      }
31  
32      public void someMethod2() {
33          int x = 90;
34          if (7>x) {
35              switch (x) { case(1): break;}} // 2 violations
36      }
37  
38      public void someMethod3() {
39          int x = 90;
40          if (7>x) {switch (x) {case(1): break;}}
41          // violation above ''}' at column 46 should be alone on a line'
42          if (7>x) {switch (x) { }} // violation ''}' at column 32 should be alone on a line'
43      }
44  }
45  
46  class NoViolationOnInputRightCurlyTestSwitchCase5 {
47      public void method() {
48          int x = 0;
49          switch (x) { }
50          switch (x) { default: }
51          switch (x) { case(1): x = 0; break; }
52          switch (x)
53          {
54          }
55          switch (x)
56          {case(1): x=1;break;
57          }
58          int b;
59          switch (x) {case(2): break; }
60          switch (x) { }
61      }
62  
63      public void someMethod2() {
64          int x = 90;
65          if (7>x) { switch (x) { case(1): break; } }
66          // violation above ''}' at column 49 should be alone on a line'
67      }
68  }