1 /*
2 * ValidIndent.java
3 *
4 * Created on November 6, 2002, 9:39 PM
5 */
6
7 package com.puppycrawl.tools.checkstyle.indentation;
8
9 /**
10 *
11 * @author jrichard
12 */
13 public class InputInvalidIfIndent {
14
15 // ctor with rcurly on same line
16 public InputInvalidIfIndent() {
17 }
18
19 // ctor with rcurly on next line
20 public InputInvalidIfIndent(int dummy)
21 {
22 }
23
24 // method with rcurly on same line
25 public void method() {
26 }
27
28 // method with rcurly on next line
29 public void method2()
30 {
31 }
32
33 // method with a bunch of params
34 public void method2(int x, int y, int w, int h)
35 {
36 }
37
38 // params on multiple lines
39 public void method2(int x, int y, int w, int h,
40 int x1, int y1, int w1, int h1)
41 {
42 }
43
44 // test ifs
45 public void emptyIfTest()
46 {
47 boolean test = true;
48
49 // lcurly on same line
50 if (test) {
51 }
52
53 // lcurly on next line -- if, rcurly indented too far, lcurly not far enough
54 //
55 if (test)
56 {
57 }
58
59 if (test)
60 {
61 }
62
63 // lcurly for if and else on same line -- too much space after if on same line -- ALLOWED
64 if (test) {
65 } else { // this is not allowed
66 }
67
68 // lcurly for if and else on same line
69 if (test)
70 {
71 }
72 else
73 {
74 }
75
76 // lcurly for if and else on same line -- mixed braces
77 if (test) {
78 }
79 else
80 {
81 }
82
83
84 // lcurly for if and else on same line -- mixed braces
85 if (test)
86 {
87 } else
88 {
89 }
90
91 // lcurly for if and else on same line -- mixed braces
92 if (test)
93 {
94 } else {
95 }
96
97 // lcurly for if and else on same line -- mixed braces, unnested
98 if (test) {
99 }
100 else {
101 }
102 }
103
104 ///// same as above, with statements
105 public void populatedIfTest()
106 {
107 boolean test = false;
108 // no braces if
109 if (test)
110 System.getProperty("blah");
111
112 // no braces if/else
113 if (test)
114 System.getProperty("blah");
115 else
116 System.getProperty("blah");
117
118
119 // lcurly on same line, and stmt
120 if (test) {
121 System.getProperty("blah");
122 }
123
124 // lcurly on next line and stmt
125 if (test)
126 {
127 System.getProperty("blah");
128 }
129 // lcurly for if and else on same line
130 if (test) {
131
132 System.
133 getProperty("blah");
134 } else {
135 System.
136 getProperty("blah");
137 }
138
139 // lcurly for if and else on same line
140 if (test)
141 {
142 System.getProperty("blah");
143 System.getProperty("blah");
144 }
145 else
146 {
147 System.getProperty("blah");
148 System.getProperty("blah");
149 }
150
151 // lcurly for if and else on same line -- mixed braces
152 if (test) {
153 System.getProperty("blah");
154 }
155 else
156 {
157 System.getProperty("blah");
158 }
159
160
161 // lcurly for if and else on same line -- mixed braces
162 if (test)
163 {
164 System.getProperty("blah");
165 } else
166 {
167 System.getProperty("blah");
168 }
169
170 // lcurly for if and else on same line -- mixed braces
171 if (test)
172 {
173 System.getProperty("blah");
174 } else {
175 System.getProperty("blah");
176 }
177
178 // lcurly for if and else on same line -- mixed braces, unnested
179 if (test) {
180 System.getProperty("blah");
181 }
182 else {
183 System.getProperty("blah");
184 }
185
186 if (test
187 && 7 < 8 && 8 < 9
188 && 10 < 11) {
189 }
190
191 if (test)
192 return;
193
194 if (test) {
195 } else if (7 < 8) {
196 } else if (8 < 9) {
197 }
198
199 if (test) {
200 System.getProperty("blah");
201 } else if (7 < 8) {
202 System.getProperty("blah");
203 } else if (8 < 9) {
204 System.getProperty("blah");
205 }
206
207
208 if (test)
209 System.getProperty("blah");
210 else if (7 < 8)
211 System.getProperty("blah");
212 else if (8 < 9)
213 System.getProperty("blah");
214
215
216 // TODO: bother to support this style?
217 if (test) {
218 System.getProperty("blah");
219 } else
220 if (7 < 8) {
221 System.getProperty("blah");
222 } else
223 if (8 < 9) {
224 System.getProperty("blah");
225 }
226
227 if (test) {
228 System.getProperty("blah"); }
229 }
230
231 public void parenIfTest() {
232 boolean test = true;
233
234 if (test
235 ) {
236 System.getProperty("blah");
237 }
238
239 if (test
240 )
241 {
242 System.getProperty("blah");
243 }
244
245 if
246 (
247 test
248 ) {
249 System.getProperty("blah");
250 }
251
252 }
253
254 }