View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="NeedBraces">
5         <property name="tokens" value="LITERAL_CASE, LITERAL_DEFAULT"/>
6         <property name="allowSingleLineStatement" value="true"/>
7       </module>
8     </module>
9   </module>
10  */
11  
12  package com.puppycrawl.tools.checkstyle.checks.blocks.needbraces;
13  
14  // xdoc section -- start
15  class Example4 {
16    String obj = new String();
17    String value = new String();
18    int counter = 1;
19    int count = 0;
20    int num = 12;
21    String o = "O";
22    public boolean Example4() {
23  
24      if (obj.equals(num)) return true;
25      // ok above, because IF is not a target of validation
26      if (true) {
27        count = 2;
28      } else
29          // ok above, because ELSE is not a target of validation
30          return false;
31      for (int i = 0; i < 5; i++) {
32        ++count;}
33      do // ok, because DO is not a target of validation
34          ++count;
35      while (false);
36      for (int j = 0; j < 10; j++);
37      // ok above, because FOR is not a target of validation
38      for(int i = 0; i < 10; value.charAt(12));
39      // ok above, because FOR is not a target of validation
40      while (counter < 10)
41          // ok above, because WHILE is not a target of validation
42          ++count;
43      while (value.charAt(12) < 5);
44      // ok above, because WHILE is not a target of validation
45      switch (num) {
46        case 1: counter++; break;
47      }
48      return true;
49    }
50  }
51  // xdoc section -- end