Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 1.85 KB

File metadata and controls

33 lines (25 loc) · 1.85 KB

Checkstyle Nullability Annotations

A custom check for Checkstyle that ensures that field, method parameter and return types are annotated with annotations specified in the check's configuration.

At the moment, check doesn't recognize annotations specified at the class level.

Supported tokens

  • CTOR_DEF for checking constructor parameter types
  • METHOD_DEF for checking method parameter and return types
  • VARIABLE_DEF for checking non-local field types

Supported properties

Name Type Default Description
tokens String[] CTOR_DEF, METHOD_DEF, VARIABLE_DEF Any combination of tokens above
nonnullClassNames String[] Not specified, mandatory Fully qualified class names that should be treated as "Nonnull" annotations.
nullableClassNames String[] Not specified, mandatory Fully qualified class names that should be treated as "Nullable" annotations.
checkLocalVariables boolean true Whether local variables should be checked as well

Sample module configuration

<module name="NullabilityAnnotationsCheck">
    <property name="tokens" value="CTOR_DEF, METHOD_DEF, VARIABLE_DEF"/>
    <property name="nonnullClassNames" value="org.jspecify.annotations.NonNull"/>
    <property name="nullableClassNames" value="org.jspecify.annotations.Nullable"/>
    <property name="checkLocalVariables" value="false"/>
</module>