1   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
2   
3   class InputRightCurlyAnnotations
4   {
5   
6       @Deprecated
7       @Override
8       public boolean equals(Object other) { boolean flag = true; return flag; } //violation
9   
10      @Override
11      public String toString() { String s = "toString"; return s; } //violation
12  
13      @Override
14      @SuppressWarnings("unused")
15      public int hashCode()
16      {
17          int a = 10;
18          return 1;
19      }
20  
21      @SuppressWarnings("unused")
22      private void foo2() { int a = 9; return; } //violation
23  
24      @SuppressWarnings("unused")
25      private void foo3()
26      { int var1 = 5; var2 = 6; } //violation
27  
28      @Deprecated
29      private void foo4() { return; } //violation
30  
31      @SuppressWarnings("unused")
32      private int foo5() { return 1; } //violation
33  
34      @SuppressWarnings("unused")
35      private String foo6() { return toString();
36      }
37  
38      private String foo7() { String s = toString(); return s.toString(); } //violation
39  
40      private void foo8() { ; return; } //violation
41  
42      private int var1; private int v1;
43      private int var2; private int v2;
44      @SuppressWarnings("unused")
45      public InputRightCurlyAnnotations() { this.var1 = 1; } //violation
46      @SuppressWarnings("unused")
47      public InputRightCurlyAnnotations(int v1, int v2) {this.var1 = v1; this.var2 = v2; } //violation
48  
49      @SuppressWarnings("unused")
50      private void foo9() { ;; } //violation
51  
52      @SuppressWarnings("unused")
53      private void foo10() { ; } //violation
54  
55      @SuppressWarnings("unused")
56      private void foo11() {  } //empty block - violation
57  
58      @SuppressWarnings("unused")
59      private void foo12() {
60          try { int i = 5; int b = 10; } //violation
61          catch (Exception e) { } //empty block - violation
62      }
63  
64      @Deprecated
65      @SuppressWarnings("unused")
66      private void foo13() {
67          for (int i = 0; i < 10; i++) { int a = 5; int b = 6; } //violation
68  
69          do
70          {
71              var1 = 2;
72          }
73          while (var2 == 2);
74      }
75  
76      static { int a; int b; } //violation
77  
78      static { int a; } //violation
79  
80      { int c; int d;} //violation
81  
82      { int c; } //violation
83  
84      @Deprecated
85      private void foo14() {
86          if (var1 > 0) {
87              return;
88          }
89      }
90  
91      @Deprecated
92      private void foo15() {
93          class A { int a; } var1++; //violation
94          class B {  } //empty block - violation
95          if(true) {
96  
97          }
98          else;
99      }
100 
101     @Deprecated
102     private void foo16() {
103         if (true) { return; } else { } //violation
104         if (false) {
105         }
106 
107         if (true) { return; } else { } //violation
108     }
109 
110     @Deprecated
111     void foo17() { int v1 = 5; v2 = 6; } @Deprecated void foo18() {int v1 = 5; v2 = 6; } //violation
112 
113     private void foo19() {int var1 = 5;
114         var2 = 6;} //violation
115 
116     @SuppressWarnings("Hello, world!")
117     private String foo20() {
118         do { var2 ++; } //violation
119         while (var2 < 15);
120 
121         while (var1 < 10) { var1++; } //violation
122 
123         do { var2++; var1++; } while (var2 < 15); return ""+0xCAFEBABE; //violation
124     }
125 
126     private void foo21() {
127         new Object() { @Override protected void finalize() { "".toString(); }}; //violation
128     }
129 
130     @SuppressWarnings("All")
131     void foo22() {
132         long startTime = System.nanoTime();
133         try {
134             int a = 5;
135             toString();
136         } catch (Exception e) { //violation
137             throw new RuntimeException(e);
138         } finally { toString(); } //violation
139     }
140 
141     @SuppressWarnings("")
142     void doDoubleBraceInitialization() {
143         java.util.Map<String, String> map = new java.util.LinkedHashMap<String, String>() {{
144             put("Hello", "World");
145             put("first", "second");
146             put("polygene", "lubricants");
147             put("alpha", "betical");
148         }}; //NO violation
149 
150         Thread t = new Thread() {@Override public void run() {super.run();}}; //violation
151         new Object() { public int hashCode() { return 1; }  { int a = 5; }}; //violation
152         new Object() { public int hashCode() { return 1; }  int b = 10; }; //violation
153         new Object() { public int hashCode() { return 1; }  { int c = 5; } int d = 8; }; //violation
154 
155         java.util.Map<String, String> map2 = new java.util.LinkedHashMap<String, String>() {{
156             put("Hello", "World");
157             put("first", "second");
158             put("polygene", "lubricants");
159             put("alpha", "betical");}  //violation
160         };
161 
162         java.util.Map<String, String> map3 = new java.util.LinkedHashMap<String, String>() {{
163             put("Hello", "World");
164             put("first", "second");
165             put("polygene", "lubricants");
166             put("alpha", "betical");}};  //violation
167 
168         java.util.Map<String, String> map4 = new java.util.LinkedHashMap<String, String>() {{
169             put("Hello", "World");
170             put("first", "second");
171             put("polygene", "lubricants");
172             put("alpha", "betical");
173             }
174         };
175 
176         foo23(new java.util.HashSet<String>() {{
177             add("XZ13s");
178             add("AB21/X");
179             add("YYLEX");
180             add("AR5E");
181         }}); //violation
182 
183         foo23(new java.util.HashSet<String>() {{
184             add("XZ13s");
185             add("AB21/X");
186             add("YYLEX");
187             add("AR5E");
188         }});} //violation
189 
190 
191     void foo23(java.util.HashSet<String> set) {
192     }
193 
194     void foo25() {
195         for (int i = 0; i < 10; i++) {
196             System.identityHashCode("Hello, world!");
197         }} //violation
198 
199     void foo26() {
200         for (int i = 0; i < 10; i++) {
201             System.identityHashCode("Hello, world!");}} //violation
202 
203     void foo27() {
204         for (int i = 0; i < 10; i++) {for (int j = 0; j < 15; j++) {int a;}}} //violation
205 
206     private java.util.ArrayList<Integer> foo28(int delta) {
207         return new java.util.ArrayList<Integer>() {
208         @Override public int size() { return Math.max(0, super.size() + 1);}; //violation
209         };
210     }
211 
212     private void foo29() {
213         boolean flag = true;
214         if (flag) {
215             System.identityHashCode("heh");
216             flag = !flag; } String.CASE_INSENSITIVE_ORDER. //violation
217             equals("Xe-xe");
218     }
219 }