View Javadoc
1   /*
2   ExecutableStatementCount
3   max = (default)30
4   tokens = (default)CTOR_DEF, METHOD_DEF, INSTANCE_INIT, STATIC_INIT, COMPACT_CTOR_DEF, LAMBDA
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.sizes.executablestatementcount;
10  
11  public class InputExecutableStatementCountDefaultConfig {
12      public void foo() { // ok
13          while (true) {
14              Runnable runnable = new Runnable() { // ok
15                  public void run() {
16                      while (true) {
17                      }
18                  }
19              };
20  
21              new Thread(runnable).start();
22          }
23      }
24  
25      public void bar() { // ok
26          if (System.currentTimeMillis() == 0) {
27              if (System.currentTimeMillis() == 0 && System.currentTimeMillis() == 0) {
28              }
29  
30              if (System.currentTimeMillis() == 0 || System.currentTimeMillis() == 0) {
31              }
32          }
33      }
34  
35      public void simpleElseIf() { // ok
36          if (System.currentTimeMillis() == 0) {
37          } else if (System.currentTimeMillis() == 0) {
38          } else {
39          }
40      }
41  
42      public void stupidElseIf() { // ok
43          if (System.currentTimeMillis() == 0) {
44          } else {
45              if (System.currentTimeMillis() == 0) {
46              } else {
47                  if (System.currentTimeMillis() == 0) {
48                  }
49              }
50  
51              if (System.currentTimeMillis() == 0) {
52              }
53          }
54      }
55  
56      public InputExecutableStatementCountDefaultConfig() // ok
57      {
58          int i = 1;
59          if (System.currentTimeMillis() == 0) {
60          } else if (System.currentTimeMillis() == 0) {
61          } else {
62          }
63      }
64  
65      // STATIC_INIT
66      static { // ok
67          int i = 1;
68          if (System.currentTimeMillis() == 0) {
69          } else if (System.currentTimeMillis() == 0) {
70          } else {
71          }
72      }
73  
74      // INSTANCE_INIT
75      { // ok
76          int i = 1;
77          if (System.currentTimeMillis() == 0) {
78          } else if (System.currentTimeMillis() == 0) {
79          } else {
80          }
81      }
82  
83      /** Inner */
84      public InputExecutableStatementCountDefaultConfig(int aParam) // ok
85      {
86          Runnable runnable = new Runnable() {
87              public void run() {// ok
88                  while (true) {
89                  }
90              }
91          };
92          new Thread(runnable).start();
93      }
94  
95      /** Empty constructor */
96      public InputExecutableStatementCountDefaultConfig(String someString) {} // ok
97  
98      static Runnable r1 = () -> { // ok
99          String.valueOf("Hello world one!");
100     };
101 }