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.
- 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.
ResultOfMethodCallIgnored
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.
Here you can find the description of settings available for the Result of method call ignored inspection, and the reference of their default values.
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 243.23126 |
Thanks for your feedback!