1
2
3
4
5
6
7
8
9
10
11 package com.puppycrawl.tools.checkstyle.checks.coding.variabledeclarationusagedistance;
12
13 import java.util.HashSet;
14 import java.util.Set;
15
16 public class InputVariableDeclarationUsageDistanceIfStatements {
17 void method2() {
18 int a = 12;
19 if (true) {
20 method2();
21 checkIfStatementWithoutParen();
22 method2();
23 a++;
24 }
25 }
26
27 void checkIfStatementWithoutParen() {
28 int a = 12;
29 method2();
30 if (true)
31 a++;
32 int b = 12;
33 method2();
34 if (false)
35 method2();
36 else if(true)
37 b++;
38 int c = 12;
39 method2();
40 checkIfStatementWithoutParen();
41 if (true)
42 c++;
43 else
44 method2();
45 }
46
47 void testConsecutiveIfStatements() {
48 int a = 12;
49 int b = 13;
50 int c = 14;
51 int d = 15;
52 if (true)
53 a++;
54 if (true)
55 b++;
56 if (false)
57 c++;
58 if (true)
59 d++;
60 }
61
62 int testReturnStatement() {
63 int a = 1;
64 testConsecutiveIfStatements();
65 testConsecutiveIfStatements();
66 testConsecutiveIfStatements();
67 if (true)
68 return a;
69
70 return 0;
71 }
72 }