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

Add CheckReturnValue annotation #4881

Merged
merged 3 commits into from
Nov 26, 2016
Merged

Add CheckReturnValue annotation #4881

merged 3 commits into from
Nov 26, 2016

Conversation

vanniktech
Copy link
Collaborator

First draft on this.

So far I have only annotated subscribeWith() and test() methods.

I checked this against Error Prone and their check is able of picking up the RxJava annotation.

How do you feel if I extend BaseTypeAnnotations to test for @CheckReturnValue too?

Related #4878

@vanniktech vanniktech changed the title Add CheckReturnValue method Add CheckReturnValue annotation Nov 24, 2016
@codecov-io
Copy link

codecov-io commented Nov 24, 2016

Current coverage is 95.74% (diff: 100%)

Merging #4881 into 2.x will decrease coverage by 0.04%

@@                2.x      #4881   diff @@
==========================================
  Files           581        581          
  Lines         37212      37212          
  Methods           0          0          
  Messages          0          0          
  Branches       5601       5601          
==========================================
- Hits          35643      35628    -15   
- Misses          647        654     +7   
- Partials        922        930     +8   

Powered by Codecov. Last update 442c6ce...94571e5

Copy link
Contributor

@artem-zinnatullin artem-zinnatullin left a comment

Choose a reason for hiding this comment

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

Gooooooood. Afaik Findbugs also able to process annotation with this name correctly.

*
* @since 2.0.2 - experimental
*/
@Retention(RetentionPolicy.RUNTIME)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: static import makes it a little bit better

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I know however for RxJava it's common to not static import them (look at BackpressureSupport & SchedulerSupport) so I left it that way. I leave the final decision up to David.

Copy link
Member

Choose a reason for hiding this comment

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

It's fine as is.

*/
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Target(ElementType.METHOD)
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same as above

@vanniktech
Copy link
Collaborator Author

I quickly checked findbugs and it does not seem like they pick up our annotation since they have their own

*
* @since 2.0.2 - experimental
*/
@Retention(RetentionPolicy.RUNTIME)
Copy link
Member

Choose a reason for hiding this comment

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

It's fine as is.

@akarnokd
Copy link
Member

Would you manually ignore methods like Disposable subscribe()?

@vanniktech
Copy link
Collaborator Author

@artem-zinnatullin weird somehow findbugs didn't pick it up though. Could be a configuration error on my side.

I'd argue that not annotating Diposable subscribe() is fine however I feel like Disposable subscribe(Consumer<T>) and the others should be annotated. I personally almost never use subscribeWith and prefer the variations with lambdas.

We're on the same point that static factory methods and operators such as flatMap, first(), last() etc should be annotated right? If so I'd apply those and then we can see which might need an annotation too.

@vanniktech
Copy link
Collaborator Author

@akarnokd added the @CheckReturnValue annotation to all public API methods of Flowable, Maybe, Single, Observable and Completable except for private methods, void methods and the Disposable subscribe() method. Is that okay now?

@akarnokd
Copy link
Member

Yes.

/cc @JakeWharton

@akarnokd akarnokd merged commit baa00f7 into ReactiveX:2.x Nov 26, 2016
@vanniktech vanniktech deleted the CheckReturnValue branch November 26, 2016 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants