aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputOneTopLevelClass.java
blob: 56b1f599bb20ab97373f58519a882dc6038e72b1 (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
package com.puppycrawl.tools.checkstyle.checks.design;

public class InputOneTopLevelClass
{
    static final int FOO2 = 3;

    // error public before package
    public static final int FOO = 3;
    
    private static final int FOO3 = 3;
   
    // eror public before package and private
    public static final int FOO4 = 3;

    private static final String ERROR = "error";

    // error protected before private
    protected static final String ERROR1 = "error";
   
    // error public before private
    public static final String WARNING = "warning";
    
    private int mMaxInitVars = 3;
    
    // error statics should be before instance members
    // error publics before private
    public static final int MAX_ITER_VARS = 3;

    private class InnerClass
    {
        private static final int INNER_FOO = 2;
       
        // error public before private
        public static final int INNER_FOO2 = 2;

        public InnerClass()
        {
            int foo = INNER_FOO;
            foo += INNER_FOO2;
            foo += INNER_FOO3;
        }

        // error member variables should be before methods or ctors
        // error public before private
        public static final int INNER_FOO3 = 2;
    }

    public int getFoo1()
    {
        return mFoo;
    }

    //  error ctors before methods
    public InputOneTopLevelClass()
    {
        String foo = ERROR;
        foo += ERROR1;
        foo += WARNING;
        int fooInt = mMaxInitVars;
        fooInt += MAX_ITER_VARS;
        fooInt += mFoo;
    }

    public static int getFoo2()
    {
        return 13;
    }

    public int getFoo()
    {
        return mFoo;
    }

    private static int getFoo21()
    {
        return 14;
    }

    // error member variables should be before methods or ctors
    private int mFoo = 0;
}