aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputDesignForExtensionOverridableMethods.java
blob: 8453755061dddcd5d0d663752564294f50b0c0fc (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package com.puppycrawl.tools.checkstyle.checks.design;

public class InputDesignForExtensionOverridableMethods {

    public class A {
        public int foo1(int a, int b) {return a + b;} // violation

        public void foo2() { }

        public void foo3(int a, int b) { }

        private int foo4(int a, int b) {return a + b;}

        public void foo5() {
            // single line comment is not counted as a content
        }

        public void foo6() {
            /**
             * javadoc block comment is not counted as a content
             */
        }

        public void foo7() {
            /*
             * block comment is not counted as a content
             */
        }

        public int foo8(int a, int b) { // violation
            // single line comment before content
            return a + b;
        }

        public int foo9(int a, int b) { // violation
            /*
             * block comment before content
             */
            return a + b;
        }

        public int foo10(int a, int b) { // violation
            /**
             * javadoc block comment before content
             */
            return a + b;
        }

        public int foo11(int a, int b) { // violation
            return a + b;
            // single line comment after content
        }

        public int foo12(int a, int b) { // violation
            return a + b;
            /*
             * block comment after content
             */
        }

        public int foo13(int a, int b) { // violation
            return a + b;
            /**
             * javadoc block comment after content
             */
        }

        protected int foo14(int a) {return a -1;} // violation

        public final int foo15(int a) {return a - 2;}

        protected final int foo16(int a) {return a - 2;}

        /** Javadoc comment */
        protected int foo17(int a) {return a -1;}

        /** Method javadoc */
        public void foo18() { }

        /** Method javadoc */
        public int foo19() {return 1;}

        /** */
        public final int foo20(int a) {return a - 2;}

        /** */
        protected final int foo21(int a) {return a - 2;}

        // Single line comment
        public void foo22() { // violation
            return;
        }

        // Single line comments
        // organized in a block
        public void foo23() { // violation
            return;
        }

        // Single line comments
        // organized in a block
        public void foo24() {}

        /* Block comment */
        public void foo25() {
            return;
        }

        // Single line comment
        @Deprecated // violation
        public void foo26() {
            return;
        }

        // Single line comments
        // organized in a block
        @Deprecated // violation
        public void foo27() {
            return;
        }

        /** Javadoc comment */
        @Deprecated
        public void foo28() {
            return;
        }

        /* Block comment */
        @Deprecated
        public void foo29() {
            return;
        }

        /**
         * Returns maximum of a and b.
         * @param a a.
         * @param b b.
         * @return maximum of a and b.
         */
        public int max(int a, int b) {
            return Math.max(a, b);
        }

        /** */
        public int foo30() {
            /** */
            return 1;
        }

        /* */
        public int foo31() {
            /** */
            return 1;
        }

        /** */
        public int foo32() {
            /* */
            return 1;
        }

        @Deprecated
        /** */
        public int foo33() {
            return 1;
        }

        @Deprecated
        /* */
        public int foo34() {
            return 1;
        }

        @Deprecated
        /* */
        public void foo35() { }

        @Deprecated
        /** */
        public void foo36() { }

        @Deprecated
        /** */
        public void foo37() { /** */ }

        @Deprecated
        // comment
        public void foo38() { }

        @Deprecated /** */
        public void foo39() {return; }

        /**
         * @param indent indentation to check.
         * @return true if {@code indent} less then minimal of
         *         acceptable indentation levels, false otherwise.
         */
        public boolean isGreaterThan(int indent) {
            return indent == 2;
        }

        /**
         * Sets whether to process JavaDoc or not.
         *
         * @param value Flag for processing JavaDoc.
         */
        public void setProcessJavadoc(boolean value) {
            value = true;
        }
    }

    public final class B {
        public int foo1(int a, int b) {return a + b;}

        protected int foo2(int a, int b) {return a + b;}

        public final int foo3(int a, int b) {return a + b;}

        protected final int foo4(int a, int b) {return a + b;}
    }

    public abstract class C {
        public abstract void foo1(int a);
    }
}