aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/InputSuppressWarningsFilter.java
blob: e26982223e315eee9b1257de262939336a9de87d (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
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
////////////////////////////////////////////////////////////////////////////////

package com.puppycrawl.tools.checkstyle.filters.suppresswarningsfilter;

/**
 * Test input for using comments to suppress errors.
 *
 * @author Trevor Robinson
 **/
@SuppressWarnings("foo") // coverage: no following AST
class InputSuppressWarningsFilter
{
    // AST coverage
    @SuppressWarnings("foo") interface I { }
    @SuppressWarnings("foo") enum E { }
    @SuppressWarnings("foo") InputSuppressWarningsFilter() { }
    @SuppressWarnings("foo") @interface A { }

    // include a non-checkstyle suppression; suppression on same line
    @SuppressWarnings("unused") private int I; // should fail MemberNameCheck
    @SuppressWarnings({"membername"})
    private int J; // should NOT fail MemberNameCheck
    private int K; // should fail MemberNameCheck

    // DO NOT REFORMAT: L and X should be on the same line
    @SuppressWarnings(value="membername")
    private int L; private int X; // L should NOT fail, X should

    // test "checkstyle:" prefix
    @SuppressWarnings("checkstyle:ConstantName")
    private static final int m = 0; // should NOT fail ConstantNameCheck
    private static final int n = 0; // should fail ConstantNameCheck

    // test explicit warning alias
    @SuppressWarnings("paramnum")
    // should NOT fail ParameterNumberCheck
    public void needsLotsOfParameters(@SuppressWarnings("unused") int a,
        int b, int c, int d, int e, int f, int g, int h)
    {
        @SuppressWarnings("unused") int z;
        try {
        }
        catch (Exception ex) {
            // should fail IllegalCatchCheck
        }
    }

    // test fully qualified annotation name
    @java.lang.SuppressWarnings("illegalCatch")
    public void needsToCatchException()
    {
        try {
        }
        catch (Exception ex) {
            // should NOT fail IllegalCatchCheck
        }
    }

    enum AnEnum {
        @SuppressWarnings("rawtypes")
        ELEMENT;
    }
    private static final String UNUSED="UnusedDeclaration";

    @SuppressWarnings(UNUSED)
    public void annotationUsingStringConstantValue(){
    }

    @SuppressWarnings("checkstyle:uncommentedmain")
    public static void main(String[] args) {

    }

    static class TestClass1 {
        @SuppressWarnings("uncommentedmain")
        public static void main(String[] args) {

        }
    }

    static class TestClass2 {
        @SuppressWarnings("UncommentedMain")
        public static void main(String[] args) {

        }
    }

    static class TestClass3 {
        @SuppressWarnings("checkstyle:UncommentedMain")
        public static void main(String[] args) {

        }
    }

    @SuppressWarnings("checkstyle:javadoctype")
    public static abstract class Task {
    }
}