View Javadoc
1   /*
2   VariableDeclarationUsageDistance
3   allowedDistance = 1
4   ignoreVariablePattern = (default)
5   validateBetweenScopes = false
6   ignoreFinal = false
7   
8   
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.coding.variabledeclarationusagedistance;
12  
13  public class InputVariableDeclarationUsageDistanceCloseToBlock {
14      void method() {
15          int a = 3; // violation 'Distance between .* declaration and its first usage is 13.'
16          int b = 2; // violation 'Distance between .* declaration and its first usage is 13.'
17  
18          run();
19          run();
20          run();
21          run();
22          run();
23          run();
24          run();
25          run();
26          run();
27          run();
28          run();
29          run();
30  
31          for (int i = 0; i < 10; i++) {
32              a = a + b;
33          }
34      }
35  
36       void method2() {
37          run();
38          run();
39          run();
40          run();
41          run();
42          run();
43          run();
44          run();
45          run();
46          run();
47          run();
48          run();
49  
50          int a = 3;
51          int b = 2;
52  
53          for (int i = 0; i < 10; i++) {
54              a = a + b;  // distance = 1
55          }
56      }
57  
58      public void run() {};
59  }