Skip to content

1.x: apply fixes based on PMD suggestions #4091

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

Merged
merged 4 commits into from
Jun 25, 2016
Merged

Conversation

akarnokd
Copy link
Member

Some notable changes:

  • move fields to the beginning of a class
  • remove unnecessary modifiers and initializers
  • avoid creating objects to early
  • update most drain algorithm to use the (more modern) while (e != r) pattern
  • PMD has a few incorrect checks: complaining about a final local that gets used in an inner class
  • adding braces to ifs
  • documenting deliberately empty methods
  • fix internal field and method namings
  • delegate to Exceptions.propagate

@akarnokd akarnokd added this to the 1.2 milestone Jun 23, 2016
@akarnokd
Copy link
Member Author

Travis doesn't pick up this one for some reason. Reopening.

@akarnokd akarnokd closed this Jun 23, 2016
@akarnokd akarnokd reopened this Jun 23, 2016
@codecov-io
Copy link

codecov-io commented Jun 23, 2016

Current coverage is 80.16%

Merging #4091 into 1.x will decrease coverage by 0.08%

@@                1.x      #4091   diff @@
==========================================
  Files           259        257     -2   
  Lines         16821      16771    -50   
  Methods           0          0          
  Messages          0          0          
  Branches       2554       2541    -13   
==========================================
- Hits          13500      13445    -55   
- Misses         2408       2416     +8   
+ Partials        913        910     -3   

Powered by Codecov. Last updated by afe3cb0...52b026d

@akarnokd
Copy link
Member Author

/cc @hzsweers @artem-zinnatullin Let me know if you want to review this and need some time.

@akarnokd
Copy link
Member Author

@artem-zinnatullin
Copy link
Contributor

I'll review it in 24 hours if you don't mind

@akarnokd
Copy link
Member Author

Sure. I'll return to 2.x till then.

@@ -151,9 +151,6 @@ public void remove() {
private final BlockingQueue<Notification<? extends T>> buf = new ArrayBlockingQueue<Notification<? extends T>>(1);
final AtomicInteger waiting = new AtomicInteger();

NextObserver() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this adds a synthetic accessor method.

@JakeWharton
Copy link
Contributor

Some of these I really like. Some I don't. Documenting empty methods seems like pure noise.

@akarnokd
Copy link
Member Author

Updated.

@akarnokd
Copy link
Member Author

@JakeWharton we can iterate on the ruleset after this gets merged.

@akarnokd akarnokd mentioned this pull request Jun 23, 2016
@stevegury
Copy link
Member

👍
I agree with @JakeWharton, adding a one-word comment to empty methods does not add substantial information. We should disable this warning, which doesn't prevent us to document empty methods where it makes sense.

@akarnokd
Copy link
Member Author

Okay then. If you don't mind, let's have the comments in this PR as is and have a separate PR disable the rule.

/**
* By default, signal a MissingBackressureException due to lack of requests.
*/
public static final BackpressureOverflow.Strategy ON_OVERFLOW_DEFAULT = Error.INSTANCE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to move this below all other strategies and change assignment to ON_OVERFLOW_DEFAULT = ON_OVERFLOW_ERROR so it'll be more clear that default strategy is same as ON_OVERFLOW_ERROR

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, how about in a separate PR after this?

Copy link
Contributor

Choose a reason for hiding this comment

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

np

@stevegury
Copy link
Member

👍 Sound good!

@@ -377,7 +379,7 @@ public static Completable create(CompletableOnSubscribe onSubscribe) {
requireNonNull(onSubscribe);
try {
return new Completable(onSubscribe);
} catch (NullPointerException ex) {
} catch (NullPointerException ex) { // NOPMD by akarnokd on 2016.06.23. 10:54
Copy link
Contributor

Choose a reason for hiding this comment

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

will be great to avoid such comments by tweaking pmd rules

Copy link
Contributor

Choose a reason for hiding this comment

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

or at least remove "by akarnokd on …", we have git history for that

@@ -2589,7 +2593,7 @@ public void call(SingleSubscriber<? super T> singleSubscriber) {
*/
@SuppressWarnings("unchecked")
static <T> Single<? extends T>[] iterableToArray(final Iterable<? extends Single<? extends T>> singlesIterable) {
final Single<? extends T>[] singlesArray;
Single<? extends T>[] singlesArray;
Copy link
Contributor

Choose a reason for hiding this comment

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

PMD complained about final variable?

@akarnokd
Copy link
Member Author

Updated: removed my name, swapped the BackpressureStategy constants, disabled empty method/constructor/catch block rules.

@artem-zinnatullin
Copy link
Contributor

👍

@@ -2410,10 +2412,12 @@ public void onNext(T t) {
Observer<T> observer = new Observer<T>() {
@Override
public void onCompleted() {
// deliberately ignored
}

@Override
public void onError(Throwable e) {
Copy link
Contributor

@ZacSweers ZacSweers Jun 24, 2016

Choose a reason for hiding this comment

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

Not sure if this is covered in PMD, but usually like to also name the param ignored. Same for the others. I suppose it's kind of orthogonal to the comment here though, which is that the method itself is deliberately unimplemented. I'd recommend specifying that it's unimplemented rather than "ignored", since "ignored" usually is in reference to the param(s)

@ZacSweers
Copy link
Contributor

Some minor nits, LGTM 👍

@akarnokd
Copy link
Member Author

Thanks @hzsweers!

@akarnokd akarnokd merged commit 5be3a4b into ReactiveX:1.x Jun 25, 2016
@akarnokd akarnokd deleted the PMDFixes623 branch June 25, 2016 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants