View Javadoc
1   /*
2   SuppressWithNearbyCommentFilter
3   commentFormat = (default)SUPPRESS CHECKSTYLE (\\w+)
4   checkFormat = (default).*
5   messageFormat = (default)(null)
6   idFormat = (default)(null)
7   influenceFormat = (default)0
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.suppresswithnearbycommentfilter;
38  
39  /**
40   * Test input for using comments to suppress violations.
41   *
42   * @author Mick Killianey
43   */
44  public class InputSuppressWithNearbyCommentFilter {
45      // filtered violation below
46      private int A1;  // SUPPRESS CHECKSTYLE MemberNameCheck
47  
48      // filtered violation below
49      private int A2;  /* SUPPRESS CHECKSTYLE MemberNameCheck */
50      /* SUPPRESS CHECKSTYLE MemberNameCheck */ private int A3; // filtered violation
51  
52      // filtered violation below
53      private int B1;  // SUPPRESS CHECKSTYLE MemberNameCheck
54  
55      // filtered violation below
56      private int B2;  /* SUPPRESS CHECKSTYLE MemberNameCheck */
57      /* SUPPRESS CHECKSTYLE MemberNameCheck */ private int B3; // filtered violation
58  
59      private int C1; // violation
60      // ALLOW MemberName ON NEXT LINE
61      private int C2; // violation
62      private int C3; // violation
63  
64      private int D1; // violation
65      private int D2; // violation
66      // ALLOW MemberName ON PREVIOUS LINE
67      private int D3; // violation
68  
69      private static final int e1 = 0; // violation
70      private int E2; // violation
71  
72      // violation below
73      private int E3;    // ALLOW ConstantName UNTIL THIS LINE+2
74      private static final int e4 = 0; // violation
75      private int E5; // violation
76      private static final int e6 = 0; // violation
77      private int E7; // violation
78      private int E8;    /* ALLOW MemberName UNTIL THIS LINE-3 */
79      // violation above
80      private static final int e9 = 0; // violation
81  
82      // ALLOW Unused UNTIL THIS LINE+5
83      public static void doit1(int aInt) { // this is +1
84      }
85  
86      public static void doit2(int aInt) { // this is +5
87      }
88  
89      public static void doit3(int aInt) { // this is +9
90      }
91  
92      public void doit4() {
93          try {
94              // blah blah blah
95              for(int i = 0; i < 10; i++) {
96                  // blah blah blah
97                  while(true) {
98                      try {
99                          // blah blah blah
100                     } catch(Exception e) { // violation
101                         // bad bad bad
102                     } catch (Throwable t) { // violation
103                         // ALLOW CATCH Throwable BECAUSE I threw this together.
104                     }
105                 }
106                 // blah blah blah
107             }
108             // blah blah blah
109         } catch(Exception ex) { // violation
110             // ALLOW CATCH Exception BECAUSE I am an exceptional person.
111         }
112     }
113 }
114 
115 class Magic {
116     // filtered violation below
117     /* SUPPRESS CHECKSTYLE MemberNameCheck */ private int A2;/* SUPPRESS CHECKSTYLE MemberName ol */
118     private int A1; // violation
119 }