View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule4861blockcommentstyle;
2   
3   /** some javadoc. */
4   public class InputCommentsIndentationInEmptyBlock {
5   
6     private void foo1() {
7       int a = 5;
8       int b = 3;
9       int v = 6;
10      if (a == b && v == b
11              || (a == 1
12              // violation 2 lines below '.* should be the same level as line 18.'
13              // violation 3 lines below '.* should be the same level as line 18.'
14          /// // odd indentation comment
15              //
16                /*   // odd indentation comment
17                 * one fine day ... */
18              && b == 1)) {
19        // Cannot clearly detect user intention of explanation target.
20      }
21    }
22  
23    private void foo2() {
24      int a = 5;
25      int b = 3;
26      int v = 6;
27      if (a == b && v == b || (a == 1 && b == 1)) {
28  
29        // comment
30      }
31    }
32  
33    private void foo3() {
34      int a = 5;
35      int b = 3;
36      int v = 6;
37      if (a == b && v == b || (a == 1 && b == 1)) {
38  // odd indentation comment
39      }
40      // violation 2 lines above '.* indentation should be the same level as line 39.'
41    }
42  
43    // Comments here should be ok by Check
44    @SuppressWarnings("unused") // trailing
45    private static void foo4() { // trailing
46      if (true) { // trailing comment
47        // some comment
48      }
49      if (true) { // trailing comment
50      }
51    }
52  
53    // Comments here should be ok by Check
54    @SuppressWarnings("unused") // trailing
55    private static void foo5() { // trailing
56      if (true) { // trailing comment
57        // violation below '.* indentation should be the same level as line 59.'
58  // odd indentation comment
59      }
60      if (true) { // trailing comment
61      }
62    }
63  
64    /** some javadoc. */
65    public void foo6() {
66      try {
67        /* foo */
68      } catch (Exception e) {
69  // odd indentation comment
70      }
71      // violation 2 lines above '.* indentation should be the same level as line 70.'
72    }
73  
74    /** some javadoc. */
75    public void foo7() {
76      try {
77        /* foo */
78      } catch (Exception e) {
79        // OOOO: handle exception here
80      }
81    }
82  
83    private static class MyClass extends Object {
84      // no members
85    }
86  }