diff --git a/build.gradle b/build.gradle index ac9eb4948..9fb75df86 100644 --- a/build.gradle +++ b/build.gradle @@ -65,7 +65,7 @@ allprojects { ] options.errorprone { - option('NullAway:AnnotatedPackages', 'com.palantir') + option('NullAway:AnnotatedPackages', 'com.palantir,com.google.common') option('NullAway:CheckOptionalEmptiness', 'true') option('AllSuggestionsAsWarnings') // https://github.com/google/error-prone/pull/3301 diff --git a/changelog/@unreleased/pr-1570.v2.yml b/changelog/@unreleased/pr-1570.v2.yml new file mode 100644 index 000000000..2ccee2cfb --- /dev/null +++ b/changelog/@unreleased/pr-1570.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Enforce NullAway for Guava packages + links: + - https://github.com/palantir/tritium/pull/1570 diff --git a/tritium-processor/src/main/java/com/palantir/tritium/processor/Methods.java b/tritium-processor/src/main/java/com/palantir/tritium/processor/Methods.java index 6df0d5004..0fdac164d 100644 --- a/tritium-processor/src/main/java/com/palantir/tritium/processor/Methods.java +++ b/tritium-processor/src/main/java/com/palantir/tritium/processor/Methods.java @@ -17,6 +17,7 @@ package com.palantir.tritium.processor; import com.google.common.base.CaseFormat; +import com.palantir.logsafe.Preconditions; import com.squareup.javapoet.CodeBlock; import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.TypeName; @@ -66,9 +67,11 @@ static IdentityHashMap methodStaticFieldName( IdentityHashMap result = new IdentityHashMap<>(); for (MethodElements method : instrumentedMethods) { String methodName = method.element().getSimpleName().toString(); - String originalMethodFieldName = CaseFormat.LOWER_CAMEL - .converterTo(CaseFormat.UPPER_UNDERSCORE) - .convert(methodName); + String originalMethodFieldName = Preconditions.checkNotNull( + CaseFormat.LOWER_CAMEL + .converterTo(CaseFormat.UPPER_UNDERSCORE) + .convert(methodName), + "methodName cannot be null"); String methodFieldName = originalMethodFieldName; for (int i = 1; true; i++) { String finalName = methodFieldName;