1
2
3
4
5
6
7 package com.puppycrawl.tools.checkstyle.checks.coding.unusedlocalvariable;
8
9 import java.io.BufferedReader;
10 import java.io.FileReader;
11 import java.io.IOException;
12
13 public enum InputUnusedLocalVariableEnum {
14
15 CONST_1,
16 CONST_2(new a() {
17 }),
18 CONST_3(new a() {
19 });
20
21 InputUnusedLocalVariableEnum(Object obj) {
22 int a = 12;
23 a = (int) obj;
24 }
25
26 InputUnusedLocalVariableEnum() {
27 }
28
29 public static class nestedClass {
30 int d = 12;
31 }
32
33 public class innerClass {
34 int k = 1;
35 }
36
37 public void testTryWithResources(int a) {
38 try (BufferedReader br =
39 new BufferedReader(new FileReader("someFile.txt"))) {
40 br.readLine();
41 }
42 catch (IOException e) {
43 e.printStackTrace();
44 }
45 }
46
47 static int a = 12;
48
49 public void testIncrementAndDecrementKinds() {
50 int a = 0;
51 a = ++this.a;
52 a++;
53 a--;
54 int index = 1;
55 int[] arr = {1};
56 arr[--index] = 3;
57 int ind = 0;
58 testTryWithResources(--ind);
59 int k = 1;
60 if (++k > 12) {
61 }
62 int p = 2;
63 if ((++p - --p) > 21) {
64 }
65 int m = 2;
66 int h = ++m;
67 h += 1;
68 }
69
70 public void testBooleanExpressions() {
71 boolean b = false;
72 if (!b) {
73 }
74 boolean b1 = true;
75 if (b1) {
76 }
77 boolean a;
78 if ((a = true) != false) {
79 }
80 boolean j;
81 if (j = true) {
82 }
83 boolean k = true, l = false;
84 if (k && !l) {
85 }
86 }
87 }
88
89 class a {
90
91 void method() {
92 int d = 12;
93 InputUnusedLocalVariableEnum.nestedClass obj =
94 new InputUnusedLocalVariableEnum.nestedClass() {
95 void method() {
96 d += 12;
97 }
98 };
99 obj.getClass();
100 }
101 }