View Javadoc
1   /*
2   SuppressWarnings
3   format = ^unchecked$*
4   tokens = (default)CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, \
5            ENUM_CONSTANT_DEF, PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, CTOR_DEF, \
6            COMPACT_CTOR_DEF, RECORD_DEF
7   
8   
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.annotation.suppresswarnings;
12  
13  import java.lang.annotation.Documented;
14  
15  // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
16  @SuppressWarnings("unchecked")
17  public class InputSuppressWarningsSingle3
18  {
19      @SuppressWarnings("   ")
20      class Empty {
21  
22          @SuppressWarnings("")
23          public Empty() {
24  
25          }
26      }
27  
28      @SuppressWarnings("unused")
29      enum Duh {
30  
31          @SuppressWarnings("unforgiven")
32          D;
33  
34          public static void foo() {
35  
36              @SuppressWarnings("unused")
37              Object o = new InputSuppressWarningsSingle3() {
38  
39                  @Override
40                  @SuppressWarnings("unchecked")
41                  // violation above, 'The warning 'unchecked' cannot be suppressed at this location'
42                  public String toString() {
43                      return "";
44                  }
45              };
46          }
47      }
48  
49      @SuppressWarnings("abcun")
50      @Documented
51      @interface Sweet {
52          int cool();
53      }
54  
55      @Documented
56      @SuppressWarnings("abcun")
57      @interface MoreSweetness {
58  
59          @SuppressWarnings("unused")
60          int cool();
61      }
62  
63      public class Junk {
64  
65          @SuppressWarnings("")
66          int a = 1;
67  
68          // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
69          @SuppressWarnings("unchecked")
70          @Deprecated
71          int b = 1;
72          void doFoo(String s, @SuppressWarnings("unchecked")String y) {
73              // violation above, 'The warning 'unchecked' cannot be suppressed at this location'
74  
75          }
76      }
77  
78      // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
79      @SuppressWarnings((false) ? "unchecked" : "")
80      class Cond {
81  
82          // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
83          @SuppressWarnings((false) ? "" : "unchecked")
84          public Cond() {
85  
86          }
87  
88          // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
89          @SuppressWarnings((false) ? (true) ? "   " : "unused" : "unchecked")
90          public void aCond1() {
91  
92          }
93  
94          // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
95          @SuppressWarnings((false) ? "unchecked" : (true) ? "   " : "unused")
96          public void aCond2() {
97  
98          }
99  
100         // violation below, 'The warning 'unchecked' cannot be suppressed at this location'
101         @java.lang.SuppressWarnings((false) ? "unchecked" :
102                 ("" == "") ? (false) ? (true) ? "" : "foo" : "    " : "unused")
103         public void seriously() {
104 
105         }
106     }
107 }