Class NullAwayOptions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddisable()Disable NullAway.voidenable()Enable NullAway.voiderror()Enable NullAway as an error.abstract org.gradle.api.provider.Property<Boolean> If set to true, treats@RecentlyNullableas {code @Nullable}, and@RecentlyNonNullas@NonNull; maps to-XepOpt:NullAway:AcknowledgeAndroidRecent.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway will acknowledge nullability annotations whenever they are available in unannotated code and also more restrictive than it's optimistic defaults; maps to-XepOpt:NullAway:AcknowledgeRestrictiveAnnotations.abstract org.gradle.api.provider.ListProperty<String> The list of packages that should be considered properly annotated according to the NullAway convention; maps to-XepOpt:NullAway:AnnotatedPackages.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway will handle assertions, and use that to reason about the possibility of null dereferences in the code that follows these assertions; maps to-XepOpt:NullAway:AssertsEnabled.abstract org.gradle.api.provider.Property<String> A comment that will be added alongside the@SuppressWarnings("NullAway")annotation whensuggestSuppressionsis set to true; maps to-XepOpt:NullAway:AutoFixSuppressionComment.abstract org.gradle.api.provider.Property<String> The fully qualified name of a method to be used for downcasting to a non-null value rather than standard suppressions in some instances; maps to-XepOpt:NullAway:CastToNonNullMethod.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway will check@Contractannotations; maps to-XepOpt:NullAway:CheckContracts.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway will check for.get()accesses to potentially emptyOptionalvalues, analogously to how it handles dereferences to@Nullablevalues; maps to-XepOpt:NullAway:CheckOptionalEmptiness.abstract org.gradle.api.provider.ListProperty<String> A list of classes to be treated asOptionalimplementations (e.g.abstract org.gradle.api.provider.ListProperty<String> A list of annotations that should be considered equivalent to@Contractannotations; maps to-XepOpt:NullAway:CustomContractAnnotations.abstract org.gradle.api.provider.ListProperty<String> A list of annotations that should be considered equivalent to@Generatedannotations, for the cases where NullAway cares about such annotations (see e.g.abstract org.gradle.api.provider.ListProperty<String> A list of annotations that should be considered equivalent to@Initializerannotations, and thus mark methods as initializers; maps to-XepOpt:NullAway:CustomInitializerAnnotations.abstract org.gradle.api.provider.ListProperty<String> A list of annotations that should be considered equivalent to@NonNullannotations, for the cases where NullAway cares about such annotations (see e.g.abstract org.gradle.api.provider.ListProperty<String> A list of annotations that should be considered equivalent to@Nullableannotations; maps to-XepOpt:NullAway:CustomNullableAnnotations.abstract org.gradle.api.provider.ListProperty<String> A list of annotations that cause classes to be excluded from nullability analysis; maps tp-XepOpt:NullAway:ExcludedClassAnnotations.abstract org.gradle.api.provider.ListProperty<String> A list of classes to be excluded from the nullability analysis; maps to-XepOpt:NullAway:ExcludedClasses.abstract org.gradle.api.provider.ListProperty<String> A list of annotations that cause fields to be excluded from being checked for proper initialization; maps to-XepOpt:NullAway:ExcludedFieldAnnotations.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway will check every method to see whether or not it overrides a method of a super-type, rather than relying only on the@Overrideannotation; maps to-XepOpt:NullAway:ExhaustiveOverride.abstract org.gradle.api.provider.ListProperty<String> A list of annotations for classes that are "externally initialized;" maps to-XepOpt:NullAway:ExternalInitAnnotations.abstract org.gradle.api.provider.ListProperty<String> A list of classes to be treated equivalently to GuavaFutures` and `FluentFuture; maps to-XepOpt:NullAway:ExtraFuturesClasses.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway will handle assertions from test libraries, likeassertThat(...).isNotNull(), and use that to reason about the possibility of null dereferences in the code that follows these assertions; maps to-XepOpt:NullAway:HandleTestAssertionLibraries.abstract org.gradle.api.provider.Property<Boolean> Should wildcard-aware generic nullability checks be enabled?abstract org.gradle.api.provider.Property<Boolean> Convenience option that enables the experimentalHandleWildcardGenerics,JSpecifyJDKModels, andWarnOnGenericInferenceFailurefeatures; maps to-XepOpt:NullAwway:JSpecifyExperimental.abstract org.gradle.api.provider.Property<Boolean> Enables NullAway's built-in JSpecify nullness models for JDK APIs; maps to-XepOpt:NullAway:JSpecifyJDKModels.abstract org.gradle.api.provider.Property<Boolean> If set to true, enables new checks based on JSpecify (like checks for generic types); maps to-XepOpt:NullAway:JSpecifyMode.abstract org.gradle.api.provider.ListProperty<String> The fully qualified name of those methods from third-party libraries that NullAway should treat as initializers; maps to-XepOpt:NullAway:KnownInitializers.abstract org.gradle.api.provider.Property<Boolean> Indicates that theannotatedPackagesflag has been deliberately omitted, and that NullAway can proceed with only treating@NullMarkedcode as annotated, in accordance with the JSpecify specification; maps to-XepOpt:NullAway:OnlyNullMarked.abstract org.gradle.api.provider.Property<net.ltgt.gradle.errorprone.CheckSeverity> The severity of the NullAway check.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway will use Error Prone's suggested fix functionality to suggest suppressing any warning that it finds; maps to-XepOpt:NullAway:SuggestSuppressions.abstract org.gradle.api.provider.ListProperty<String> A list of names to suppress NullAway using a@SuppressWarningsannotation, similar to@SuppressWarnings("NullAway"); maps to-XepOpt:NullAway:SuppressionNameAliases.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway treats any class annotated with@Generatedas if its APIs are unannotated when analyzing uses from other classes; maps to-XepOpt:NullAway:TreatGeneratedAsUnannotated.abstract org.gradle.api.provider.ListProperty<String> A list of classes within annotated packages that should be treated as unannotated; maps to-XepOpt:NullAway:UnannotatedClasses.abstract org.gradle.api.provider.ListProperty<String> A list of subpackages to be excluded from theannotatedPackageslist; maps to-XepOpt:NullAway:UnannotatedSubPackages.abstract org.gradle.api.provider.Property<Boolean> If set to true, NullAway will issue a warning when generic type inference fails to infer a type argument's nullability; maps to-XepOpt:NullAway:WarnOnGenericInferenceFailure.voidwarn()Enable NullAway as a warning.
-
Constructor Details
-
NullAwayOptions
-
-
Method Details
-
getSeverity
@Input public abstract org.gradle.api.provider.Property<net.ltgt.gradle.errorprone.CheckSeverity> getSeverity()The severity of the NullAway check.Almost equivalent to
options.errorprone.check("NullAway", severity)(NullAway won't actually appear inoptions.errorprone.checks). Can be set toCheckSeverity.OFFto disable NullAway.- See Also:
-
getOnlyNullMarked
Indicates that theannotatedPackagesflag has been deliberately omitted, and that NullAway can proceed with only treating@NullMarkedcode as annotated, in accordance with the JSpecify specification; maps to-XepOpt:NullAway:OnlyNullMarked.If this option is passed, then
annotatedPackagesmust be empty. Note that even if this flag is omitted (andannotatedPackagesis non-empty), any@NullMarkedcode will still be treated as annotated.Defaults to the
value configured at the project-level. -
getAnnotatedPackages
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getAnnotatedPackages()The list of packages that should be considered properly annotated according to the NullAway convention; maps to-XepOpt:NullAway:AnnotatedPackages.This can be used to add to or override the
annotatedPackagesat the project level.Defaults to the
list configured at the project-level. -
getUnannotatedSubPackages
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getUnannotatedSubPackages()A list of subpackages to be excluded from theannotatedPackageslist; maps to-XepOpt:NullAway:UnannotatedSubPackages. -
getUnannotatedClasses
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getUnannotatedClasses()A list of classes within annotated packages that should be treated as unannotated; maps to-XepOpt:NullAway:UnannotatedClasses. -
getKnownInitializers
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getKnownInitializers()The fully qualified name of those methods from third-party libraries that NullAway should treat as initializers; maps to-XepOpt:NullAway:KnownInitializers. -
getExcludedClassAnnotations
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getExcludedClassAnnotations()A list of annotations that cause classes to be excluded from nullability analysis; maps tp-XepOpt:NullAway:ExcludedClassAnnotations. -
getExcludedClasses
A list of classes to be excluded from the nullability analysis; maps to-XepOpt:NullAway:ExcludedClasses. -
getExcludedFieldAnnotations
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getExcludedFieldAnnotations()A list of annotations that cause fields to be excluded from being checked for proper initialization; maps to-XepOpt:NullAway:ExcludedFieldAnnotations. -
getCustomInitializerAnnotations
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getCustomInitializerAnnotations()A list of annotations that should be considered equivalent to@Initializerannotations, and thus mark methods as initializers; maps to-XepOpt:NullAway:CustomInitializerAnnotations. -
getExternalInitAnnotations
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getExternalInitAnnotations()A list of annotations for classes that are "externally initialized;" maps to-XepOpt:NullAway:ExternalInitAnnotations. -
getTreatGeneratedAsUnannotated
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getTreatGeneratedAsUnannotated()If set to true, NullAway treats any class annotated with@Generatedas if its APIs are unannotated when analyzing uses from other classes; maps to-XepOpt:NullAway:TreatGeneratedAsUnannotated. -
getAcknowledgeRestrictiveAnnotations
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getAcknowledgeRestrictiveAnnotations()If set to true, NullAway will acknowledge nullability annotations whenever they are available in unannotated code and also more restrictive than it's optimistic defaults; maps to-XepOpt:NullAway:AcknowledgeRestrictiveAnnotations.- See Also:
-
getCheckOptionalEmptiness
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getCheckOptionalEmptiness()If set to true, NullAway will check for.get()accesses to potentially emptyOptionalvalues, analogously to how it handles dereferences to@Nullablevalues; maps to-XepOpt:NullAway:CheckOptionalEmptiness.- See Also:
-
getSuggestSuppressions
If set to true, NullAway will use Error Prone's suggested fix functionality to suggest suppressing any warning that it finds; maps to-XepOpt:NullAway:SuggestSuppressions.- See Also:
-
getAssertsEnabled
If set to true, NullAway will handle assertions, and use that to reason about the possibility of null dereferences in the code that follows these assertions; maps to-XepOpt:NullAway:AssertsEnabled.This assumes that assertions will always be enabled at runtime (
javarun with-eaJVM argument). -
getExhaustiveOverride
If set to true, NullAway will check every method to see whether or not it overrides a method of a super-type, rather than relying only on the@Overrideannotation; maps to-XepOpt:NullAway:ExhaustiveOverride. -
getCastToNonNullMethod
The fully qualified name of a method to be used for downcasting to a non-null value rather than standard suppressions in some instances; maps to-XepOpt:NullAway:CastToNonNullMethod. -
getCheckOptionalEmptinessCustomClasses
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getCheckOptionalEmptinessCustomClasses()A list of classes to be treated asOptionalimplementations (e.g. Guava'scom.google.common.base.Optional); maps to-XepOpt:NullAway:CheckOptionalEmptinessCustomClasses.- See Also:
-
getAutoFixSuppressionComment
@Input @Optional public abstract org.gradle.api.provider.Property<String> getAutoFixSuppressionComment()A comment that will be added alongside the@SuppressWarnings("NullAway")annotation whensuggestSuppressionsis set to true; maps to-XepOpt:NullAway:AutoFixSuppressionComment.- See Also:
-
getHandleTestAssertionLibraries
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getHandleTestAssertionLibraries()If set to true, NullAway will handle assertions from test libraries, likeassertThat(...).isNotNull(), and use that to reason about the possibility of null dereferences in the code that follows these assertions; maps to-XepOpt:NullAway:HandleTestAssertionLibraries. -
getAcknowledgeAndroidRecent
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getAcknowledgeAndroidRecent()If set to true, treats@RecentlyNullableas {code @Nullable}, and@RecentlyNonNullas@NonNull; maps to-XepOpt:NullAway:AcknowledgeAndroidRecent.Requires that
acknowledgeRestrictiveAnnotationsis also set to true.- See Also:
-
getCheckContracts
If set to true, NullAway will check@Contractannotations; maps to-XepOpt:NullAway:CheckContracts. -
getCustomContractAnnotations
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getCustomContractAnnotations()A list of annotations that should be considered equivalent to@Contractannotations; maps to-XepOpt:NullAway:CustomContractAnnotations. -
getCustomNullableAnnotations
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getCustomNullableAnnotations()A list of annotations that should be considered equivalent to@Nullableannotations; maps to-XepOpt:NullAway:CustomNullableAnnotations. -
getCustomNonnullAnnotations
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getCustomNonnullAnnotations()A list of annotations that should be considered equivalent to@NonNullannotations, for the cases where NullAway cares about such annotations (see e.g.acknowledgeRestrictiveAnnotations); maps to-XepOpt:NullAway:CustomNonnullAnnotations. -
getCustomGeneratedCodeAnnotations
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getCustomGeneratedCodeAnnotations()A list of annotations that should be considered equivalent to@Generatedannotations, for the cases where NullAway cares about such annotations (see e.g.treatGeneratedAsUnannotated); maps to-XepOpt:NullAway:CustomGeneratedCodeAnnotations. -
getJspecifyMode
If set to true, enables new checks based on JSpecify (like checks for generic types); maps to-XepOpt:NullAway:JSpecifyMode. -
getExtraFuturesClasses
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getExtraFuturesClasses()A list of classes to be treated equivalently to GuavaFutures` and `FluentFuture; maps to-XepOpt:NullAway:ExtraFuturesClasses.This special support will likely be removed once NullAway's JSpecify support is more complete.
-
getSuppressionNameAliases
@Input @Optional public abstract org.gradle.api.provider.ListProperty<String> getSuppressionNameAliases()A list of names to suppress NullAway using a@SuppressWarningsannotation, similar to@SuppressWarnings("NullAway"); maps to-XepOpt:NullAway:SuppressionNameAliases.This is useful when other warnings are already suppressed in the codebase and NullAway should be suppressed as well, such as with JetBrains' [
DataFlowIssue](https://www.jetbrains.com/help/inspectopedia/DataFlowIssue.html) inspection. -
getWarnOnGenericInferenceFailure
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getWarnOnGenericInferenceFailure()If set to true, NullAway will issue a warning when generic type inference fails to infer a type argument's nullability; maps to-XepOpt:NullAway:WarnOnGenericInferenceFailure. -
getHandleWildcardGenerics
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getHandleWildcardGenerics()Should wildcard-aware generic nullability checks be enabled? maps to-XepOpt:NullAway:HandleWildcardGenerics. -
getJspecifyExperimental
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getJspecifyExperimental()Convenience option that enables the experimentalHandleWildcardGenerics,JSpecifyJDKModels, andWarnOnGenericInferenceFailurefeatures; maps to-XepOpt:NullAwway:JSpecifyExperimental.This option must be used with
jspecifyMode = true. An explicit value for any of the individual feature flags overrides the value supplied by this option. -
getJspecifyJdkModels
Enables NullAway's built-in JSpecify nullness models for JDK APIs; maps to-XepOpt:NullAway:JSpecifyJDKModels.This option may only be enabled in JSpecify mode.
-
enable
public void enable()Enable NullAway.Equivalent to setting
severitytoCheckSeverity.DEFAULT. -
disable
public void disable()Disable NullAway.Equivalent to setting
severitytoCheckSeverity.OFF. -
warn
public void warn()Enable NullAway as a warning.Equivalent to setting
severitytoCheckSeverity.WARN -
error
public void error()Enable NullAway as an error.Equivalent to setting
severitytoCheckSeverity.ERROR
-