View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule4861blockcommentstyle;
2   
3   /** Contains examples of using comments at the end of the block. */
4   public class InputFormattedCommentsIndentationCommentIsAtTheEndOfBlock {
5   
6     /** some javadoc. */
7     public void foo1() {
8       foo2();
9       // OOOO: missing functionality
10    }
11  
12    /** some javadoc. */
13    public void foo2() {
14  
15      foo3();
16      // odd indentation comment
17    }
18  
19    /** some javadoc. */
20    public void foo3() {
21      foo2();
22      // refreshDisplay();
23    }
24  
25    /** some javadoc. */
26    public void foo4() {
27      foooooooooooooooooooooooooooooooooooooooooo();
28      // ^-- some hint
29    }
30  
31    /** some javadoc. */
32    public void foooooooooooooooooooooooooooooooooooooooooo() {}
33  
34    /////////////////////////////// odd indentation comment
35  
36    /** some javadoc. */
37    public void foo7() {
38  
39      int a = 0;
40      // odd indentation comment
41    }
42  
43    /////////////////////////////// (a single-line border to separate a group of methods)
44  
45    /** some javadoc. */
46    public void foo8() {}
47  
48    /** some javadoc. */
49    public class TestClass {
50      /** some javadoc. */
51      public void test() {
52  
53        int a = 0;
54        // odd indentation comment
55      }
56      // odd indentation comment
57    }
58  
59    /** some javadoc. */
60    public void foo9() {
61  
62      this.foo1();
63      // odd indentation comment
64    }
65  
66    //    public void foo10() {
67    //
68    //    }
69  
70    /** some javadoc. */
71    public void foo11() {
72      String.valueOf(new Integer(0)).trim().length();
73      // comment
74    }
75  
76    /** some javadoc. */
77    public void foo12() {
78  
79      String.valueOf(new Integer(0)).trim().length();
80      // odd indentation comment
81    }
82  
83    /** some javadoc. */
84    public void foo13() {
85      String.valueOf(new Integer(0)).trim().length();
86      // comment
87    }
88  
89    /** some javadoc. */
90    public void foo14() {
91  
92      String.valueOf(new Integer(0)).trim().length();
93      // odd indentation comment
94    }
95  
96    /** some javadoc. */
97    public void foo15() {
98      String.valueOf(new Integer(0));
99      // comment
100   }
101 
102   /** some javadoc. */
103   public void foo16() {
104 
105     String.valueOf(new Integer(0));
106     // odd indentation comment
107   }
108 
109   /** some javadoc. */
110   public void foo17() {
111     String.valueOf(new Integer(0))
112         .trim()
113         // comment
114         .length();
115   }
116 
117   /** some javadoc. */
118   public void foo18() {
119 
120     String.valueOf(new Integer(0))
121         .trim()
122         // odd indentation comment
123         .length();
124   }
125 
126   /** some javadoc. */
127   public void foo19() {
128     (new Thread(
129             new Runnable() {
130               @Override
131               public void run() {}
132             }))
133         .run();
134     // comment
135   }
136 
137   /** some javadoc. */
138   public void foo20() {
139 
140     (new Thread(
141             new Runnable() {
142               @Override
143               public void run() {}
144             }))
145         .run();
146     // odd indentation comment
147   }
148 
149   /** some javadoc. */
150   public void foo21() {
151     int[] array = new int[5];
152 
153     java.util.List<String> expected = new java.util.ArrayList<>();
154     for (int i = 0; i < 5; i++) {
155       org.junit.Assert.assertEquals(expected.get(i), array[i]);
156     }
157     String s =
158         String.format(
159             java.util.Locale.ENGLISH,
160             "The array element "
161                 + "immediately following the end of the collection should be nulled",
162             array[1]);
163     // the above example was taken from hibernate-orm and was modified a bit
164   }
165 
166   /** some javadoc. */
167   public void foo22() {
168     int[] array = new int[5];
169 
170     java.util.List<String> expected = new java.util.ArrayList<>();
171     for (int i = 0; i < 5; i++) {
172       org.junit.Assert.assertEquals(expected.get(i), array[i]);
173     }
174 
175     String s =
176         String.format(
177             java.util.Locale.ENGLISH,
178             "The array element "
179                 + "immediately following the end of the collection should be nulled",
180             array[1]);
181     // odd indentation comment
182   }
183 
184   /** some javadoc. */
185   public void foo23() {
186     new Object();
187     // comment
188   }
189 
190   /** some javadoc. */
191   public void foo24() {
192 
193     new Object();
194     // odd indentation comment
195   }
196 
197   /** some javadoc. */
198   public String foo25() {
199     return String.format(java.util.Locale.ENGLISH, "%d", 1);
200     // comment
201   }
202 
203   /** some javadoc. */
204   public String foo26() {
205 
206     return String.format(java.util.Locale.ENGLISH, "%d", 1);
207     // odd indentation comment
208   }
209 
210   /** some javadoc. */
211   public void foo27() {
212     // comment
213     // block
214     foo17();
215 
216     // OOOO
217   }
218 
219   /** some javadoc. */
220   public String foo28() {
221     int a = 5;
222     return String.format(java.util.Locale.ENGLISH, "%d", 1);
223     // comment
224   }
225 
226   /** some javadoc. */
227   public String foo29() {
228     int a = 5;
229 
230     return String.format(java.util.Locale.ENGLISH, "%d", 1);
231     // odd indentation comment
232   }
233 
234   /** some javadoc. */
235   public void foo30() {
236     // comment
237 
238     int a = 5;
239     // odd indentation comment
240   }
241 
242   /** some javadoc. */
243   public void foo31() {
244     String s = new String("A" + "B" + "C");
245     // comment
246   }
247 
248   /** some javadoc. */
249   public void foo32() {
250 
251     String s = new String("A" + "B" + "C");
252     // odd indentation comment
253   }
254 
255   /** some javadoc. */
256   public void foo33() {
257     // comment
258 
259     this.foo22();
260     // odd indentation comment
261   }
262 
263   /** some javadoc. */
264   public void foo34() throws Exception {
265     throw new Exception("", new Exception());
266     // comment
267   }
268 
269   /** some javadoc. */
270   public void foo35() throws Exception {
271 
272     throw new Exception("", new Exception());
273     // odd indentation comment
274   }
275 
276   /** some javadoc. */
277   public void foo36() throws Exception {
278 
279     throw new Exception("", new Exception());
280     // odd indentation comment
281   }
282 
283   /** some javadoc. */
284   public void foo37() throws Exception {
285     throw new Exception("", new Exception());
286     // comment
287   }
288 
289   /** some javadoc. */
290   public void foo38() throws Exception {
291 
292     throw new Exception("", new Exception());
293     // odd indentation comment
294   }
295 
296   /** some javadoc. */
297   public void foo39() throws Exception {
298 
299     throw new Exception("", new Exception());
300     // odd indentation comment
301   }
302 
303   /** some javadoc. */
304   public void foo40() throws Exception {
305     int a = 88;
306 
307     throw new Exception("", new Exception());
308     // odd indentation comment
309   }
310 
311   /** some javadoc. */
312   public void foo41() throws Exception {
313     int a = 88;
314     throw new Exception("", new Exception());
315     // comment
316   }
317 
318   /** some javadoc. */
319   public void foo42() {
320     int a = 5;
321     if (a == 5) {
322       int b;
323       // comment
324     } else if (a == 6) {
325       /* foo */
326     }
327   }
328 
329   /** some javadoc. */
330   public void foo43() {
331     try {
332       int a;
333       // comment
334     } catch (Exception e) {
335       /* foo */
336     }
337   }
338 
339   /** some javadoc. */
340   public void foo44() {
341     int ar = 5;
342     // comment
343     ar = 6;
344     // comment
345   }
346 
347   /** some javadoc. */
348   public void foo45() {
349     int ar = 5;
350     // comment
351 
352     ar = 6;
353     // odd indentation comment
354   }
355 
356   /** some javadoc. */
357   public void foo46() {
358 
359     // comment
360     // block
361     // odd indentation comment
362   }
363 
364   /** some javadoc. */
365   public void foo47() {
366     int a = 5;
367     // comment
368     // block
369     // comment
370   }
371 
372   /** some javadoc. */
373   public void foo48() {
374 
375     int a = 5;
376     // comment
377     // block
378     // odd indentation comment
379   }
380 
381   /** some javadoc. */
382   public void foo49() {
383     // comment
384     // block
385     // ok
386   }
387 
388   /** some javadoc. */
389   public void foo50() {
390     return;
391 
392     // No NPE here!
393   }
394 
395   /** some javadoc. */
396   public String foo51() {
397 
398     return String.valueOf("11");
399     // odd indentation comment
400   }
401 
402   /** some javadoc. */
403   public String foo52() {
404     return String.valueOf("11");
405     // comment
406   }
407 
408   // We almost reached the end of the class here.
409 }
410 // The END of the class.