View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
2   
3   class InputLeftCurlyBraces
4   { //warn
5       /** @return helper func **/
6       boolean condition()
7       { //warn
8           return false;
9       }
10  
11      /** Test do/while loops **/
12      void testDoWhile()
13      { //warn
14  
15          do {
16              testDoWhile();
17          }
18          while (condition());
19  
20  
21          do testDoWhile(); while (condition());
22      }
23  
24      /** Test while loops **/
25      void testWhile()
26      { //warn
27  
28          while (condition()) {
29              testWhile();
30          }
31  
32  
33          while(condition());
34          while (condition())
35              testWhile();
36          while (condition())
37              if (condition())
38                  testWhile();
39      }
40  
41      /** Test for loops **/
42      void testFor()
43      {  //warn
44  
45          for (int i = 1; i < 5; i++) {
46              testFor();
47          }
48  
49  
50          for(int i = 1;i < 5;i++);
51          for (int i = 1; i < 5; i++)
52              testFor();
53          for (int i = 1; i < 5;
54               i++)
55              if (i > 2)
56                  testFor();
57      }
58  
59      /** Test if constructs **/
60      public void testIf()
61      { //warn
62  
63          if (condition()) {
64              testIf();
65          }
66          else if (condition()) {
67              testIf();
68          }
69          else {
70              testIf();
71          }
72  
73  
74          if (condition());
75          if (condition())
76              testIf();
77          if (condition())
78              testIf();
79          else
80              testIf();
81          if (condition())
82              testIf();
83          else {
84              testIf();
85          }
86          if (condition()) {
87              testIf();
88          }
89          else
90              testIf();
91          if (condition())
92              if (condition())
93                  testIf();
94      }
95  
96      void whitespaceAfterSemi()
97      { //warn
98  
99          int i = 1;int j = 2;
100 
101 
102         for (;;) {
103         }
104     }
105 
106     /** Empty constructor block. **/
107     public InputLeftCurlyBraces() {}
108 
109     /** Empty method block. **/
110     public void emptyImplementation() {}
111 }
112 
113 class EnumContainerLeft {
114     private enum Suit { CLUBS, HEARTS, SPADES, DIAMONDS } // ok
115 }
116 
117 class WithArraysLeft { // ok
118     String[] s = {""}; // ok
119     String[] empty = {}; // ok
120     String[] s1 = { // ok
121         "foo", "foo",
122     };
123     String[] s2 =
124         { // ok
125             "foo", "foo",
126         };
127     String[] s3 =
128         { // ok
129             "foo",
130             "foo",
131         };
132     String[] s4 =
133         {"foo", "foo"}; // ok
134 }