View Javadoc
1   /*
2   SuppressionCommentFilter
3   offCommentFormat = UNUSED OFF\\: (\\w+)
4   onCommentFormat = UNUSED ON\\: (\\w+)
5   checkFormat = Unused
6   messageFormat = ^Unused \\w+ '$1'.$
7   idFormat = (default)(null)
8   checkCPP = (default)true
9   checkC = (default)true
10  
11  
12  com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck
13  id = ignore
14  format = (default)^[a-z][a-zA-Z0-9]*$
15  applyToPublic = (default)true
16  applyToProtected = (default)true
17  applyToPackage = (default)true
18  applyToPrivate = (default)true
19  
20  
21  com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck
22  id = (null)
23  format = (default)^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$
24  applyToPublic = (default)true
25  applyToProtected = (default)true
26  applyToPackage = (default)true
27  applyToPrivate = (default)true
28  
29  
30  com.puppycrawl.tools.checkstyle.checks.coding.IllegalCatchCheck
31  illegalClassNames = (default)Error, Exception, RuntimeException, Throwable, java.lang.Error, \
32                      java.lang.Exception, java.lang.RuntimeException, java.lang.Throwable
33  
34  
35  */
36  
37  package com.puppycrawl.tools.checkstyle.filters.suppressioncommentfilter;
38  
39  /**
40   * Test input for using comments to suppress violations.
41   * @author Rick Giles
42   **/
43  class InputSuppressionCommentFilter9
44  {
45      private int I; // violation
46  
47      /* CHECKSTYLE:OFF */
48      private int J; // violation
49      /* CHECKSTYLE:ON */
50  
51      private int K; // violation
52  
53      //CSOFF: MemberNameCheck|ConstantNameCheck
54      private int L; // violation
55      private static final int m = 0; // violation
56      /*
57       * CSON: MemberNameCheck|ConstantNameCheck
58       */
59      private int M2;//CSOFF: ConstantNameCheck // violation
60      private static final int n = 0; // violation
61      //CSON: ConstantNameCheck
62  
63      //CS_OFF
64      private int P; // violation
65      //CS_ON
66  
67      private int Q; // violation
68  
69      //CS_OFF: ConstantNameCheck
70      private int R; // violation
71      private static final int s = 0; // violation
72      //CS_ON
73  
74      //CHECKSTYLE:OFF
75      private int T; // violation
76      //CHECKSTYLE:ON
77  
78      //UNUSED OFF: aInt
79      public static void doit1(int aInt)
80      {
81      }
82      //UNUSED ON: aInt
83      public static void doit2(int aInt)
84      {
85      }
86  
87      public void doit3()
88      {
89          try {
90              // lots of code omitted
91              for(int i = 0; i < 10; i++) {
92                  // more code omitted
93                  while(true) {
94                      try {
95                          //CHECKSTYLE:OFF
96                      } catch(Exception e) { // violation
97                         //CHECKSTYLE:ON
98                      }
99                  }
100                 // code omitted
101             }
102             //CHECKSTYLE:OFF
103         } catch(Exception ex) { // violation
104             //CHECKSTYLE:ON
105         }
106 
107         try{
108             //IllegalCatchCheck OFF: Exception
109         } catch(RuntimeException ex){ // violation
110         } catch(Exception ex){ // violation
111             //IllegalCatchCheck ON: Exception
112         }
113     }
114 
115     public void doit4() {
116         try {
117 
118         /* CHECKSTYLE:OFF */} catch(Exception e) {/* CHECKSTYLE:ON */ // violation
119 
120         }
121     }
122 }