View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="MagicNumber">
5         <property name="tokens" value="NUM_DOUBLE, NUM_FLOAT"/>
6         <property name="ignoreNumbers" value="0, 0.5, 1"/>
7         <property name="ignoreFieldDeclaration" value="true"/>
8         <property name="ignoreAnnotation" value="true"/>
9       </module>
10    </module>
11  </module>
12  */
13  
14  package com.puppycrawl.tools.checkstyle.checks.coding.magicnumber;
15  
16  // xdoc section -- start
17  @Example2.Annotation(6)
18  public class Example2 {
19    private int field = 7;
20  
21    void method1() {
22      int i = 1;
23      int j = 8;
24    }
25    public void method2() {
26      final TestClass testObject = new TestClass(62);
27      final int a = 3;
28      final int[] b = {4, 5};
29      final int c = -3;
30      final int d = +4;
31      final int e = method3(10, 20);
32      final int f = 3 * 4;
33      final int g = 3 / 4;
34      final int h = 3 + 4;
35      final int i = 3 - 4;
36      final int j = (int) 3.4;
37    }
38    private int method3(int a, int b) {
39      return a + b;
40    }
41    public int hashCode() {
42      return 10;
43    }
44    @interface Annotation {
45      int value() default 10;
46      int[] value2() default {10};
47    }
48    class TestClass {
49      TestClass(int field) {}
50    }
51  }
52  // xdoc section -- end