From 87eec2b619bf038a53ec81895c6d6948dbf1e944 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 18 Dec 2024 07:11:41 -0800 Subject: [PATCH] Enforce `VoidMissingNullable` in testonly code The relaxation was useful to code NullMarked their production sources, but didn't bother with their test code. However, projects that want to check their entire codebase don't have great options as `-XepOpt:Nullness:Conservative` gates a lot of behavior behind it. As we push further into null-marking code, annotating the types in test code will likely be beneficial anyway. PiperOrigin-RevId: 707539601 --- .../bugpatterns/nullness/VoidMissingNullable.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/nullness/VoidMissingNullable.java b/core/src/main/java/com/google/errorprone/bugpatterns/nullness/VoidMissingNullable.java index fe9be25f990..4109e2d3c00 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/nullness/VoidMissingNullable.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/nullness/VoidMissingNullable.java @@ -92,10 +92,6 @@ public Description matchParameterizedType( return NO_MATCH; } - if (beingConservative && state.errorProneOptions().isTestOnlyTarget()) { - return NO_MATCH; - } - if (beingConservative && !isInNullMarkedScope(state)) { return NO_MATCH; } @@ -127,10 +123,6 @@ private static boolean isInNullMarkedScope(VisitorState state) { @Override public Description matchMethod(MethodTree tree, VisitorState state) { - if (beingConservative && state.errorProneOptions().isTestOnlyTarget()) { - return NO_MATCH; - } - MethodSymbol sym = getSymbol(tree); if (!typeMatches(sym.getReturnType(), sym, state)) { return NO_MATCH; @@ -143,10 +135,6 @@ public Description matchMethod(MethodTree tree, VisitorState state) { @Override public Description matchVariable(VariableTree tree, VisitorState state) { - if (beingConservative && state.errorProneOptions().isTestOnlyTarget()) { - return NO_MATCH; - } - if (hasImplicitType(tree, state)) { /* * In the case of `var`, a declaration-annotation @Nullable would be valid. But a type-use