You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If on a method, you should use the return value of this method somehow
If on a class/package, you should treat every method in this class/package as if it were annotated with CheckReturnValue, unless it's annotated with CanIgnoreReturnValue
The new rule should check this. It's just the name of the annotation that is relevant, the package name can be ignored.
Code Sample:
Bad:
logger.atError().setMessage("some message with two arguments {} ms: {}")
.addArgument("some string argument")
.addArgument(() -> System.currentTimeMillis() - startDate);
Good:
logger.atError().setMessage("some message with two arguments {} ms: {}")
.addArgument("some string argument")
.addArgument(() -> System.currentTimeMillis() - startDate)
.log();
We should have a property where the user can define additional InvocationMatchers. The return value of these calls should also be checked. (Maybe we can copy the list of methods from IntelliJ's "Result of method call ignored" inspection as a default for additional methods to check? In that case, this rule would subsume UselessPureMethodCall, CheckSkipResult, CheckResultSet and possibly others.)
Activity
UncleOwen commentedon May 26, 2026
Inspectopedia: ResultOfMethodCallIgnored
[java] Fix pmd#6625: new rule UnusedReturnValue (pmd#6916)
[-][java] New rule: CheckReturnValue[/-][+][java] New rule: UnusedReturnValue[/+][doc] Update release notes for 7.27.0 (#6989)