1 /*xml
2 <module name="Checker">
3 <module name="TreeWalker">
4 <module name="NeedBraces"/>
5 </module>
6 </module>
7 */
8
9 package com.puppycrawl.tools.checkstyle.checks.blocks.needbraces;
10
11 // xdoc section -- start
12 class Example1 {
13 String obj = new String();
14 String value = new String();
15 int counter = 1;
16 int count = 0;
17 int num = 12;
18 String o = "O";
19 public boolean Example1() {
20 if (obj.equals(num)) return true;
21 // violation above, ''if' construct must use '{}'s.'
22 if (true) {
23 count = 2;
24 } else
25 // violation above, ''else' construct must use '{}'s.'
26 return false;
27 for (int i = 0; i < 5; i++) {
28 ++count;}
29 do // violation, ''do' construct must use '{}'s.'
30 ++count;
31 while (false);
32 for (int j = 0; j < 10; j++);
33 // violation above, ''for' construct must use '{}'s.'
34 for(int i = 0; i < 10; value.charAt(12));
35 // violation above, ''for' construct must use '{}'s.'
36 while (counter < 10)
37 // violation above, ''while' construct must use '{}'s.'
38 ++count;
39 while (value.charAt(12) < 5);
40 // violation above, ''while' construct must use '{}'s.'
41 switch (num) {
42 case 1: counter++; break;
43 // ok above, because break in case blocks is not counted to allow compact view
44 }
45 return true;
46 }
47 }
48
49
50
51
52
53
54 // xdoc section -- end