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