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 InputFallThroughLastLineCommentCheck {
12  
13      public void method(int i) {
14          switch (i) {
15              case 1:
16                  if (true) {
17                  }
18                  // comment
19                  // fall through
20                  // check
21              case 2: // violation 'Fall\ through from previous branch of the switch statement'
22                  break;
23              case 3:
24                  break;
25          }
26      }
27  
28      public void method2(int i) {
29          switch (i) {
30              case 1:
31                  i++;
32                  /* block */ /* fallthru */ // comment
33              case 2:
34                  // this is comment
35                  i++;
36                  // fall through
37          }
38      }
39  
40      public void method3(int i) {
41          switch (i) {
42              case 1:
43                  break;
44              case 2:
45                  // this is comment
46                  i++;
47                  // fallthru
48          }
49      }
50  
51      public void method4(int i) {
52          switch (i) {
53              case 1:
54                  break;
55              case 2:
56                  // this is comment
57                  i++;
58              /* comment */ // fallthru
59          }
60      }
61  
62     void methodFallThruCC(int i) {
63        while (true) {
64            switch (i){
65            case 5:
66                i++;
67            // fallthru
68            }
69        }
70     }
71  
72     void method4(int i, int j, boolean cond) {
73        while (true) {
74            switch (i){
75            case 5:
76                i++;
77                /* block */ /* comment */ // fallthru
78            }
79        }
80     }
81  
82     void method5(int i, int j, boolean cond) {
83        while (true) {
84            switch (i){
85            case 5:
86                i++;
87                /* block */ // comment
88                /* fallthru */
89            }
90        }
91     }
92  
93      void method6(String str) {
94          switch (str) {
95              case "9": String s = "s🥳d🥳s";
96                  //🥳d🥳 fallthru
97  
98              case "10": String s2 = "s🥳d🥳s";
99              /*🥳🥳🥳🥳🥳🥳*/ /* fallthru */ default: str.toUpperCase();
100             // violation above 'Fall .* from the last branch of the switch statement'
101         }
102     }
103 
104    void method7(int i, int j, boolean cond) {
105       while (true) {
106           switch (i){
107           case 5:
108               i++;
109               /* block */ i++; /* fallthru */ // comment
110           }
111       }
112    }
113 }