Skip to content

Commit 86e5c95

Browse files
netdpbError Prone Team
authored and
Error Prone Team
committed
Optimization: Abort class scan in JUnit4TestNotRun if all suspicious methods have been excluded.
PiperOrigin-RevId: 737675199
1 parent c139e7f commit 86e5c95

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/JUnit4TestNotRun.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,14 @@ public Description matchClass(ClassTree tree, VisitorState state) {
110110
suspiciousMethods.put(getSymbol(methodTree), methodTree);
111111
}
112112
}
113-
if (suspiciousMethods.isEmpty()) {
114-
return NO_MATCH;
115-
}
116113
tree.accept(
117114
new TreeScanner<Void, Void>() {
115+
@Override
116+
public Void scan(Tree tree, Void unused) {
117+
// stop when there are no more suspicious methods
118+
return suspiciousMethods.isEmpty() ? null : super.scan(tree, null);
119+
}
120+
118121
@Override
119122
public Void visitMethodInvocation(
120123
MethodInvocationTree methodInvocationTree, Void unused) {

0 commit comments

Comments
 (0)