View Javadoc
1   /*
2   FallThrough
3   checkLastCaseGroup = (default)false
4   reliefPattern = (default)falls?[ -]?thr(u|ough)
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough;
10  
11  public class InputFallThrough2 {
12      enum Test {
13          A, B, C
14      }
15  
16      public static void test() {
17          Test test = Test.A;
18          int variable = 0;
19  
20          switch (test) {
21              case A:
22                  break;
23              case B:
24                  if (variable == 1) {
25                      // some work
26                      break;
27                  }
28              case C: // violation 'Fall\ through from previous branch of the switch statement.'
29                  break;
30          }
31  
32          int var2 = 1;
33          switch (variable) {
34              case 0:
35              case 1:
36              case 2:
37                  System.identityHashCode(var2);
38                  break;
39              case 3:
40                  if (true) {
41                      return;
42                  }
43              case 4: // violation 'Fall\ through from previous branch of the switch statement.'
44                  if (var2 == 2) {
45                      break;
46                  }
47              case 5: // violation 'Fall\ through from previous branch of the switch statement.'
48                  if (var2 == 1) {
49  
50                  }
51                  else if (true) {
52                      return;
53                  }
54              case 6: // violation 'Fall\ through from previous branch of the switch statement.'
55                  if (var2 > 1) {
56                      break;
57                  }
58                  else {
59                      break;
60                  }
61              case 7:
62                  if (var2 ==1) {
63                      break;
64                  }
65                  else if (true) {
66                      return;
67                  }
68              case 8: // violation 'Fall\ through from previous branch of the switch statement.'
69                  if(var2 == 5) {
70                      System.identityHashCode("0xB16B00B5");
71                  }
72                  else {
73                      break;
74                  }
75              case 9: // violation 'Fall\ through from previous branch of the switch statement.'
76                  if(var2 == 5) {
77                      System.identityHashCode("0xCAFED00D");
78                  }
79                  else {
80                      String.CASE_INSENSITIVE_ORDER.equals("0x4B1D");
81                  }
82                  break;
83              case 10:
84                  int var3 = 0xDEADBEEF;
85                  switch (var3) {
86                      case 0xCAFEBABE:
87                          String.CASE_INSENSITIVE_ORDER.equals("0x1CEB00DA");
88                      default: // violation 'Fall\ through from prev.* br.* switch statement.'
89                          String.CASE_INSENSITIVE_ORDER.equals("");
90                  }
91                  if(true) {
92                      break;
93                  }
94              case 11: // violation 'Fall\ through from previous branch of the switch statement.'
95                  if(false) {break;}
96              case 12: // violation 'Fall\ through from previous branch of the switch statement.'
97                  if(true);
98                  break;
99              default:
100                 break;
101         }
102     }
103 }