View Javadoc
1   /*
2   MagicNumber
3   ignoreNumbers =
4   ignoreHashCodeMethod = (default)false
5   ignoreAnnotation = true
6   ignoreFieldDeclaration = (default)false
7   ignoreAnnotationElementDefaults = (default)true
8   constantWaiverParentToken = (default)TYPECAST, METHOD_CALL, EXPR, ARRAY_INIT, UNARY_MINUS, \
9                               UNARY_PLUS, ELIST, STAR, ASSIGN, PLUS, MINUS, DIV, LITERAL_NEW
10  tokens = (default)NUM_DOUBLE, NUM_FLOAT, NUM_INT, NUM_LONG
11  
12  
13  */
14  
15  package com.puppycrawl.tools.checkstyle.checks.coding.magicnumber;
16  
17  class InputMagicNumberIgnoreNone3 {
18  
19      public int hashCode() {
20          return 31; // violation
21      }
22  
23  
24      public int hashCode(int val) {
25          return 42; // violation
26      }
27  
28  
29      public int hashcode() {
30          return 13; // violation
31      }
32  
33      static {
34          int x=21; // violation
35      }
36  
37      {
38          int y=37; // violation
39      }
40  
41      public InputMagicNumberIgnoreNone3() {
42          int z=101; // violation
43      }
44  
45      @InputMagicNumberIntMethodAnnotation(42)
46      public void another() {
47      }
48  
49      @InputMagicNumberIntMethodAnnotation(value=43)
50      public void another2() {
51      }
52  
53      @InputMagicNumberIntMethodAnnotation(-44)
54      public void anotherNegative() {
55      }
56  
57      @InputMagicNumberIntMethodAnnotation(value=-45)
58      public void anotherNegative2() {
59      }
60  }
61  
62  class TestMethodCallIgnoreNone3 {
63  
64          public TestMethodCallIgnoreNone3(int x){
65  
66      }
67  
68          public void method2() {
69          final TestMethodCallIgnoreNone3 dummyObject = new TestMethodCallIgnoreNone3(62);
70          }
71  }
72  
73  class BinaryIgnoreNone3 {
74      int intValue = 0b101; // violation
75      long l = 0b1010000101000101101000010100010110100001010001011010000101000101L; // violation
76  }
77  @interface AnnotationWithDefaultValueIgnoreNone3 {
78      int value() default 101;
79      int[] ar() default {102};
80  }
81  class AIgnoreNone3 {
82      {
83          switch (Blah2IgnoreNone1.LOW) {
84          default:
85              int b = 122; // violation
86          }
87      }
88  }