Inspectopedia Help

Result of method call ignored

Reports method calls whose result is ignored.

For many methods, ignoring the result is perfectly legitimate, but for some it is almost certainly an error. Examples of methods where ignoring the result is likely an error include, which returns the number of bytes actually read, and any method on java.lang.String or java.math.BigInteger. These methods do not produce side-effects and thus pointless if their result is ignored.

The calls to the following methods are inspected:

  • Simple getters (which do nothing except return a field)

  • Methods specified in the settings of this inspection

  • Methods annotated with org.jetbrains.annotations.Contract(pure=true)

  • Methods annotated with .*. CheckReturnValue

  • Methods in a class or package annotated with javax.annotation.CheckReturnValue

  • Optionally, all non-library methods

Calls to methods annotated with Error Prone's or AssertJ's @CanIgnoreReturnValue annotation are not reported.

Use the inspection settings to specify the classes to check. Methods are matched by name or name pattern using Java regular expression syntax. For classes, use fully-qualified names. Each entry applies to both the class and all its inheritors.

Inspection options

Here you can find the description of settings available for the Result of method call ignored inspection, and the reference of their default values.

Report all ignored non-library calls

Not selected

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024