View Javadoc
1   /*
2   SuppressWarnings
3   format = (default)^\\s*+$
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  @SuppressWarnings("unchecked")
16  public class InputSuppressWarningsSingle1
17  {
18      // violation below, 'The warning '   ' cannot be suppressed at this location'
19      @SuppressWarnings("   ")
20      class Empty {
21  
22          // violation below, 'The warning '' cannot be suppressed at this location'
23          @SuppressWarnings("")
24          public Empty() {
25  
26          }
27      }
28  
29      @SuppressWarnings("unused")
30      enum Duh {
31  
32          @SuppressWarnings("unforgiven")
33          D;
34  
35          public static void foo() {
36  
37              @SuppressWarnings("unused")
38              Object o = new InputSuppressWarningsSingle1() {
39  
40                  @Override
41                  @SuppressWarnings("unchecked")
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          // violation below, 'The warning '' cannot be suppressed at this location'
66          @SuppressWarnings("")
67          int a = 1;
68  
69          @SuppressWarnings("unchecked")
70          @Deprecated
71          int b = 1;
72          void doFoo(String s, @SuppressWarnings("unchecked")String y) {
73  
74          }
75      }
76  
77      // violation below, 'The warning '' cannot be suppressed at this location'
78      @SuppressWarnings((false) ? "unchecked" : "")
79      class Cond {
80  
81          // violation below, 'The warning '' cannot be suppressed at this location'
82          @SuppressWarnings((false) ? "" : "unchecked")
83          public Cond() {
84  
85          }
86  
87          // violation below, 'The warning '   ' cannot be suppressed at this location'
88          @SuppressWarnings((false) ? (true) ? "   " : "unused" : "unchecked")
89          public void aCond1() {
90  
91          }
92  
93          // violation below, 'The warning '   ' cannot be suppressed at this location'
94          @SuppressWarnings((false) ? "unchecked" : (true) ? "   " : "unused")
95          public void aCond2() {
96  
97          }
98  
99          @java.lang.SuppressWarnings((false) ? "unchecked" :
100                 ("" == "") ? (false) ? (true) ? "" : "foo" : "    " : "unused") // 2 violations
101         public void seriously() {
102 
103         }
104     }
105 }