This is the check "The result of ignoring the method is ignored." By default, it reports only a few special methods, including all java.lang.BigDecimal methods. In the validation configuration, you can add other classes and methods that should be reported this way.

The "Report all ignored non-library calls" checkbox selects all classes in your project.
If you want to use annotations, you can annotate individual methods or entire classes using the JSR 305 annotation
javax.annotation.CheckReturnValue
With IDEA 2016.3 you can even use error annotation
com.google.errorprone.annotations.CanIgnoreReturnValue
exclude individual methods from checking return value. Using both annotations, you can write a class as follows:
import javax.annotation.CheckReturnValue; import com.google.errorprone.annotations.CanIgnoreReturnValue; @CheckReturnValue class A { String a() { return "a"; } @CanIgnoreReturnValue String b() { return "b"; } void run() { a();
source share