question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add CheckReturnValue to queries

See original GitHub issue

It allows to detect incorrect API usage through static checkers in IDEs or Findbugs.

Findbugs and the IDEs work in a nice way and one can define an annotation named @CheckReturnValue in their own package and the checkers will honer it. There won’t be any need for a dependency to a 3rd party.

Marking a class with @CheckReturnValue will apply that to all of it’s method. In order to ignore a particular method one can annotate it with an annotation named @CanIgnoreReturnValue.

All this would be beneficial for a better developer experience with the Flowable Java API

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
filiphrcommented, Sep 5, 2018

@lamtrhieu you don’t need to write a custom detector for findbugs.

An example of what an incorrect usage is:

ProcessInstnaceQuery query = ...

query.processDefinitionKey("key");

The problem is not calling one of singleResult, list, listPage or count.

An example how this looks like in AssertJ can be found in this.

This is how the CheckReturnValue annotation works in Findbug.

There is also a possibility to use a custom CanIgnoreReturnValue. This is how it was done in AssertJ.

All things said, if you want to do something I would suggest you do one query and we see how it works, because I think that there might be some issues (at least discovery in IntelliJ)

0reactions
lamtrhieucommented, Sep 5, 2018

Hi @filiphr Can you please help to answer all my questions when you have time ? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

apply CheckReturnValue to entire project - java - Stack Overflow
It's been fixed but now I want to add some static analysis to help find if other existing bugs of the same nature...
Read more >
CheckReturnValue - Error Prone
add (element) returns a boolean : The return value is false if element was already contained in set . Typically, callers don't need...
Read more >
CallArgsStep (jOOQ 3.18.0-SNAPSHOT API)
A step in the construction of the CALL statement. Referencing XYZ*Step types directly from client code. It is usually not recommended to reference...
Read more >
Source code - Guava
CheckReturnValue ; 037import javax.annotation. ... of certain elements (for example 049 * {@link #last}) 050 * <li>query methods which answer questions about ...
Read more >
hasParameterType: Functions to query existence of specific type ...
Similarly, we determine if we have any information about the return type before adding a call to checkReturnValue. They are used internally.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found