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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove by akarnokd, update rules
  • Loading branch information
akarnokd committed Jun 24, 2016
commit 52b026dfb0411167daf31284768e1cea472ec75a
3 changes: 0 additions & 3 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 @@ -179,8 +178,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
8 changes: 4 additions & 4 deletions src/main/java/rx/BackpressureOverflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
public final class BackpressureOverflow {

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

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

/**
* Drop the oldest value in the buffer.
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/rx/Completable.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public static Completable create(CompletableOnSubscribe onSubscribe) {
requireNonNull(onSubscribe);
try {
return new Completable(onSubscribe);
} catch (NullPointerException ex) { // NOPMD by akarnokd on 2016.06.23. 10:54
} catch (NullPointerException ex) { // NOPMD
throw ex;
} catch (Throwable ex) {
RxJavaHooks.onError(ex);
Expand Down Expand Up @@ -851,7 +851,7 @@ public static <R> Completable using(final Func0<R> resourceFunc0,
return create(new CompletableOnSubscribe() {
@Override
public void call(final CompletableSubscriber s) {
final R resource; // NOPMD by akarnokd on 2016.06.23. 10:55
final R resource; // NOPMD

try {
resource = resourceFunc0.call();
Expand Down Expand Up @@ -1549,7 +1549,7 @@ public void call(CompletableSubscriber s) {
CompletableSubscriber sw = onLiftDecorated.call(s);

unsafeSubscribe(sw);
} catch (NullPointerException ex) { // NOPMD by akarnokd on 2016.06.23. 10:54
} catch (NullPointerException ex) { // NOPMD
throw ex;
} catch (Throwable ex) {
throw toNpe(ex);
Expand Down Expand Up @@ -2007,7 +2007,7 @@ public final void unsafeSubscribe(CompletableSubscriber s) {
CompletableOnSubscribe onSubscribeDecorated = RxJavaHooks.onCompletableStart(this, this.onSubscribe);

onSubscribeDecorated.call(s);
} catch (NullPointerException ex) { // NOPMD by akarnokd on 2016.06.23. 10:54
} catch (NullPointerException ex) { // NOPMD
throw ex;
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
Expand Down Expand Up @@ -2071,7 +2071,7 @@ public void onSubscribe(Subscription d) {
}
});
RxJavaHooks.onObservableReturn(s);
} catch (NullPointerException ex) { // NOPMD by akarnokd on 2016.06.23. 10:54
} catch (NullPointerException ex) { // NOPMD
throw ex;
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -9015,7 +9015,7 @@ public final Subscription unsafeSubscribe(Subscriber<? super T> subscriber) {
// TODO could the hook be the cause of the error in the on error handling.
RxJavaHooks.onObservableError(r);
// TODO why aren't we throwing the hook's return value.
throw r; // NOPMD by akarnokd on 2016.06.23. 10:51
throw r; // NOPMD
}
return Subscriptions.unsubscribed();
}
Expand Down Expand Up @@ -9112,7 +9112,7 @@ static <T> Subscription subscribe(Subscriber<? super T> subscriber, Observable<T
// TODO could the hook be the cause of the error in the on error handling.
RxJavaHooks.onObservableError(r);
// TODO why aren't we throwing the hook's return value.
throw r; // NOPMD by akarnokd on 2016.06.23. 10:51
throw r; // NOPMD
}
}
return Subscriptions.unsubscribed();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/Single.java
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ public final Subscription unsafeSubscribe(Subscriber<? super T> subscriber) {
// TODO could the hook be the cause of the error in the on error handling.
RxJavaHooks.onSingleError(r);
// TODO why aren't we throwing the hook's return value.
throw r; // NOPMD by akarnokd on 2016.06.23. 10:54
throw r; // NOPMD
}
return Subscriptions.unsubscribed();
}
Expand Down Expand Up @@ -1829,7 +1829,7 @@ public final Subscription subscribe(Subscriber<? super T> subscriber) {
// TODO could the hook be the cause of the error in the on error handling.
RxJavaHooks.onSingleError(r);
// TODO why aren't we throwing the hook's return value.
throw r; // NOPMD by akarnokd on 2016.06.23. 10:53
throw r; // NOPMD
}
return Subscriptions.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AssemblyStackTraceException(String message) {
}

@Override
public synchronized Throwable fillInStackTrace() { // NOPMD by akarnokd on 2016.06.23. 10:29
public synchronized Throwable fillInStackTrace() { // NOPMD
return this;
}
}
6 changes: 3 additions & 3 deletions src/main/java/rx/exceptions/CompositeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class CompositeException extends RuntimeException {
* @param errors the collection of errors
* @deprecated please use {@link #CompositeException(Collection)} */
@Deprecated
public CompositeException(String messagePrefix, Collection<? extends Throwable> errors) { // NOPMD by akarnokd on 2016.06.23. 10:31
public CompositeException(String messagePrefix, Collection<? extends Throwable> errors) { // NOPMD
Set<Throwable> deDupedExceptions = new LinkedHashSet<Throwable>();
List<Throwable> localExceptions = new ArrayList<Throwable>();
if (errors != null) {
Expand Down Expand Up @@ -119,7 +119,7 @@ public String getMessage() {
}

@Override
public synchronized Throwable getCause() { // NOPMD by akarnokd on 2016.06.23. 10:31
public synchronized Throwable getCause() { // NOPMD
if (cause == null) {
// we lazily generate this causal chain if this is called
CompositeExceptionCausalChain localCause = new CompositeExceptionCausalChain();
Expand Down Expand Up @@ -147,7 +147,7 @@ public synchronized Throwable getCause() { // NOPMD by akarnokd on 2016.06.23. 1
// we now have 'e' as the last in the chain
try {
chain.initCause(e);
} catch (Throwable t) { // NOPMD by akarnokd on 2016.06.23. 10:32
} catch (Throwable t) { // NOPMD
// ignore
// the javadocs say that some Throwables (depending on how they're made) will never
// let me call initCause without blowing up even if it returns null
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/rx/exceptions/Exceptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static RuntimeException propagate(Throwable t) {
} else if (t instanceof Error) {
throw (Error) t;
} else {
throw new RuntimeException(t); // NOPMD by akarnokd on 2016.06.23. 10:29
throw new RuntimeException(t); // NOPMD
}
}
/**
Expand Down Expand Up @@ -127,7 +127,7 @@ public static void addCause(Throwable e, Throwable cause) {
// we now have 'e' as the last in the chain
try {
e.initCause(cause);
} catch (Throwable t) { // NOPMD by akarnokd on 2016.06.23. 10:30
} catch (Throwable t) { // NOPMD
// ignore
// the javadocs say that some Throwables (depending on how they're made) will never
// let me call initCause without blowing up even if it returns null
Expand Down Expand Up @@ -172,7 +172,7 @@ public static void throwIfAny(List<? extends Throwable> exceptions) {
} else if (t instanceof Error) {
throw (Error) t;
} else {
throw new RuntimeException(t); // NOPMD by akarnokd on 2016.06.23. 10:29
throw new RuntimeException(t); // NOPMD
}
}
throw new CompositeException(exceptions);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/internal/operators/OnSubscribeGroupJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ final class ResultManager implements Subscription {
/** Guarded by guard. */
int rightIds;
/** Guarded by guard. */
final Map<Integer, Observer<T2>> leftMap = new HashMap<Integer, Observer<T2>>(); // NOPMD by akarnokd on 2016.06.23. 12:54
final Map<Integer, Observer<T2>> leftMap = new HashMap<Integer, Observer<T2>>(); // NOPMD
/** Guarded by guard. */
final Map<Integer, T2> rightMap = new HashMap<Integer, T2>(); // NOPMD by akarnokd on 2016.06.23. 12:54
final Map<Integer, T2> rightMap = new HashMap<Integer, T2>(); // NOPMD
/** Guarded by guard. */
boolean leftDone;
/** Guarded by guard. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static final class DebounceState<T> {
/** Guarded by this. */
boolean emitting;

public synchronized int next(T value) { // NOPMD by akarnokd on 2016.06.23. 11:30
public synchronized int next(T value) { // NOPMD
this.value = value;
this.hasValue = true;
return ++index;
Expand Down Expand Up @@ -173,7 +173,7 @@ public void emitAndComplete(Subscriber<T> onNextAndComplete, Subscriber<?> onErr
}
onNextAndComplete.onCompleted();
}
public synchronized void clear() { // NOPMD by akarnokd on 2016.06.23. 11:30
public synchronized void clear() { // NOPMD
++index;
value = null;
hasValue = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/internal/operators/OperatorGroupBy.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static final class State<T, K> extends AtomicInteger implements Producer, Subscr
final AtomicBoolean once;


public State(int bufferSize, GroupBySubscriber<?, K, T> parent, K key, boolean delayError) { // NOPMD by akarnokd on 2016.06.23. 12:47
public State(int bufferSize, GroupBySubscriber<?, K, T> parent, K key, boolean delayError) { // NOPMD
this.queue = new ConcurrentLinkedQueue<Object>();
this.parent = parent;
this.key = key;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/internal/operators/OperatorPublish.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void call(Subscriber<? super T> child) {
// setting the producer will trigger the first request to be considered by
// the subscriber-to-source.
child.setProducer(inner);
break; // NOPMD by akarnokd on 2016.06.23. 11:26
break; // NOPMD
}
}
};
Expand Down Expand Up @@ -194,7 +194,7 @@ public void connect(Action1<? super Subscription> connection) {
// if connect() was called concurrently, only one of them should actually
// connect to the source
doConnect = !ps.shouldConnect.get() && ps.shouldConnect.compareAndSet(false, true);
break; // NOPMD by akarnokd on 2016.06.23. 11:26
break; // NOPMD
}
/*
* Notify the callback that we have a (new) connection which it can unsubscribe
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/internal/operators/OperatorReplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void call(Subscriber<? super T> child) {
// setting the producer will trigger the first request to be considered by
// the subscriber-to-source.
child.setProducer(inner);
break; // NOPMD by akarnokd on 2016.06.23. 12:54
break; // NOPMD
}
}
};
Expand Down Expand Up @@ -279,7 +279,7 @@ public void connect(Action1<? super Subscription> connection) {
// if connect() was called concurrently, only one of them should actually
// connect to the source
doConnect = !ps.shouldConnect.get() && ps.shouldConnect.compareAndSet(false, true);
break; // NOPMD by akarnokd on 2016.06.23. 12:54
break; // NOPMD
}
/*
* Notify the callback that we have a (new) connection which it can unsubscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public SingleOnSubscribeUsing(Func0<Resource> resourceFactory,

@Override
public void call(final SingleSubscriber<? super T> child) {
final Resource resource; // NOPMD by akarnokd on 2016.06.23. 11:18
final Resource resource; // NOPMD

try {
resource = resourceFactory.call();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void request(long n) {
emit(child, value);
}
}
return; // NOPMD by akarnokd on 2016.06.23. 9:58
return; // NOPMD
}
}

Expand All @@ -85,7 +85,7 @@ public void setValue(T value) {
emit(child, value);
}
}
return; // NOPMD by akarnokd on 2016.06.23. 9:58
return; // NOPMD
}
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/internal/schedulers/NewThreadWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static void purgeExecutors() {
* @return true if the policy was successfully enabled
*/
public static boolean tryEnableCancelPolicy(ScheduledExecutorService executor) {
if (SHOULD_TRY_ENABLE_CANCEL_POLICY) { // NOPMD by akarnokd on 2016.06.23. 10:08
if (SHOULD_TRY_ENABLE_CANCEL_POLICY) { // NOPMD
final boolean isInstanceOfScheduledThreadPoolExecutor = executor instanceof ScheduledThreadPoolExecutor;

Method methodToCall;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/rx/internal/util/IndexedRingBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected IndexedRingBuffer<?> createObject() {
try {
defaultSize = Integer.parseInt(sizeFromProperty);
} catch (NumberFormatException e) {
System.err.println("Failed to set 'rx.indexed-ring-buffer.size' with value " + sizeFromProperty + " => " + e.getMessage()); // NOPMD by akarnokd on 2016.06.23. 11:09
System.err.println("Failed to set 'rx.indexed-ring-buffer.size' with value " + sizeFromProperty + " => " + e.getMessage()); // NOPMD
}
}

Expand Down Expand Up @@ -358,7 +358,7 @@ private ElementSection<E> getElementSection(int index) {
return a;
}

private synchronized int getIndexForAdd() { // NOPMD by akarnokd on 2016.06.23. 11:11
private synchronized int getIndexForAdd() { // NOPMD
/*
* Synchronized as I haven't yet figured out a way to do this in an atomic way that doesn't involve object allocation
*/
Expand Down Expand Up @@ -387,7 +387,7 @@ private synchronized int getIndexForAdd() { // NOPMD by akarnokd on 2016.06.23.
*
* @return
*/
private synchronized int getIndexFromPreviouslyRemoved() { // NOPMD by akarnokd on 2016.06.23. 11:11
private synchronized int getIndexFromPreviouslyRemoved() { // NOPMD
/*
* Synchronized as I haven't yet figured out a way to do this in an atomic way that doesn't involve object allocation
*/
Expand All @@ -407,7 +407,7 @@ private synchronized int getIndexFromPreviouslyRemoved() { // NOPMD by akarnokd
}
}

private synchronized void pushRemovedIndex(int elementIndex) { // NOPMD by akarnokd on 2016.06.23. 11:11
private synchronized void pushRemovedIndex(int elementIndex) { // NOPMD
/*
* Synchronized as I haven't yet figured out a way to do this in an atomic way that doesn't involve object allocation
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/internal/util/LinkedArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ public void add(Object o) {
* @return the head object array
*/
public Object[] head() {
return head; // NOPMD by akarnokd on 2016.06.23. 11:04
return head; // NOPMD
}
/**
* Returns the tail buffer segment or null if the list is empty.
* @return the tail object array
*/
public Object[] tail() {
return tail; // NOPMD by akarnokd on 2016.06.23. 11:04
return tail; // NOPMD
}
/**
* Returns the total size of the list.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/internal/util/ObjectPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class ObjectPool<T> implements SchedulerLifecycle {
private final AtomicReference<Future<?>> periodicTask;

public ObjectPool() {
this(0, 0, 67); // NOPMD by akarnokd on 2016.06.23. 11:00
this(0, 0, 67); // NOPMD
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/internal/util/OpenHashSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void rehash() {


for (int j = size; j-- != 0; ) {
while (a[--i] == null); // NOPMD by akarnokd on 2016.06.23. 11:06
while (a[--i] == null); // NOPMD
int pos = mix(a[i].hashCode()) & m;
if (b[pos] != null) {
for (;;) {
Expand Down Expand Up @@ -205,6 +205,6 @@ public boolean isEmpty() {
* @return the raw array of values of this set
*/
public T[] values() {
return keys; // NOPMD by akarnokd on 2016.06.23. 11:06
return keys; // NOPMD
}
}
2 changes: 1 addition & 1 deletion src/main/java/rx/internal/util/PlatformDependent.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static int resolveAndroidApiVersion() {
.forName("android.os.Build$VERSION", true, getSystemClassLoader())
.getField("SDK_INT")
.get(null);
} catch (Exception e) { // NOPMD by akarnokd on 2016.06.23. 11:04
} catch (Exception e) { // NOPMD
// Can not resolve version of Android API, maybe current platform is not Android
// or API of resolving current Version of Android API has changed in some release of Android
return ANDROID_API_VERSION_IS_NOT_ANDROID;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/internal/util/RxJavaPluginUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ private static void handlePluginException(Throwable pluginException) {
* Since the plugin should never throw this is a safety net
* and will complain loudly to System.err so it gets fixed.
*/
System.err.println("RxJavaErrorHandler threw an Exception. It shouldn't. => " + pluginException.getMessage()); // NOPMD by akarnokd on 2016.06.23. 11:05
pluginException.printStackTrace(); // NOPMD by akarnokd on 2016.06.23. 11:05
System.err.println("RxJavaErrorHandler threw an Exception. It shouldn't. => " + pluginException.getMessage()); // NOPMD
pluginException.printStackTrace(); // NOPMD
}

}
Loading