Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply @CheckReturnValue more aggressively #2363

Closed
kluever opened this issue Jul 19, 2021 · 2 comments · Fixed by #2379
Closed

Apply @CheckReturnValue more aggressively #2363

kluever opened this issue Jul 19, 2021 · 2 comments · Fixed by #2379

Comments

@kluever
Copy link
Contributor

kluever commented Jul 19, 2021

Mockito has a local copy of @CheckReturnValue (presumably to avoid a dependency on errorprone, but it's only used on a few APIs. There's a lot of additional APIs that it could be applied to, an in fact the best solution is often to annotate entire classes (and then opt-out specific APIs) or entire packages (via package-info.java).

Top APIs to add @CheckReturnValue to:

  • org.mockito.ArgumentMatchers
  • org.mockito.ArgumentCaptor
  • org.mockito.Mockito
  • org.mockito.stubbing.Stubber
@TimvdLippe
Copy link
Contributor

Just to double-check that I understand the behavior of @CheckReturnValue. If we were to add it to org.mockito.Mockito, it can automatically ignore any method that returns void?

@kluever
Copy link
Contributor Author

kluever commented Jul 19, 2021

Indeed, it only affects non-void methods. Additionally, it's often easier to add it to the class, and if there are methods where it is OK to ignore the return value, then those methods would be marked with @CanIgnoreReturnValue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants