aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputCommentsIndentationInEmptyBlock.java
blob: d566ea07cca626951138855540cd7a9079828b32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.puppycrawl.tools.checkstyle.checks.indentation;

public class InputCommentsIndentationInEmptyBlock {

    private void foo1() {
        int a = 5, b = 3, v = 6;
        if (a == b
            && v == b || ( a ==1
                   /// violation
                       /* violation
                        * one fine day ... */
                               && b == 1)   ) {
            // Cannot clearly detect user intention of explanation target.
        }
    }

    private void foo2() {
        int a = 5, b = 3, v = 6;
        if (a == b
            && v == b || ( a ==1
            && b == 1)   ) {


             // comment
        }
    }

    private void foo3() {
        int a = 5, b = 3, v = 6;
        if (a == b
            && v == b || (a == 1
            && b == 1)) {
// violation
        }
    }

    // Comments here should be ok by Check
    @SuppressWarnings("unused") // trailing
    private static void foo4() { // trailing
        if (true) // trailing comment
        {
            // some comment
        }
        if (true) { // trailing comment

        }
        /**
         *
         */
    }

    // Comments here should be ok by Check
    @SuppressWarnings("unused") // trailing
    private static void foo5() { // trailing
        if (true) // trailing comment
        {
// violation
        }
        if (true) { // trailing comment

        }
        /**
         *
         */
    }

    public void foo6() {
        try {

        } catch (Exception e) {
// violation
        }
    }

    public void foo7() {
        try {

        } catch (Exception e) {
            // TODO: handle exception here
        }
    }

    private static class MyClass extends Object {
           // no members
    }

    private static class MyClass1 extends Object {

           // no members
    }

    public void foo8() {
        String[] array1 = {
                // comment
        };
        String[] array2 = {
                    // comment
        };
        String[] array3 = {
        // comment
        };
        String[] array4 = {
// violation
        };
        String[] array5 = {

// violation
        };
    }
}