Skip to content

[java] Fix #7068: UnusedReturnValue false positive after Mockito.verify - #7069

Merged
UncleOwen merged 3 commits into
pmd:mainfrom
kalayciburak:fix/7068-unused-return-value-mockito-verify
Sep 13, 2026
Merged

UncleOwen merged 3 commits into
pmd:mainfrom
kalayciburak:fix/7068-unused-return-value-mockito-verify

Conversation

@kalayciburak

Copy link
Copy Markdown
Contributor

Describe the PR

UnusedReturnValue reported fluent/pure calls made on Mockito.verify(mock), for example Mockito.verify(mock).withCallCredentials(...) or Mockito.verify(mock).size(). Mockito's verification API ignores that return value by design.

Skip the unused-return check when the call's qualifier is org.mockito.Mockito#verify.

Direct unused pure calls such as mock.size() are still reported.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

…erify

Do not flag unused results of methods invoked on Mockito.verify(...).
Verification APIs ignore the return value by design.
@pmd-actions-helper

pmd-actions-helper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 5 violations, 16 errors and 9 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-09-13 14:32:14+00:00 for b6e24c6)

@UncleOwen UncleOwen added this to the 7.28.0 milestone Sep 13, 2026

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@UncleOwen
UncleOwen merged commit 95ba062 into pmd:main Sep 13, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] UnusedReturnValue: False positive for calls made on Mockito.verify(mock)

2 participants