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 InputFallThroughCharacterSwitch
12  {
13      void foo(char c, int i) {
14          while (true) {
15              switch (c) {
16              case 'a':
17              case 'b':
18                  i++;
19              case 'c': // violation 'Fall\ through from previous branch of the switch statement.'
20                  String.valueOf(i);
21                  break;
22              case 'd':
23                  return;
24              case 'e':
25                  continue;
26              case 'f':
27                  if (true) {
28                      return;
29                  }
30              case 'g': // violation 'Fall\ through from previous branch of the switch statement.'
31                  try {
32                      i++;
33                      break;
34                  } catch (RuntimeException e) {
35                  } catch (Error e) {
36                      return;
37                  }
38              case 'h': // violation 'Fall\ through from previous branch of the switch statement.'
39                  switch (i) {
40                  case 1:
41                      continue;
42                  case 2:
43                      i++;
44                  case 3: // violation 'Fall\ through from previous branch of the switch statement.'
45                      String.valueOf(i);
46                      return;
47                  }
48              case 'i': // violation 'Fall\ through from previous branch of the switch statement.'
49                  switch (i) {
50                  case 1:
51                      continue;
52                  case 2:
53                      i++;
54                      break;
55                  case 3:
56                      String.valueOf(i);
57                      return;
58                  }
59                  break;
60              case 'A':
61                  i++;
62                  // FALL-THRU (case-sensitive)
63              case 'B': // violation 'Fall\ through from previous branch of the switch statement.'
64                  i++;
65                  // fall-through
66              default:
67                  i++;
68                  break;
69              }
70          }
71      }
72  }