Skip to content

Commit

Permalink
2.x: cleanup of PMD suggestions (ReactiveX#4129)
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd authored Jun 26, 2016
1 parent c9c772f commit 6e508e5
Show file tree
Hide file tree
Showing 105 changed files with 518 additions and 559 deletions.
8 changes: 0 additions & 8 deletions pmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
<rule ref="rulesets/java/basic.xml/DontUseFloatTypeForLoopIndices"/>
<rule ref="rulesets/java/basic.xml/DoubleCheckedLocking"/>
<rule ref="rulesets/java/imports.xml/DuplicateImports"/>
<rule ref="rulesets/java/empty.xml/EmptyCatchBlock"/>
<rule ref="rulesets/java/finalizers.xml/EmptyFinalizer"/>
<rule ref="rulesets/java/empty.xml/EmptyFinallyBlock"/>
<rule ref="rulesets/java/empty.xml/EmptyInitializer"/>
Expand Down Expand Up @@ -110,7 +109,6 @@
<rule ref="rulesets/java/migrating.xml/JUnit4SuitesShouldUseSuiteAnnotation"/>
<rule ref="rulesets/java/migrating.xml/JUnit4TestShouldUseAfterAnnotation"/>
<rule ref="rulesets/java/migrating.xml/JUnit4TestShouldUseBeforeAnnotation"/>
<rule ref="rulesets/java/migrating.xml/JUnit4TestShouldUseTestAnnotation"/>
<rule ref="rulesets/java/junit.xml/JUnitAssertionsShouldIncludeMessage"/>
<rule ref="rulesets/java/junit.xml/JUnitSpelling"/>
<rule ref="rulesets/java/junit.xml/JUnitStaticSuite"/>
Expand All @@ -134,9 +132,6 @@
<rule ref="rulesets/java/javabeans.xml/MissingSerialVersionUID"/>
<rule ref="rulesets/java/design.xml/MissingStaticMethodInNonInstantiatableClass"/>
<rule ref="rulesets/java/logging-java.xml/MoreThanOneLogger"/>
<rule ref="rulesets/java/codesize.xml/NcssConstructorCount"/>
<rule ref="rulesets/java/codesize.xml/NcssMethodCount"/>
<rule ref="rulesets/java/codesize.xml/NcssTypeCount"/>
<rule ref="rulesets/java/naming.xml/NoPackage"/>
<rule ref="rulesets/java/design.xml/NonCaseLabelInSwitchStatement"/>
<rule ref="rulesets/java/design.xml/NonStaticInitializer"/>
Expand All @@ -160,7 +155,6 @@
<rule ref="rulesets/java/design.xml/ReturnEmptyArrayRatherThanNull"/>
<rule ref="rulesets/java/basic.xml/ReturnFromFinallyBlock"/>
<rule ref="rulesets/java/migrating.xml/ShortInstantiation"/>
<rule ref="rulesets/java/naming.xml/ShortMethodName"/>
<rule ref="rulesets/java/strictexception.xml/SignatureDeclareThrowsException"/>
<rule ref="rulesets/java/design.xml/SimpleDateFormatNeedsLocale"/>
<rule ref="rulesets/java/junit.xml/SimplifyBooleanAssertion"/>
Expand All @@ -183,8 +177,6 @@
<rule ref="rulesets/java/junit.xml/TestClassWithoutTestCases"/>
<rule ref="rulesets/java/design.xml/TooFewBranchesForASwitchStatement"/>
<rule ref="rulesets/java/imports.xml/TooManyStaticImports"/>
<rule ref="rulesets/java/design.xml/UncommentedEmptyConstructor"/>
<rule ref="rulesets/java/design.xml/UncommentedEmptyMethodBody"/>
<rule ref="rulesets/java/basic.xml/UnconditionalIfStatement"/>
<rule ref="rulesets/java/junit.xml/UnnecessaryBooleanAssertion"/>
<rule ref="rulesets/java/strings.xml/UnnecessaryCaseChange"/>
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/io/reactivex/Completable.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
* The class follows a similar event pattern as Reactive-Streams: onSubscribe (onError|onComplete)?
*/
public abstract class Completable implements CompletableConsumable {
/** Single instance of a complete Completable. */
static final Completable COMPLETE = new CompletableEmpty();

/** Single instance of a never Completable. */
static final Completable NEVER = new CompletableNever();

/**
* Convenience interface and callback used by the lift operator that given a child CompletableSubscriber,
* return a parent CompletableSubscriber that does any kind of lifecycle-related transformations.
Expand All @@ -47,12 +53,6 @@ public interface CompletableTransformer extends Function<Completable, Completabl

}

/** Single instance of a complete Completable. */
static final Completable COMPLETE = new CompletableEmpty();

/** Single instance of a never Completable. */
static final Completable NEVER = new CompletableNever();

/**
* Wraps the given CompletableConsumable into a Completable
* if not already Completable.
Expand Down Expand Up @@ -186,7 +186,7 @@ public static Completable create(CompletableConsumable onSubscribe) {
// TODO plugin wrapping onSubscribe

return new CompletableWrapper(onSubscribe);
} catch (NullPointerException ex) {
} catch (NullPointerException ex) { // NOPMD
throw ex;
} catch (Throwable ex) {
RxJavaPlugins.onError(ex);
Expand Down Expand Up @@ -1038,7 +1038,7 @@ public final void subscribe(CompletableSubscriber s) {
// TODO plugin wrapping the subscriber

subscribeActual(s);
} catch (NullPointerException ex) {
} catch (NullPointerException ex) { // NOPMD
throw ex;
} catch (Throwable ex) {
RxJavaPlugins.onError(ex);
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/io/reactivex/Flowable.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
import io.reactivex.subscribers.*;

public abstract class Flowable<T> implements Publisher<T> {
private static final Object OBJECT = new Object();
/** The default buffer size. */
static final int BUFFER_SIZE;
static {
BUFFER_SIZE = Math.max(16, Integer.getInteger("rx2.buffer-size", 128));
}

/**
* Interface to map/wrap a downstream subscriber to an upstream subscriber.
*
Expand All @@ -53,12 +60,6 @@ public interface Transformer<T, R> extends Function<Flowable<T>, Publisher<? ext

}

/** The default buffer size. */
static final int BUFFER_SIZE;
static {
BUFFER_SIZE = Math.max(16, Integer.getInteger("rx2.buffer-size", 128));
}

/** A never observable instance as there is no need to instantiate this more than once. */
static final Flowable<Object> NEVER = create(new Publisher<Object>() {
@Override
Expand Down Expand Up @@ -459,8 +460,7 @@ public static <T> Flowable<T> fromFuture(Future<? extends T> future) {
public static <T> Flowable<T> fromFuture(Future<? extends T> future, long timeout, TimeUnit unit) {
Objects.requireNonNull(future, "future is null");
Objects.requireNonNull(unit, "unit is null");
Flowable<T> o = new FlowableFromFuture<T>(future, timeout, unit);
return o;
return new FlowableFromFuture<T>(future, timeout, unit);
}

@BackpressureSupport(BackpressureKind.FULL)
Expand Down Expand Up @@ -1613,16 +1613,14 @@ public Publisher<T> apply(Long v) {
});
}

private static final Object OBJECT = new Object();

@SuppressWarnings({ "rawtypes", "unchecked" })
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final <U> Flowable<T> delaySubscription(final Supplier<? extends Publisher<U>> delaySupplier) {
Objects.requireNonNull(delaySupplier, "delaySupplier is null");
return fromCallable(new Callable<Object>() {
@Override
public Object call() throws Exception {
public Object call() {
return delaySupplier.get();
}
})
Expand Down Expand Up @@ -2936,7 +2934,7 @@ public final void subscribe(Subscriber<? super T> s) {
}

subscribeActual(s);
} catch (NullPointerException e) {
} catch (NullPointerException e) { // NOPMD
throw e;
} catch (Throwable e) {
// TODO throw if fatal?
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/reactivex/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
* Utility class to help construct notification objects.
*/
public final class Notification {
static final Try<Optional<Object>> COMPLETE = Try.ofValue(Optional.<Object>empty());

private Notification() {
throw new IllegalStateException();
}

static final Try<Optional<Object>> COMPLETE = Try.ofValue(Optional.<Object>empty());

@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> Try<Optional<T>> complete() {
return (Try)COMPLETE;
Expand Down
Loading

0 comments on commit 6e508e5

Please sign in to comment.