View Javadoc
1   /*
2   MethodLength
3   max = 2
4   countEmpty = false
5   tokens = (default)METHOD_DEF, CTOR_DEF, COMPACT_CTOR_DEF
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.sizes.methodlength;
10  
11  public class InputMethodLengthCountEmptySmallSize {}
12  class AA {
13      AA() { // ok, 2 lines
14  
15      }
16  
17      AA(int a) { // ok, 2 lines
18          /*
19          my comment
20           */
21          // other comment
22      }
23  
24      AA(String a) {  // violation 'Method .* length is 3 lines (max allowed is 2).'
25          oneLine();
26      }
27  
28      void twoLines() {
29  
30      }
31  
32      void twoLines2() {
33          oneLine();}
34  
35      void twoLinesAndComment() {
36          // some comment
37      }
38  
39      void oneLine() { oneLine();}
40  
41      void threeLines() { // violation 'Method threeLines length is 3 lines (max allowed is 2).'
42          oneLine();
43      }
44  
45      void threeLinesAndComments() { // violation 'Method .* length is 3 lines (max allowed is 2).'
46          // comment above
47          oneLine();
48          /*
49          block comment below
50           */
51      }
52  
53      void threeLinesWrap() // violation 'Method .* length is 3 lines (max allowed is 2).'
54  
55      {
56          // comment above
57          oneLine();
58          /*
59          block comment below
60           */
61      }
62  
63      void m2() { // violation 'Method .* length is 10 lines (max allowed is 2).'
64          String a = "1";
65          a.concat("")
66              .concat("")
67              .concat("")
68              .concat("")
69              .concat("")
70              .concat("")
71              .concat("");
72      }
73  }