View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // Test case file for checkstyle.
3   ////////////////////////////////////////////////////////////////////////////////
4   
5   package com.puppycrawl.tools.checkstyle.filters.suppresswarningsfilter;
6   
7   /**
8    * Test input for using comments to suppress errors.
9    *
10   * @author Trevor Robinson
11   **/
12  @SuppressWarnings("foo") // coverage: no following AST
13  class InputSuppressWarningsFilter
14  {
15      // AST coverage
16      @SuppressWarnings("foo") interface I { }
17      @SuppressWarnings("foo") enum E { }
18      @SuppressWarnings("foo") InputSuppressWarningsFilter() { }
19      @SuppressWarnings("foo") @interface A { }
20  
21      // include a non-checkstyle suppression; suppression on same line
22      @SuppressWarnings("unused") private int I; // should fail MemberNameCheck
23      @SuppressWarnings({"membername"})
24      private int J; // should NOT fail MemberNameCheck
25      private int K; // should fail MemberNameCheck
26  
27      // DO NOT REFORMAT: L and X should be on the same line
28      @SuppressWarnings(value="membername")
29      private int L; private int X; // L should NOT fail, X should
30  
31      // test "checkstyle:" prefix
32      @SuppressWarnings("checkstyle:ConstantName")
33      private static final int m = 0; // should NOT fail ConstantNameCheck
34      private static final int n = 0; // should fail ConstantNameCheck
35  
36      // test explicit warning alias
37      @SuppressWarnings("paramnum")
38      // should NOT fail ParameterNumberCheck
39      public void needsLotsOfParameters(@SuppressWarnings("unused") int a,
40          int b, int c, int d, int e, int f, int g, int h)
41      {
42          @SuppressWarnings("unused") int z;
43          try {
44          }
45          catch (Exception ex) {
46              // should fail IllegalCatchCheck
47          }
48      }
49  
50      // test fully qualified annotation name
51      @java.lang.SuppressWarnings("illegalCatch")
52      public void needsToCatchException()
53      {
54          try {
55          }
56          catch (Exception ex) {
57              // should NOT fail IllegalCatchCheck
58          }
59      }
60  
61      enum AnEnum {
62          @SuppressWarnings("rawtypes")
63          ELEMENT;
64      }
65      private static final String UNUSED="UnusedDeclaration";
66  
67      @SuppressWarnings(UNUSED)
68      public void annotationUsingStringConstantValue(){
69      }
70  
71      @SuppressWarnings("checkstyle:uncommentedmain")
72      public static void main(String[] args) {
73  
74      }
75  
76      static class TestClass1 {
77          @SuppressWarnings("uncommentedmain")
78          public static void main(String[] args) {
79  
80          }
81      }
82  
83      static class TestClass2 {
84          @SuppressWarnings("UncommentedMain")
85          public static void main(String[] args) {
86  
87          }
88      }
89  
90      static class TestClass3 {
91          @SuppressWarnings("checkstyle:UncommentedMain")
92          public static void main(String[] args) {
93  
94          }
95      }
96  
97      @SuppressWarnings("checkstyle:javadoctype")
98      public static abstract class Task {
99      }
100 }