View Javadoc
1   /*
2   SuppressionXpathSingleFilter
3   files = (default)(null)
4   checks = (default)(null)
5   message = (default)(null)
6   id = (default)(null)
7   query = /COMPILATION_UNIT/CLASS_DEF[./IDENT \
8           [@text='InputSuppressionXpathSingleFilterComplexQuery']]/OBJBLOCK/METHOD_DEF[./IDENT \
9           [@text='countTokens']]/SLIST/VARIABLE_DEF[./IDENT[@text='pi']] \
10          /ASSIGN/EXPR/NUM_FLOAT[@text='3.14']
11  
12  com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck
13  ignoreNumbers = (default)-1, 0, 1, 2
14  ignoreHashCodeMethod = (default)false
15  ignoreAnnotation = (default)false
16  ignoreFieldDeclaration = (default)false
17  ignoreAnnotationElementDefaults = (default)true
18  constantWaiverParentToken = (default)TYPECAST, METHOD_CALL, EXPR, ARRAY_INIT, UNARY_MINUS, \
19                              UNARY_PLUS, ELIST, STAR, ASSIGN, PLUS, MINUS, DIV, LITERAL_NEW
20  tokens = (default)NUM_DOUBLE, NUM_FLOAT, NUM_INT, NUM_LONG
21  
22  */
23  package com.puppycrawl.tools.checkstyle.filters.suppressionxpathsinglefilter;
24  
25  public class InputSuppressionXpathSingleFilterComplexQuery {
26      private int countTokens() {
27          double pi = 3.14; // filtered violation
28          return 123; // violation
29      }
30  
31      public String getName() {
32          int someVariable = 123; // violation
33          return "InputSuppressByXpathThree";
34      }
35  
36      public int sum(int a, int b) {
37          String someVariable = "Hello World";
38          return a + b;
39      }
40  
41  }