1
2
3
4
5
6
7
8
9
10
11 package com.puppycrawl.tools.checkstyle.checks.blocks.needbraces;
12
13 class InputNeedBracesTestItWithAllowsOn
14 {
15
16 boolean condition()
17 {
18 return false;
19 }
20
21
22 void testDoWhile()
23 {
24
25 do {
26 testDoWhile();
27 }
28 while (condition());
29
30
31 do testDoWhile(); while (condition());
32 }
33
34
35 void testWhile()
36 {
37
38 while (condition()) {
39 testWhile();
40 }
41
42
43 while(condition());
44 while (condition())
45 testWhile();
46 while (condition())
47 if (condition())
48 testWhile();
49 }
50
51
52 void testFor()
53 {
54
55 for (int i = 1; i < 5; i++) {
56 testFor();
57 }
58
59
60 for(int i = 1;i < 5;i++);
61 for (int i = 1; i < 5; i++)
62 testFor();
63 for (int i = 1; i < 5;
64 i++)
65 if (i > 2)
66 testFor();
67 }
68
69
70 public void testIf()
71 {
72
73 if (condition()) {
74 testIf();
75 }
76 else if (condition()) {
77 testIf();
78 }
79 else {
80 testIf();
81 }
82
83
84 if (condition());
85 if (condition())
86 testIf();
87 if (condition())
88 testIf();
89 else
90 testIf();
91 if (condition())
92 testIf();
93 else {
94 testIf();
95 }
96 if (condition()) {
97 testIf();
98 }
99 else
100 testIf();
101 if (condition())
102 if (condition())
103 testIf();
104
105 if (condition())
106 while (condition()) testWhile();
107 if (condition())
108 do testDoWhile(); while (condition());
109 if (condition())
110 for (int i = 0; i < 1; i++) testFor();
111 int a = 0;
112 switch (a) {default: {}}
113 }
114
115 void whitespaceAfterSemi()
116 {
117
118 int i = 1;int j = 2;
119
120
121 for (;;) {
122 }
123 }
124
125
126 public InputNeedBracesTestItWithAllowsOn() {}
127
128
129 public void emptyImplementation() {}
130
131 public void method() {
132 if (true
133 || true || true) return;
134 }
135 }