-
Notifications
You must be signed in to change notification settings - Fork 266
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
Add @CheckReturnValue to detect common mistake through static analysis #159
Comments
This would be an excellent feature! I might suggest considering jsr308 and Checker Framework over new jsr305 usage. jsr305 is incompatible with Java 9 and has been inactive for a long time now. This has spurred a number of recent proposals to migrate off js305. One of the most popular options has been jsr308 and the Checker Framework. See google/guava#2960 for discussion around Guava's recent migration. They have chosen to already migrate to the Checker Framework for nullability checks, and I believe they are still deciding on other annotations. Currently, a lot of tooling support is not quite there, but I suspect with the upcoming Java 9 breakage and Guava's migration, we should see broader support follow very soon. |
As I'm looking at this more, I'm not sure that a change like this would catch a majority of the cases I've seen. If we put
But unless
Ideally, we'd want to have some type of static check to ensure that all results of type |
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. |
That's a good idea. It looks like methods with the |
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
|
A common mistake among new to ParSeq is to treat Task as if it's creation caused is execution e.g.:
Using jsr305 @CheckReturnValue on methods that return Task would allow detecting this mistake through static analysis.
The text was updated successfully, but these errors were encountered: