View Javadoc
1   /*
2   FallThrough
3   checkLastCaseGroup = true
4   reliefPattern = (default)falls?[ -]?thr(u|ough)
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough;
10  
11  public class InputFallThrough4 {
12      void methodFallThru(int i, int j) {
13          while (true) {
14              switch (i) {
15                  case -1: // FALLTHRU
16                  case 0:
17                  case 26:
18                      switch (j) {
19                          case 1:
20                              continue;
21                          case 2:
22                              break;
23                          default:
24                          return;
25                      }
26                  // fallthru
27              default:
28                // this is the last label
29                  i++;
30              // fallthru
31           }
32        }
33     }
34  
35     void methodFallThruCC(int i, int j) {
36        while (true) {
37            switch (i){
38            case 5:
39                i++;
40            // fallthru
41            }
42        }
43     }
44  
45     void methodFall(int i, int j) {
46        while (true) {
47            switch (i){
48            case 5: // violation 'Fall .* from the last branch of the switch statement'
49                i++;
50            }
51        }
52     }
53  
54     void method(int i, int j) {
55        while (true) {
56            switch (i){
57            case 2: {
58                i++;
59            }
60            // fallthru
61            case 3:
62                i++;
63            /* fallthru */case 4:
64                  break;
65            case 5:
66                i++;
67            // fallthru
68            }
69        }
70     }
71  
72     void method2(int i, int j) {
73        while (true) {
74            switch (i){
75            case 2: {
76                i++;
77            }
78            // fallthru
79            case 3:
80                i++;
81            /* fallthru */case 4:
82                  break;
83            case 5: // violation 'Fall .* from the last branch of the switch statement'
84                i++;
85            }
86        }
87     }
88  
89      void method3(int i, int j, boolean cond) {
90        while (true) {
91            switch (i){
92            case 5:
93                i++;
94                /* block */ /* fallthru */
95            }
96        }
97     }
98  
99     void method4(int i, int j, boolean cond) {
100       while (true) {
101           switch (i){
102           case 5:
103               i++;
104               /* block */ /* comment */ // fallthru
105           }
106       }
107    }
108 
109    void method5(int i, int j, boolean cond) {
110       while (true) {
111           switch (i){
112           case 5:
113               i++;
114               /* block */ /* fallthru */ // comment
115           }
116       }
117    }
118 }