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 InputFallThrough6 {
12 void foo(int i){
13 switch(i) {
14 case 1:
15 int fallthru = 2; // fallthru
16 case 2:
17 int fallthrough = 2; // fall thru
18 case 3:
19 break;
20 case 4:
21 int fallthru2 = 3;
22 // fall - thru
23 case 5: // violation 'Fall\ through from previous branch of the switch statement.'
24 int fallthru3 = 4; // This is a fallthru comment
25 case 6:
26 int fallthru4 = 5; // falldown
27 default: // violation 'Fall\ through from previous branch of the switch statement.'
28 }
29 }
30
31 void multipleCasesOnOneLine() {
32 int i = 0;
33 switch (i) {
34 case 0: case 1: i *= i; // fall through
35 case 2: case 3: i *= i; // fall through
36 case 4: case 5: i *= i; // fall through
37 case 6: case 7: i *= i;
38 break;
39 default:
40 throw new RuntimeException();
41 }
42 }
43
44 void method() {
45 int i=0;
46 switch (i) {
47 case 0:
48 break;
49 case 1:
50 // fall through
51 i++;
52 case 2: // violation 'Fall\ through from previous branch of the switch statement'
53 break;
54 }
55 }
56
57 void method2() {
58 int i=0;
59 switch (i) {
60 case 0:
61 break;
62 case 1: // random
63 // fall through
64 i++;
65 case 2: // violation 'Fall\ through from previous branch of the switch statement'
66 break;
67 }
68 }
69
70 void method3() {
71 int i=0;
72 switch (i) {
73 case 0:
74 break;
75 case 1: /* random */
76 // fall through
77 // non fall
78 /* comment */
79 i++;
80 case 2: // violation 'Fall\ through from previous branch of the switch statement'
81 break;
82 }
83 }
84
85 void method4() {
86 int i=0;
87 switch (i) {
88 case 0:
89 break;
90 case 1: // random
91 /* fallthru */
92 // comment
93 i++;
94 case 2: // violation 'Fall\ through from previous branch of the switch statement'
95 break;
96 }
97 }
98
99 void method5() {
100 int i=0;
101 switch (i) {
102 case 0:
103 break;
104 case 1:
105 // random
106 // fall through
107 // comment
108 System.out.println("check");
109 case 2: // violation 'Fall\ through from previous branch of the switch statement'
110 break;
111 }
112 }
113 }