Skip to content

Commit 821e194

Browse files
committed
Replace CheckMessageVerifierRule with JavaCheckVerifier
1 parent d853262 commit 821e194

219 files changed

Lines changed: 1922 additions & 2571 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

java-checks/src/test/files/checks/AnonymousClassesTooBigCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private void f() { // 2
1717
} // 6
1818
}; // 7
1919

20-
new Comparable<T>() { // 21
20+
new Comparable<T>() { // Noncompliant {{Reduce this anonymous class number of lines from 21 to at most 20, or make it a named class.}}
2121

2222
@Override
2323
private void f(int a, int b) {
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
class A {
2+
private void f() {
3+
int a = new Comparable();
4+
5+
new Comparable<T>() { // 1
6+
private void f() { // 2
7+
System.out.println(); // 3
8+
System.out.println(); // 4
9+
} // 5
10+
}; // 6
11+
12+
new Comparable<T>() { // Noncompliant {{Reduce this anonymous class number of lines from 7 to at most 6, or make it a named class.}}
13+
private void f() { // 2
14+
System.out.println(); // 3
15+
System.out.println(); // 4
16+
System.out.println(); // 5
17+
} // 6
18+
}; // 7
19+
20+
new Comparable<T>() { // Noncompliant {{Reduce this anonymous class number of lines from 21 to at most 6, or make it a named class.}}
21+
22+
@Override
23+
private void f(int a, int b) {
24+
if (a == b) {
25+
return 0;
26+
}
27+
28+
return a < b;
29+
}
30+
31+
private void g() {
32+
System.out.println();
33+
System.out.println();
34+
System.out.println();
35+
System.out.println();
36+
System.out.println();
37+
return;
38+
}
39+
40+
};
41+
42+
Callable<Integer> c0 = ()-> {
43+
return 1;
44+
};
45+
Callable<Integer> c1 = ()-> { // Noncompliant {{Reduce this lambda expression number of lines from 8 to at most 6.}}
46+
System.out.println();
47+
System.out.println();
48+
System.out.println();
49+
System.out.println();
50+
System.out.println();
51+
return 1;
52+
};
53+
54+
Callable<Integer> c1 = ()-> 1 + 2;
55+
Callable<Integer> c1 = ()-> 1 + 2+ // Noncompliant {{Reduce this lambda expression number of lines from 7 to at most 6.}}
56+
2 +
57+
3 * 4 +
58+
5+
59+
3+
60+
1+
61+
1;
62+
63+
Runnable r2 = () -> System.out.println("Hello world two!");
64+
65+
Predicate<Person> allDraftees =
66+
p ->
67+
p.getAge() >= 18
68+
&& p.getAge() <= 25
69+
&& p.getGender() == Gender.MALE;
70+
71+
List<Person> pl = Person.createShortList();
72+
pl.forEach(p -> {
73+
System.out.println(p.printCustom(r ->
74+
"Name: " + r.getGivenName() + " EMail: " + r.getEmail()));
75+
});
76+
}
77+
}
78+
79+
public enum SizeUnit {
80+
81+
BYTES {
82+
@Override
83+
public long toBytes(long size) {
84+
return size;
85+
}
86+
87+
@Override
88+
public long toKB(long size) {
89+
return size / (C1 / C0);
90+
}
91+
92+
@Override
93+
public long toMB(long size) {
94+
return size / (C2 / C0);
95+
}
96+
97+
@Override
98+
public long toGB(long size) {
99+
return size / (C3 / C0);
100+
}
101+
};
102+
103+
public abstract long toBytes(long size);
104+
public abstract long toKB(long size);
105+
public abstract long toMB(long size);
106+
public abstract long toGB(long size);
107+
108+
private static final long C0 = 1L;
109+
private static final long C1 = C0 * 1024L;
110+
private static final long C2 = C1 * 1024L;
111+
private static final long C3 = C2 * 1024L;
112+
113+
}
114+
115+
@interface plop {
116+
117+
118+
}

java-checks/src/test/files/checks/ClassCouplingCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Foo { // Noncompliant - depends on too many other classes
1+
class Foo { // Noncompliant {{Split this class into smaller and more specialized ones to reduce its dependencies on other classes from 21 to the maximum authorized 20 or less.}}
22
T1 a1; // Foo is coupled to T1
33
T2 a2; // Foo is coupled to T2
44
T3 a3; // Foo is coupled to T3
@@ -141,7 +141,7 @@ class Qex { // Compliant
141141
int a21;
142142
}
143143

144-
class Plop { // Noncompliant
144+
class Plop { // Noncompliant {{Split this class into smaller and more specialized ones to reduce its dependencies on other classes from 21 to the maximum authorized 20 or less.}}
145145
List<T1> a1;
146146
List<T2> a2;
147147
List<T3> a3;
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
class Foo {
2+
T1 a1; // Foo is coupled to T1
3+
T2 a2; // Foo is coupled to T2
4+
T3 a3; // Foo is coupled to T3
5+
T4 a4; // etc.
6+
T5 a6;
7+
T6 a6;
8+
T7 a7;
9+
T8 a8;
10+
T9 a9;
11+
T10 a10;
12+
T11 a11;
13+
T12 a12;
14+
T13 a13;
15+
T14 a14;
16+
T15 a15;
17+
T16 a16;
18+
T17 a17;
19+
T18 a18;
20+
T19 a19;
21+
T20 a20;
22+
T21 a21; // Counted just once
23+
T21 a21; // Counted just once
24+
T21 a21; // Counted just once
25+
T21 a21; // Counted just once
26+
}
27+
28+
class Bar {
29+
T1 a1;
30+
T2 a2;
31+
}
32+
33+
class Baz { // Noncompliant {{Split this class into smaller and more specialized ones to reduce its dependencies on other classes from 23 to the maximum authorized 22 or less.}}
34+
T1 a1;
35+
T2 a2;
36+
T3 a3;
37+
T4 a4;
38+
T5 a6;
39+
T6 a6;
40+
T7 a7;
41+
T8 a8;
42+
T9 a9;
43+
T10 a10;
44+
T11 a11;
45+
T12 a12;
46+
T13 a13;
47+
T14 a14;
48+
T15 a15;
49+
T16 a16;
50+
T17 a17;
51+
T18 a18;
52+
T19 a19;
53+
T20 a20;
54+
T21 a21;
55+
T22 a22;
56+
T23 a23;
57+
}
58+
59+
class Qix {
60+
class Bar {
61+
T1 a1;
62+
T2 a2;
63+
T3 a3;
64+
T4 a4;
65+
T5 a6;
66+
T6 a6;
67+
T7 a7;
68+
T8 a8;
69+
T9 a9;
70+
T10 a10;
71+
T11 a11;
72+
T12 a12;
73+
T13 a13;
74+
T14 a14;
75+
T15 a15;
76+
T16 a16;
77+
T17 a17;
78+
T18 a18;
79+
T19 a19;
80+
T20 a20;
81+
T21 a21;
82+
}
83+
}
84+
85+
class Qux {
86+
T1 a1;
87+
T2 a2;
88+
T3 a3;
89+
T4 a4;
90+
T5 a6;
91+
T6 a6;
92+
T7 a7;
93+
T8 a8;
94+
T9 a9;
95+
T10 a10;
96+
97+
class Bar {
98+
}
99+
100+
T11 a11;
101+
T12 a12;
102+
T13 a13;
103+
T14 a14;
104+
T15 a15;
105+
T16 a16;
106+
T17 a17;
107+
T18 a18;
108+
T19 a19;
109+
T20 a20;
110+
T21 a21;
111+
}
112+
113+
enum Qax {
114+
;
115+
116+
T1 foo() {
117+
}
118+
}
119+
120+
class Qex {
121+
T1 a1;
122+
T2 a2;
123+
T3 a3;
124+
T4 a4;
125+
T5 a6;
126+
T6 a6;
127+
T7 a7;
128+
T8 a8;
129+
T9 a9;
130+
T10 a10;
131+
T11 a11;
132+
T12 a12;
133+
T13 a13;
134+
T14 a14;
135+
T15 a15;
136+
T16 a16;
137+
T17 a17;
138+
short a18;
139+
float a19;
140+
double a20;
141+
int a21;
142+
}
143+
144+
class Plop {
145+
List<T1> a1;
146+
List<T2> a2;
147+
List<T3> a3;
148+
List<T4> a4;
149+
List<T5> a6;
150+
List<T6> a6;
151+
List<T7> a7;
152+
List<T8> a8;
153+
List<T9> a9;
154+
List<T10> a10;
155+
List<T11> a11;
156+
List<T12> a12;
157+
List<T13> a13;
158+
List<T14> a14;
159+
List<T15> a15;
160+
List<T16> a16;
161+
List<T17> a17;
162+
List<T18> a18;
163+
List<T19> a19;
164+
List<T20> a20;
165+
}
166+
167+
class Tmp<T1, T2> {
168+
void m() {
169+
try {} catch (Exception1 | Exception2 e) {} // not covered...
170+
171+
Object o;
172+
org.foo.T1 t1 = (org.foo.T1) o;
173+
T2 t2 = new T2(o);
174+
T3 t3 = new <Integer> T3(o);
175+
T4 t4 = new T4<Integer>(o);
176+
T5<? extends T4> t5 = new T5<T4>(o);
177+
T6 t6 = (T6) o;
178+
T7 t7 = (T7) o;
179+
T8 t8 = (T8) o;
180+
T9 t9 = (T9) o;
181+
T10 t10 = (T10) o;
182+
T11 t11 = (T11) o;
183+
T12 t12 = (T12) o;
184+
T13 t13 = (T13) o;
185+
T14 t14 = (T14) o;
186+
T15 t15 = (T15) o;
187+
T16 t16 = new T16() {
188+
void foo() {}
189+
};
190+
T17[] t17 = new T17[3];
191+
boolean t18 = 0 instanceof T18;
192+
}
193+
}

0 commit comments

Comments
 (0)