-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
InputRequireThisAnonymousEmpty.java
92 lines (73 loc) · 1.73 KB
/
InputRequireThisAnonymousEmpty.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
RequireThis
checkFields = (default)true
checkMethods = (default)true
validateOnlyOverlapping = false
*/
package com.puppycrawl.tools.checkstyle.checks.coding.requirethis;
public class InputRequireThisAnonymousEmpty {
private int bar;
int a;
interface AnonWithEmpty {
public void fooEmpty();
}
void method() {
AnonWithEmpty foo = new AnonWithEmpty() {
public void emptyMethod() {
}
@Override
public void fooEmpty() {
int a = doSideEffect(); // violation
}
public int doSideEffect() {
return bar; // violation
}
};
new AnonWithEmpty() {
int anonMember = 0;
@Override
public void fooEmpty() {
new AnonWithEmpty() {
@Override
public void fooEmpty() {
anonMember++;
}
};
}
};
new AnonWithEmpty() {
int foobar = 1;
@Override
public void fooEmpty() {
foobar++; // violation
}
};
}
void method2() {
int a = 1;
InputRequireThisAnonymousEmpty obj =
new InputRequireThisAnonymousEmpty() {
void method() {
a += 1;
}
};
}
void anotherMethod() {
int var1 = 12;
int var2 = 13;
Foo obj = new Foo() {
void method() {
var2 += var1;
}
};
obj.getClass();
}
}
class SharkFoo {
int var1 = 12;
}
class Foo {
int var2 = 13;
class SharkFoo {
}
}