View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
2   
3   class InputRightCurlyOther
4   {
5       /** @see test method **/
6       int foo() throws InterruptedException
7       {
8           int x = 1;
9           int a = 2;
10          while (true)
11          {
12              try
13              {
14                  if (x > 0)
15                  {
16                      break;
17                  } else if (x < 0) {  //ok
18  
19                      ;
20                  } //warn
21                  else
22                  {
23                      break;
24                  }//ok
25                  switch (a)
26                  {
27                  case 0:
28                      break;
29                  default:
30                      break;
31                  } //ok
32              } //warn
33              catch (Exception e)
34              {
35                  break;
36              }//ok
37          }//ok
38  
39          synchronized (this)
40          {
41              do
42              {
43                  x = 2;
44              } while (x == 2); //ok
45          }//ok
46  
47          this.wait(666
48                   ); // Bizarre, but legal
49  
50          for (int k = 0; k < 1; k++)
51          {
52              String innerBlockVariable = "";
53          }//ok
54  
55  
56          if (System.currentTimeMillis() > 1000)
57              return 1;
58          else
59              return 2;
60      }//ok
61  
62  
63      static
64      {
65          int x = 1;
66      }//ok
67  
68      public enum GreetingsEnum
69      {
70          HELLO,
71          GOODBYE
72      }; //ok
73  
74      void method2()
75      {
76          boolean flag = true;
77          if (flag) {
78              System.identityHashCode("heh");
79              flag = !flag; } System. //warn
80                identityHashCode("Xe-xe");
81  
82  
83          if (flag) { System.identityHashCode("some foo"); }
84      } //ok
85  } //ok
86  
87  /**
88   * Test input for closing brace if that brace terminates
89   * a statement or the body of a constructor.
90   */
91  class FooCtor
92  {
93      int i;
94      public FooCtor()
95      {
96          i = 1;
97      }} // warn
98  
99  /**
100 * Test input for closing brace if that brace terminates
101 * a statement or the body of a method.
102 */
103 class FooMethod
104 {
105     public void fooMethod()
106     {
107         int i = 1;
108     }} // warn
109 
110 /**
111 * Test input for closing brace if that brace terminates
112 * a statement or the body of a named class.
113 */
114 class FooInner
115 {
116     class InnerFoo
117     {
118         public void fooInnerMethod ()
119         {
120 
121         }
122     }} //ok
123 
124 class EnumContainer {
125     private enum Suit { CLUBS, HEARTS, SPADES, DIAMONDS } // ok
126 }
127 
128 class WithArrays {
129     String[] s = {""}; // ok
130     String[] empty = {}; // ok
131     String[] s1 = {
132         "foo", "foo",
133     }; // ok
134     String[] s2 =
135         {
136             "foo", "foo",
137         }; // ok
138     String[] s3 =
139         {
140             "foo",
141             "foo",
142         }; // ok
143     String[] s4 =
144         {"foo", "foo"}; // ok
145 }