diff options
author | Manu Sridharan <msridhar@gmail.com> | 2022-01-18 12:47:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 12:47:47 -0800 |
commit | b27c6e1ad2e4fb37ac000b8c6feda4789956e9c5 (patch) | |
tree | a3884b3ea44ea198f618dd37974fda6c5ca1ccd7 | |
parent | 55de3a882694251ca1e6659cbe9e8f7dd4092190 (diff) | |
download | nullaway-b27c6e1ad2e4fb37ac000b8c6feda4789956e9c5.tar.gz |
Require braces for all conditionals and loops (#556)
Enable the Error Prone [MissingBraces](http://errorprone.info/bugpattern/MissingBraces) check, and fix all violations.
18 files changed, 123 insertions, 43 deletions
diff --git a/build.gradle b/build.gradle index cbc3eb8..dbc8f51 100644 --- a/build.gradle +++ b/build.gradle @@ -64,6 +64,7 @@ subprojects { project -> // this check is too noisy check("StringSplitter", CheckSeverity.OFF) check("WildcardImport", CheckSeverity.ERROR) + check("MissingBraces", CheckSeverity.ERROR) } } diff --git a/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/BytecodeAnnotator.java b/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/BytecodeAnnotator.java index 247f09e..73c2e1d 100644 --- a/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/BytecodeAnnotator.java +++ b/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/BytecodeAnnotator.java @@ -46,7 +46,9 @@ public final class BytecodeAnnotator { private static boolean debug = false; private static void LOG(boolean cond, String tag, String msg) { - if (cond) System.out.println("[" + tag + "] " + msg); + if (cond) { + System.out.println("[" + tag + "] " + msg); + } } public static final String javaxNullableDesc = "Ljavax/annotation/Nullable;"; diff --git a/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParams.java b/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParams.java index b6bb234..ef7eec0 100644 --- a/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParams.java +++ b/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParams.java @@ -52,7 +52,9 @@ public class DefinitelyDerefedParams { private boolean USE_EXTENDED_APPROACH = true; private static void LOG(boolean cond, String tag, String msg) { - if (cond) System.out.println("[JI " + tag + "] " + msg); + if (cond) { + System.out.println("[JI " + tag + "] " + msg); + } } private final IMethod method; @@ -190,7 +192,9 @@ public class DefinitelyDerefedParams { // Iterate over all instructions in BB for (int i = node.getFirstInstructionIndex(); i <= node.getLastInstructionIndex(); i++) { SSAInstruction instr = ir.getInstructions()[i]; - if (instr == null) continue; // Some instructions are null (padding NoOps) + if (instr == null) { // Some instructions are null (padding NoOps) + continue; + } LOG(DEBUG, "DEBUG", "\tinst: " + instr.toString()); int derefValueNumber = -1; if (instr instanceof SSAGetInstruction && !((SSAGetInstruction) instr).isStatic()) { diff --git a/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParamsDriver.java b/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParamsDriver.java index f6c62cc..469d3d0 100644 --- a/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParamsDriver.java +++ b/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParamsDriver.java @@ -74,7 +74,9 @@ public class DefinitelyDerefedParamsDriver { private static boolean VERBOSE = false; private static void LOG(boolean cond, String tag, String msg) { - if (cond) System.out.println("[JI " + tag + "] " + msg); + if (cond) { + System.out.println("[JI " + tag + "] " + msg); + } } String lastOutPath = ""; @@ -230,8 +232,11 @@ public class DefinitelyDerefedParamsDriver { scope.setExclusions( new FileOfClasses( new ByteArrayInputStream(DEFAULT_EXCLUSIONS.getBytes(StandardCharsets.UTF_8)))); - if (jarIS != null) scope.addInputStreamForJarToScope(ClassLoaderReference.Application, jarIS); - else AnalysisScopeReader.addClassPathToScope(inPath, scope, ClassLoaderReference.Application); + if (jarIS != null) { + scope.addInputStreamForJarToScope(ClassLoaderReference.Application, jarIS); + } else { + AnalysisScopeReader.addClassPathToScope(inPath, scope, ClassLoaderReference.Application); + } AnalysisOptions options = new AnalysisOptions(scope, null); AnalysisCache cache = new AnalysisCacheImpl(); IClassHierarchy cha = ClassHierarchyFactory.makeWithRoot(scope); @@ -241,12 +246,18 @@ public class DefinitelyDerefedParamsDriver { for (IClassLoader cldr : cha.getLoaders()) { if (!cldr.getName().toString().equals("Primordial")) { for (IClass cls : Iterator2Iterable.make(cldr.iterateAllClasses())) { - if (cls instanceof PhantomClass) continue; + if (cls instanceof PhantomClass) { + continue; + } // Only process classes in specified classpath and not its dependencies. // TODO: figure the right way to do this - if (!pkgName.isEmpty() && !cls.getName().toString().startsWith(pkgName)) continue; + if (!pkgName.isEmpty() && !cls.getName().toString().startsWith(pkgName)) { + continue; + } // Skip non-public / ABI classes - if (!cls.isPublic() && !includeNonPublicClasses) continue; + if (!cls.isPublic() && !includeNonPublicClasses) { + continue; + } LOG(DEBUG, "DEBUG", "analyzing class: " + cls.getName().toString()); for (IMethod mtd : Iterator2Iterable.make(cls.getDeclaredMethods().iterator())) { // Skip methods without parameters, abstract methods, native methods @@ -339,9 +350,13 @@ public class DefinitelyDerefedParamsDriver { * @return boolean True if all parameters and return value are of primitive type, otherwise false. */ private static boolean isAllPrimitiveTypes(IMethod mtd) { - if (!mtd.getReturnType().isPrimitiveType()) return false; + if (!mtd.getReturnType().isPrimitiveType()) { + return false; + } for (int i = (mtd.isStatic() ? 0 : 1); i < mtd.getNumberOfParameters(); i++) { - if (!mtd.getParameterType(i).isPrimitiveType()) return false; + if (!mtd.getParameterType(i).isPrimitiveType()) { + return false; + } } return true; } @@ -412,7 +427,9 @@ public class DefinitelyDerefedParamsDriver { for (Map.Entry<String, Set<Integer>> entry : nonnullParams.entrySet()) { String sign = entry.getKey(); Set<Integer> ddParams = entry.getValue(); - if (ddParams.isEmpty()) continue; + if (ddParams.isEmpty()) { + continue; + } Map<Integer, ImmutableSet<String>> argAnnotation = new HashMap<>(); for (Integer param : ddParams) { argAnnotation.put(param, ImmutableSet.of("Nonnull")); @@ -480,7 +497,9 @@ public class DefinitelyDerefedParamsDriver { int argi = mtd.isStatic() ? 0 : 1; // Skip 'this' parameter for (; argi < mtd.getNumberOfParameters(); argi++) { strArgTypes += getSimpleTypeName(mtd.getParameterType(argi)); - if (argi < mtd.getNumberOfParameters() - 1) strArgTypes += ", "; + if (argi < mtd.getNumberOfParameters() - 1) { + strArgTypes += ", "; + } } return classType + ":" @@ -508,7 +527,9 @@ public class DefinitelyDerefedParamsDriver { .put("S", "short") .put("Z", "boolean") .build(); - if (typ.isArrayType()) return "Array"; + if (typ.isArrayType()) { + return "Array"; + } String typName = typ.getName().toString(); if (typName.startsWith("L")) { typName = typName.split("<")[0].substring(1); // handle generics diff --git a/jar-infer/jar-infer-lib/src/test/java/com/uber/nullaway/jarinfer/AnnotationChecker.java b/jar-infer/jar-infer-lib/src/test/java/com/uber/nullaway/jarinfer/AnnotationChecker.java index 2098819..197c3a1 100644 --- a/jar-infer/jar-infer-lib/src/test/java/com/uber/nullaway/jarinfer/AnnotationChecker.java +++ b/jar-infer/jar-infer-lib/src/test/java/com/uber/nullaway/jarinfer/AnnotationChecker.java @@ -113,7 +113,9 @@ public class AnnotationChecker { return false; } List<AnnotationNode>[] paramAnnotations = method.visibleParameterAnnotations; - if (paramAnnotations == null) continue; + if (paramAnnotations == null) { + continue; + } for (List<AnnotationNode> annotations : paramAnnotations) { if (!checkExpectedAnnotations(annotations, expectedToActualAnnotations) && !checkTestMethodParamAnnotationByName(method)) { @@ -207,7 +209,9 @@ public class AnnotationChecker { // Returns the number of times 'annotation' is present in the list 'annotations'. private static int countAnnotations(List<AnnotationNode> annotations, String annotation) { - if (annotations == null) return 0; + if (annotations == null) { + return 0; + } int count = 0; for (AnnotationNode annotationNode : annotations) { if (annotationNode.desc.equals(annotation)) { diff --git a/jar-infer/jar-infer-lib/src/test/java/com/uber/nullaway/jarinfer/JarInferTest.java b/jar-infer/jar-infer-lib/src/test/java/com/uber/nullaway/jarinfer/JarInferTest.java index aa52049..67d5356 100644 --- a/jar-infer/jar-infer-lib/src/test/java/com/uber/nullaway/jarinfer/JarInferTest.java +++ b/jar-infer/jar-infer-lib/src/test/java/com/uber/nullaway/jarinfer/JarInferTest.java @@ -173,13 +173,21 @@ public class JarInferTest { for (Map.Entry<String, Set<Integer>> entry : result.entrySet()) { String mtd_sign = entry.getKey(); Set<Integer> ddParams = entry.getValue(); - if (ddParams.isEmpty()) continue; + if (ddParams.isEmpty()) { + continue; + } Set<Integer> xddParams = expected.get(mtd_sign); - if (xddParams == null) return false; + if (xddParams == null) { + return false; + } for (Integer var : ddParams) { - if (!xddParams.remove(var)) return false; + if (!xddParams.remove(var)) { + return false; + } + } + if (!xddParams.isEmpty()) { + return false; } - if (!xddParams.isEmpty()) return false; expected.remove(mtd_sign); } return expected.isEmpty(); diff --git a/jar-infer/test-android-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Bar.java b/jar-infer/test-android-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Bar.java index 9ea66a3..e763714 100644 --- a/jar-infer/test-android-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Bar.java +++ b/jar-infer/test-android-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Bar.java @@ -5,7 +5,9 @@ public class Bar { public int b; public Bar(String str) { - if (str == null) str = "bar"; + if (str == null) { + str = "bar"; + } this.bar = str; this.b = bar.length(); } diff --git a/jar-infer/test-android-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Foo.java b/jar-infer/test-android-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Foo.java index cf8da08..0d51f74 100644 --- a/jar-infer/test-android-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Foo.java +++ b/jar-infer/test-android-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Foo.java @@ -4,7 +4,9 @@ public class Foo { private String foo; public Foo(String str) { - if (str == null) str = "foo"; + if (str == null) { + str = "foo"; + } this.foo = str; } diff --git a/jar-infer/test-java-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Bar.java b/jar-infer/test-java-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Bar.java index 9ea66a3..e763714 100644 --- a/jar-infer/test-java-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Bar.java +++ b/jar-infer/test-java-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Bar.java @@ -5,7 +5,9 @@ public class Bar { public int b; public Bar(String str) { - if (str == null) str = "bar"; + if (str == null) { + str = "bar"; + } this.bar = str; this.b = bar.length(); } diff --git a/jar-infer/test-java-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Foo.java b/jar-infer/test-java-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Foo.java index 0cd0f70..9d1fae4 100644 --- a/jar-infer/test-java-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Foo.java +++ b/jar-infer/test-java-lib-jarinfer/src/main/java/com/uber/nullaway/jarinfer/toys/unannotated/Foo.java @@ -4,7 +4,9 @@ public class Foo { private String foo; public Foo(String str) { - if (str == null) str = "foo"; + if (str == null) { + str = "foo"; + } this.foo = str; } diff --git a/nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java b/nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java index 3d6dc54..30d66ed 100755 --- a/nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java +++ b/nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java @@ -356,9 +356,10 @@ public class ErrorBuilder { static int getLineNumForElement(Element uninitField, VisitorState state) { Tree tree = getTreesInstance(state).getTree(uninitField); - if (tree == null) + if (tree == null) { throw new RuntimeException( "When getting the line number for uninitialized field, can't get the tree from the element."); + } DiagnosticPosition position = (DiagnosticPosition) tree; // Expect Tree to be JCTree and thus implement DiagnosticPosition TreePath path = state.getPath(); diff --git a/nullaway/src/main/java/com/uber/nullaway/NullAway.java b/nullaway/src/main/java/com/uber/nullaway/NullAway.java index 7b2fd19..2c29da1 100644 --- a/nullaway/src/main/java/com/uber/nullaway/NullAway.java +++ b/nullaway/src/main/java/com/uber/nullaway/NullAway.java @@ -873,7 +873,9 @@ public class NullAway extends BugChecker return false; } else if (methodLambdaOrBlock instanceof MethodTree) { MethodTree methodTree = (MethodTree) methodLambdaOrBlock; - if (isConstructor(methodTree) && !constructorInvokesAnother(methodTree, state)) return true; + if (isConstructor(methodTree) && !constructorInvokesAnother(methodTree, state)) { + return true; + } if (ASTHelpers.getSymbol(methodTree).isStatic()) { Set<MethodTree> staticInitializerMethods = class2Entities.get(enclosingClassSymbol(enclosingBlockPath)).staticInitializerMethods(); diff --git a/nullaway/src/main/java/com/uber/nullaway/dataflow/NullnessStore.java b/nullaway/src/main/java/com/uber/nullaway/dataflow/NullnessStore.java index 97f40b0..3c254a1 100644 --- a/nullaway/src/main/java/com/uber/nullaway/dataflow/NullnessStore.java +++ b/nullaway/src/main/java/com/uber/nullaway/dataflow/NullnessStore.java @@ -129,7 +129,9 @@ public class NullnessStore implements Store<NullnessStore> { * @return The {@link Nullness} value of the access path. */ public Nullness getNullnessOfAccessPath(AccessPath accessPath) { - if (contents == null) return Nullness.NULLABLE; + if (contents == null) { + return Nullness.NULLABLE; + } Nullness nullness = contents.get(accessPath); return (nullness == null) ? Nullness.NULLABLE : nullness; } diff --git a/nullaway/src/main/java/com/uber/nullaway/handlers/CompositeHandler.java b/nullaway/src/main/java/com/uber/nullaway/handlers/CompositeHandler.java index 089b650..0ad99fb 100644 --- a/nullaway/src/main/java/com/uber/nullaway/handlers/CompositeHandler.java +++ b/nullaway/src/main/java/com/uber/nullaway/handlers/CompositeHandler.java @@ -218,7 +218,9 @@ class CompositeHandler implements Handler { Optional<ErrorMessage> optionalErrorMessage; for (Handler h : handlers) { optionalErrorMessage = h.onExpressionDereference(expr, baseExpr, state); - if (optionalErrorMessage.isPresent()) return optionalErrorMessage; + if (optionalErrorMessage.isPresent()) { + return optionalErrorMessage; + } } return Optional.empty(); } diff --git a/nullaway/src/main/java/com/uber/nullaway/handlers/InferredJARModelsHandler.java b/nullaway/src/main/java/com/uber/nullaway/handlers/InferredJARModelsHandler.java index cf343e6..6a2ac38 100644 --- a/nullaway/src/main/java/com/uber/nullaway/handlers/InferredJARModelsHandler.java +++ b/nullaway/src/main/java/com/uber/nullaway/handlers/InferredJARModelsHandler.java @@ -62,7 +62,9 @@ public class InferredJARModelsHandler extends BaseNoOpHandler { private static boolean VERBOSE = false; private static void LOG(boolean cond, String tag, String msg) { - if (cond) System.out.println("[JI " + tag + "] " + msg); + if (cond) { + System.out.println("[JI " + tag + "] " + msg); + } } private static final int VERSION_0_FILE_MAGIC_NUMBER = 691458791; @@ -118,8 +120,9 @@ public class InferredJARModelsHandler extends BaseNoOpHandler { if (path.matches(config.getJarInferRegexStripModelJarName())) { String name = path.replaceAll(config.getJarInferRegexStripModelJarName(), "$1"); LOG(DEBUG, "DEBUG", "model jar name: " + name + "\tjar path: " + path); - if (!mapModelJarLocations.containsKey(name)) + if (!mapModelJarLocations.containsKey(name)) { mapModelJarLocations.put(name, new LinkedHashSet<>()); + } mapModelJarLocations.get(name).add(path); } } @@ -144,10 +147,14 @@ public class InferredJARModelsHandler extends BaseNoOpHandler { "Skipping abstract method: " + className + " : " + methodSymbol.getQualifiedName()); return nonNullPositions; } - if (!lookupAndBuildCache(classSymbol)) return nonNullPositions; + if (!lookupAndBuildCache(classSymbol)) { + return nonNullPositions; + } String methodSign = getMethodSignature(methodSymbol); Map<Integer, Set<String>> methodArgAnnotations = lookupMethodInCache(className, methodSign); - if (methodArgAnnotations == null) return nonNullPositions; + if (methodArgAnnotations == null) { + return nonNullPositions; + } Set<Integer> jiNonNullParams = new LinkedHashSet<>(); for (Map.Entry<Integer, Set<String>> annotationEntry : methodArgAnnotations.entrySet()) { if (annotationEntry.getKey() != RETURN @@ -156,8 +163,9 @@ public class InferredJARModelsHandler extends BaseNoOpHandler { jiNonNullParams.add(annotationEntry.getKey() - (methodSymbol.isStatic() ? 0 : 1)); } } - if (!jiNonNullParams.isEmpty()) + if (!jiNonNullParams.isEmpty()) { LOG(DEBUG, "DEBUG", "Nonnull params: " + jiNonNullParams.toString() + " for " + methodSign); + } return Sets.union(nonNullPositions, jiNonNullParams).immutableCopy(); } @@ -222,7 +230,9 @@ public class InferredJARModelsHandler extends BaseNoOpHandler { if (!argAnnotCache.containsKey(className)) { // this works for aar ! URLConnection uc = klass.classfile.toUri().toURL().openConnection(); - if (!(uc instanceof JarURLConnection)) return false; + if (!(uc instanceof JarURLConnection)) { + return false; + } JarURLConnection juc = (JarURLConnection) uc; jarPath = juc.getJarFileURL().getPath(); LOG(DEBUG, "DEBUG", "Found source of class: " + className + ", jar: " + jarPath); @@ -284,7 +294,9 @@ public class InferredJARModelsHandler extends BaseNoOpHandler { } private Map<Integer, Set<String>> lookupMethodInCache(String className, String methodSign) { - if (!argAnnotCache.containsKey(className)) return null; + if (!argAnnotCache.containsKey(className)) { + return null; + } Map<Integer, Set<String>> methodArgAnnotations = argAnnotCache.get(className).get(methodSign); if (methodArgAnnotations == null) { LOG( @@ -330,9 +342,11 @@ public class InferredJARModelsHandler extends BaseNoOpHandler { } private String getSimpleTypeName(Type typ) { - if (typ.getKind() == TypeKind.TYPEVAR) + if (typ.getKind() == TypeKind.TYPEVAR) { return typ.getUpperBound().tsym.getSimpleName().toString(); - else return typ.tsym.getSimpleName().toString(); + } else { + return typ.tsym.getSimpleName().toString(); + } } private void parseStubStream(InputStream stubxInputStream, String stubxLocation) @@ -398,11 +412,15 @@ public class InferredJARModelsHandler extends BaseNoOpHandler { private void cacheAnnotation(String methodSig, Integer argNum, String annotation) { // TODO: handle inner classes properly String className = methodSig.split(":")[0].replace('$', '.'); - if (!argAnnotCache.containsKey(className)) argAnnotCache.put(className, new LinkedHashMap<>()); - if (!argAnnotCache.get(className).containsKey(methodSig)) + if (!argAnnotCache.containsKey(className)) { + argAnnotCache.put(className, new LinkedHashMap<>()); + } + if (!argAnnotCache.get(className).containsKey(methodSig)) { argAnnotCache.get(className).put(methodSig, new LinkedHashMap<>()); - if (!argAnnotCache.get(className).get(methodSig).containsKey(argNum)) + } + if (!argAnnotCache.get(className).get(methodSig).containsKey(argNum)) { argAnnotCache.get(className).get(methodSig).put(argNum, new LinkedHashSet<>()); + } argAnnotCache.get(className).get(methodSig).get(argNum).add(annotation); } } diff --git a/nullaway/src/main/java/com/uber/nullaway/handlers/OptionalEmptinessHandler.java b/nullaway/src/main/java/com/uber/nullaway/handlers/OptionalEmptinessHandler.java index 568bf35..919ef33 100644 --- a/nullaway/src/main/java/com/uber/nullaway/handlers/OptionalEmptinessHandler.java +++ b/nullaway/src/main/java/com/uber/nullaway/handlers/OptionalEmptinessHandler.java @@ -201,7 +201,9 @@ public class OptionalEmptinessHandler extends BaseNoOpHandler { for (Type optionalType : optionalTypes) { if (symbol.getSimpleName().toString().equals("isPresent") && symbol.getParameters().length() == 0 - && types.isSubtype(symbol.owner.type, optionalType)) return true; + && types.isSubtype(symbol.owner.type, optionalType)) { + return true; + } } return false; } @@ -210,7 +212,9 @@ public class OptionalEmptinessHandler extends BaseNoOpHandler { for (Type optionalType : optionalTypes) { if (symbol.getSimpleName().toString().equals("get") && symbol.getParameters().length() == 0 - && types.isSubtype(symbol.owner.type, optionalType)) return true; + && types.isSubtype(symbol.owner.type, optionalType)) { + return true; + } } return false; } diff --git a/sample/src/main/java/com/uber/mylib/MyClass.java b/sample/src/main/java/com/uber/mylib/MyClass.java index 67bba1e..d4721d7 100644 --- a/sample/src/main/java/com/uber/mylib/MyClass.java +++ b/sample/src/main/java/com/uber/mylib/MyClass.java @@ -7,7 +7,9 @@ import org.utilities.StringUtils; public class MyClass { static void log(@Nullable Object x) { - if (x == null) return; + if (x == null) { + return; + } System.out.println(x.toString()); } diff --git a/test-java-lib-lombok/build.gradle b/test-java-lib-lombok/build.gradle index fad79b9..71b76c2 100644 --- a/test-java-lib-lombok/build.gradle +++ b/test-java-lib-lombok/build.gradle @@ -38,6 +38,7 @@ tasks.withType(JavaCompile) { options.errorprone { check("NullAway", CheckSeverity.ERROR) check("UnusedVariable", CheckSeverity.OFF) // We are not the only checker that fails on Lombok + check("MissingBraces", CheckSeverity.OFF) // We are not the only checker that fails on Lombok option("NullAway:AnnotatedPackages", "com.uber") option("NullAway:UnannotatedSubPackages", "com.uber.lib.unannotated") } |