View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="DescendantToken">
5         <property name="tokens" value="METHOD_DEF"/>
6         <property name="limitedTokens" value="VARIABLE_DEF"/>
7         <property name="maximumDepth" value="2"/>
8         <property name="maximumNumber" value="1"/>
9       </module>
10    </module>
11  </module>
12  */
13  package com.puppycrawl.tools.checkstyle.checks.descendanttoken;
14  
15  // xdoc section -- start
16  class Example8 {
17    void testMethod1() {
18      int var1 = 1;
19    }
20    void testMethod2() { // violation 'Count of 2 for 'METHOD_DEF' descendant'
21      int var1 = 1;
22      int var2 = 2;
23    }
24  
25    int testMethod3(int x) {
26      if (x == -1) {
27        return -1;
28      }
29      else if (x == 0) {
30        return 0;
31      }
32      return -1;
33    }
34    int testMethod4(int x) {
35      if (x == -1) {
36        return -1;
37      }
38      else if (x == 0) {
39        return 0;
40      }
41      else {
42        return x;
43      }
44    }
45  }
46  // xdoc section -- end
47