Add @CheckReturnValue to detect common mistake through static analysis
See original GitHub issueA common mistake among new to ParSeq is to treat Task as if it’s creation caused is execution e.g.:
Task<RelevanceItems> getRelevanceItemsTask = _relevanceBackendClient.get(keys)
.map(relevanceItems -> {
if (Sets.difference(userItems, relevanceItems).size() > 0) {
// Doesn’t actually execute since this is a Task but isn’t connected to parent task
_userItemsClient.update(userId, userItems.addAll(relevanceItems));
}
return _userItems;
});
Using jsr305 @CheckReturnValue on methods that return Task would allow detecting this mistake through static analysis.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
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 >How to mark a Java method as "must use result" for static ...
I would like API users to be able to identify such bugs via static analysis, such as with FindBugs or IntelliJ inspections. I...
Read more >NetBeans - More static code analysis · Timelessness
Through this option, we can inspect the project with the complete FindBugs static analysis rules set. If this profile is not available ...
Read more >Bug descriptions — spotbugs 4.7.3 documentation
This code seems to be storing a non-serializable object into an HttpSession. If this session is passivated or migrated, an error will result....
Read more >Android Lint API Guide - Google Samples
Compatibility: We may add additional parameters over time. ... This is a common mistake for new lint check authors: the lint check works...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One possibility is to create a custom FindBugs rule. It should not be too hard: refactor rule that validates @CheckReturnValue annotation with a twist that it applies to all methods (annotation is not necessary) which return Task type. This could be a tiny contrib project.
If this turns out to be high effort, I want to note that findbugs community is moving towards the spotbugs project.
Some alternatives could include