@NotNull/@Nullable problems
Reports problems related to nullability annotations.
Examples:
Overriding methods are not annotated:
abstract class A { @NotNull abstract String m(); } class B extends A { String m() { return "empty string"; } }Annotated primitive types:
@NotNull int myFoo;Both
@Nullableand@NotNullare present on the same member:@Nullable @NotNull String myFooString;Collection of nullable elements is assigned into a collection of non-null elements:
void testList(List<@Nullable String> nullableList) { List<@NotNull String> list2 = nullableList; }
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
NullableProblems- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Use the Configure Annotations button to specify nullability annotations and the checkboxes to fine-tune where the inspection should provide warnings.
This inspection only reports if the language level of the project or module is 5 or higher, and nullability annotations are available on the classpath.
Inspection ID: NullableProblems
Inspection options
Here you can find the description of settings available for the @NotNull/@Nullable problems inspection, and the reference of their default values.
- Report @NotNull parameters overriding @Nullable and vice versa
Option ID:
REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLEDefault value:
Selected- Report non-annotated parameters or methods overriding @NotNull
Option ID:
REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULLDefault value:
Selected- Report non-annotated type arguments instantiating non-null type parameter
Option ID:
REPORT_NOT_ANNOTATED_INSTANTIATION_NOT_NULL_TYPEDefault value:
Not selected- Report @NotNull parameters overriding non-annotated
Option ID:
REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATEDDefault value:
Not selected- Report non-annotated setter parameters or getters of annotated fields
Option ID:
REPORT_NOT_ANNOTATED_GETTERDefault value:
Selected- Report @NotNull parameters with null-literal argument usages
Option ID:
REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETERDefault value:
Selected- Report nullability annotations on local variables when they are non-applicable
Option ID:
REPORT_NULLABILITY_ANNOTATION_ON_LOCALSDefault value:
Selected- Report assignment of a not null type parameter to nullable type parameter
Option ID:
REPORT_NOT_NULL_TO_NULLABLE_CONFLICTS_IN_ASSIGNMENTSDefault value:
Not selected
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |