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 java.io.inputStream.read(), 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.

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.

IgnoreResultOfCall
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.

Settings or Preferences | Editor | Inspections | Java | Probable bugs

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

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Java, 241.18072

Last modified: 18 June 2024