The following issues were found

src/main/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMapNotification.java
17 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 26

              
public final class ObservableMapNotification<T, R> extends AbstractObservableWithUpstream<T, ObservableSource<? extends R>> {

    final Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper;
    final Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper;
    final Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier;

    public ObservableMapNotification(
            ObservableSource<T> source,

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 27

              public final class ObservableMapNotification<T, R> extends AbstractObservableWithUpstream<T, ObservableSource<? extends R>> {

    final Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper;
    final Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper;
    final Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier;

    public ObservableMapNotification(
            ObservableSource<T> source,
            Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper,

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 28

              
    final Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper;
    final Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper;
    final Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier;

    public ObservableMapNotification(
            ObservableSource<T> source,
            Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper,
            Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper,

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 48

              
    static final class MapNotificationObserver<T, R>
    implements Observer<T>, Disposable {
        final Observer<? super ObservableSource<? extends R>> downstream;
        final Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper;
        final Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper;
        final Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier;

        Disposable upstream;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 49

                  static final class MapNotificationObserver<T, R>
    implements Observer<T>, Disposable {
        final Observer<? super ObservableSource<? extends R>> downstream;
        final Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper;
        final Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper;
        final Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier;

        Disposable upstream;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 50

                  implements Observer<T>, Disposable {
        final Observer<? super ObservableSource<? extends R>> downstream;
        final Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper;
        final Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper;
        final Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier;

        Disposable upstream;

        MapNotificationObserver(Observer<? super ObservableSource<? extends R>> actual,

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 51

                      final Observer<? super ObservableSource<? extends R>> downstream;
        final Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper;
        final Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper;
        final Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier;

        Disposable upstream;

        MapNotificationObserver(Observer<? super ObservableSource<? extends R>> actual,
                Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper,

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 53

                      final Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper;
        final Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier;

        Disposable upstream;

        MapNotificationObserver(Observer<? super ObservableSource<? extends R>> actual,
                Function<? super T, ? extends ObservableSource<? extends R>> onNextMapper,
                Function<? super Throwable, ? extends ObservableSource<? extends R>> onErrorMapper,
                Supplier<? extends ObservableSource<? extends R>> onCompleteSupplier) {

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 89

              
            try {
                p = Objects.requireNonNull(onNextMapper.apply(t), "The onNext ObservableSource returned is null");
            } catch (Throwable e) {
                Exceptions.throwIfFatal(e);
                downstream.onError(e);
                return;
            }


            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 104

              
            try {
                p = Objects.requireNonNull(onErrorMapper.apply(t), "The onError ObservableSource returned is null");
            } catch (Throwable e) {
                Exceptions.throwIfFatal(e);
                downstream.onError(new CompositeException(t, e));
                return;
            }


            

Reported by PMD.

src/main/java/io/reactivex/rxjava3/internal/operators/observable/ObservableRepeatWhen.java
17 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 34

               */
public final class ObservableRepeatWhen<T> extends AbstractObservableWithUpstream<T, T> {

    final Function<? super Observable<Object>, ? extends ObservableSource<?>> handler;

    public ObservableRepeatWhen(ObservableSource<T> source, Function<? super Observable<Object>, ? extends ObservableSource<?>> handler) {
        super(source);
        this.handler = handler;
    }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 43

              
    @Override
    protected void subscribeActual(Observer<? super T> observer) {
        Subject<Object> signaller = PublishSubject.create().toSerialized();

        ObservableSource<?> other;

        try {
            other = Objects.requireNonNull(handler.apply(signaller), "The handler returned a null ObservableSource");

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 49

              
        try {
            other = Objects.requireNonNull(handler.apply(signaller), "The handler returned a null ObservableSource");
        } catch (Throwable ex) {
            Exceptions.throwIfFatal(ex);
            EmptyDisposable.error(ex, observer);
            return;
        }


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 58

                      RepeatWhenObserver<T> parent = new RepeatWhenObserver<>(observer, signaller, source);
        observer.onSubscribe(parent);

        other.subscribe(parent.inner);

        parent.subscribeNext();
    }

    static final class RepeatWhenObserver<T> extends AtomicInteger implements Observer<T>, Disposable {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 67

              
        private static final long serialVersionUID = 802743776666017014L;

        final Observer<? super T> downstream;

        final AtomicInteger wip;

        final AtomicThrowable error;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 69

              
        final Observer<? super T> downstream;

        final AtomicInteger wip;

        final AtomicThrowable error;

        final Subject<Object> signaller;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 71

              
        final AtomicInteger wip;

        final AtomicThrowable error;

        final Subject<Object> signaller;

        final InnerRepeatObserver inner;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 73

              
        final AtomicThrowable error;

        final Subject<Object> signaller;

        final InnerRepeatObserver inner;

        final AtomicReference<Disposable> upstream;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 75

              
        final Subject<Object> signaller;

        final InnerRepeatObserver inner;

        final AtomicReference<Disposable> upstream;

        final ObservableSource<T> source;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 77

              
        final InnerRepeatObserver inner;

        final AtomicReference<Disposable> upstream;

        final ObservableSource<T> source;

        volatile boolean active;


            

Reported by PMD.

src/main/java/io/reactivex/rxjava3/internal/operators/observable/ObservableZipIterable.java
17 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 27

              import io.reactivex.rxjava3.plugins.RxJavaPlugins;

public final class ObservableZipIterable<T, U, V> extends Observable<V> {
    final Observable<? extends T> source;
    final Iterable<U> other;
    final BiFunction<? super T, ? super U, ? extends V> zipper;

    public ObservableZipIterable(
            Observable<? extends T> source,

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 28

              
public final class ObservableZipIterable<T, U, V> extends Observable<V> {
    final Observable<? extends T> source;
    final Iterable<U> other;
    final BiFunction<? super T, ? super U, ? extends V> zipper;

    public ObservableZipIterable(
            Observable<? extends T> source,
            Iterable<U> other, BiFunction<? super T, ? super U, ? extends V> zipper) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 29

              public final class ObservableZipIterable<T, U, V> extends Observable<V> {
    final Observable<? extends T> source;
    final Iterable<U> other;
    final BiFunction<? super T, ? super U, ? extends V> zipper;

    public ObservableZipIterable(
            Observable<? extends T> source,
            Iterable<U> other, BiFunction<? super T, ? super U, ? extends V> zipper) {
        this.source = source;

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 45

              
        try {
            it = Objects.requireNonNull(other.iterator(), "The iterator returned by other is null");
        } catch (Throwable e) {
            Exceptions.throwIfFatal(e);
            EmptyDisposable.error(e, t);
            return;
        }


            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 55

              
        try {
            b = it.hasNext();
        } catch (Throwable e) {
            Exceptions.throwIfFatal(e);
            EmptyDisposable.error(e, t);
            return;
        }


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 70

                  }

    static final class ZipIterableObserver<T, U, V> implements Observer<T>, Disposable {
        final Observer<? super V> downstream;
        final Iterator<U> iterator;
        final BiFunction<? super T, ? super U, ? extends V> zipper;

        Disposable upstream;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 71

              
    static final class ZipIterableObserver<T, U, V> implements Observer<T>, Disposable {
        final Observer<? super V> downstream;
        final Iterator<U> iterator;
        final BiFunction<? super T, ? super U, ? extends V> zipper;

        Disposable upstream;

        boolean done;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 72

                  static final class ZipIterableObserver<T, U, V> implements Observer<T>, Disposable {
        final Observer<? super V> downstream;
        final Iterator<U> iterator;
        final BiFunction<? super T, ? super U, ? extends V> zipper;

        Disposable upstream;

        boolean done;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 74

                      final Iterator<U> iterator;
        final BiFunction<? super T, ? super U, ? extends V> zipper;

        Disposable upstream;

        boolean done;

        ZipIterableObserver(Observer<? super V> actual, Iterator<U> iterator,
                BiFunction<? super T, ? super U, ? extends V> zipper) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 76

              
        Disposable upstream;

        boolean done;

        ZipIterableObserver(Observer<? super V> actual, Iterator<U> iterator,
                BiFunction<? super T, ? super U, ? extends V> zipper) {
            this.downstream = actual;
            this.iterator = iterator;

            

Reported by PMD.

src/main/java/io/reactivex/rxjava3/internal/operators/parallel/ParallelReduce.java
17 issues
Avoid reassigning parameters such as 'subscribers'
Design

Line: 48

                  }

    @Override
    public void subscribe(Subscriber<? super R>[] subscribers) {
        subscribers = RxJavaPlugins.onSubscribe(this, subscribers);

        if (!validate(subscribers)) {
            return;
        }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 35

               */
public final class ParallelReduce<T, R> extends ParallelFlowable<R> {

    final ParallelFlowable<? extends T> source;

    final Supplier<R> initialSupplier;

    final BiFunction<R, ? super T, R> reducer;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 37

              
    final ParallelFlowable<? extends T> source;

    final Supplier<R> initialSupplier;

    final BiFunction<R, ? super T, R> reducer;

    public ParallelReduce(ParallelFlowable<? extends T> source, Supplier<R> initialSupplier, BiFunction<R, ? super T, R> reducer) {
        this.source = source;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 39

              
    final Supplier<R> initialSupplier;

    final BiFunction<R, ? super T, R> reducer;

    public ParallelReduce(ParallelFlowable<? extends T> source, Supplier<R> initialSupplier, BiFunction<R, ? super T, R> reducer) {
        this.source = source;
        this.initialSupplier = initialSupplier;
        this.reducer = reducer;

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 65

              
            try {
                initialValue = Objects.requireNonNull(initialSupplier.get(), "The initialSupplier returned a null value");
            } catch (Throwable ex) {
                Exceptions.throwIfFatal(ex);
                reportError(subscribers, ex);
                return;
            }


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 92

              
        private static final long serialVersionUID = 8200530050639449080L;

        final BiFunction<R, ? super T, R> reducer;

        R accumulator;

        boolean done;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 94

              
        final BiFunction<R, ? super T, R> reducer;

        R accumulator;

        boolean done;

        ParallelReduceSubscriber(Subscriber<? super R> subscriber, R initialValue, BiFunction<R, ? super T, R> reducer) {
            super(subscriber);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 96

              
        R accumulator;

        boolean done;

        ParallelReduceSubscriber(Subscriber<? super R> subscriber, R initialValue, BiFunction<R, ? super T, R> reducer) {
            super(subscriber);
            this.accumulator = initialValue;
            this.reducer = reducer;

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 122

              
                try {
                    v = Objects.requireNonNull(reducer.apply(accumulator, t), "The reducer returned a null value");
                } catch (Throwable ex) {
                    Exceptions.throwIfFatal(ex);
                    cancel();
                    onError(ex);
                    return;
                }

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 140

                              return;
            }
            done = true;
            accumulator = null;
            downstream.onError(t);
        }

        @Override
        public void onComplete() {

            

Reported by PMD.

src/jmh/java/io/reactivex/rxjava3/core/RxVsStreamPerf.java
17 issues
The class 'RxVsStreamPerf' is suspected to be a Data Class (WOC=14.286%, NOPA=1, NOAM=6, WMC=7)
Design

Line: 31

              @OutputTimeUnit(TimeUnit.SECONDS)
@Fork(value = 1)
@State(Scope.Thread)
public class RxVsStreamPerf {
    @Param({ "1", "1000", "1000000" })
    public int times;

    Flowable<Integer> range;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

              @State(Scope.Thread)
public class RxVsStreamPerf {
    @Param({ "1", "1000", "1000000" })
    public int times;

    Flowable<Integer> range;

    Observable<Integer> rangeObservable;


            

Reported by PMD.

Field range has the same name as a method
Error

Line: 35

                  @Param({ "1", "1000", "1000000" })
    public int times;

    Flowable<Integer> range;

    Observable<Integer> rangeObservable;

    Flowable<Integer> rangeFlatMap;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 35

                  @Param({ "1", "1000", "1000000" })
    public int times;

    Flowable<Integer> range;

    Observable<Integer> rangeObservable;

    Flowable<Integer> rangeFlatMap;


            

Reported by PMD.

Field rangeObservable has the same name as a method
Error

Line: 37

              
    Flowable<Integer> range;

    Observable<Integer> rangeObservable;

    Flowable<Integer> rangeFlatMap;

    Observable<Integer> rangeObservableFlatMap;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 37

              
    Flowable<Integer> range;

    Observable<Integer> rangeObservable;

    Flowable<Integer> rangeFlatMap;

    Observable<Integer> rangeObservableFlatMap;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 39

              
    Observable<Integer> rangeObservable;

    Flowable<Integer> rangeFlatMap;

    Observable<Integer> rangeObservableFlatMap;

    Flowable<Integer> rangeFlatMapJust;


            

Reported by PMD.

Field rangeFlatMap has the same name as a method
Error

Line: 39

              
    Observable<Integer> rangeObservable;

    Flowable<Integer> rangeFlatMap;

    Observable<Integer> rangeObservableFlatMap;

    Flowable<Integer> rangeFlatMapJust;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 41

              
    Flowable<Integer> rangeFlatMap;

    Observable<Integer> rangeObservableFlatMap;

    Flowable<Integer> rangeFlatMapJust;

    Observable<Integer> rangeObservableFlatMapJust;


            

Reported by PMD.

Field rangeObservableFlatMap has the same name as a method
Error

Line: 41

              
    Flowable<Integer> rangeFlatMap;

    Observable<Integer> rangeObservableFlatMap;

    Flowable<Integer> rangeFlatMapJust;

    Observable<Integer> rangeObservableFlatMapJust;


            

Reported by PMD.

src/main/java/io/reactivex/rxjava3/internal/schedulers/InstantPeriodicTask.java
17 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 28

               */
final class InstantPeriodicTask implements Callable<Void>, Disposable {

    final Runnable task;

    final AtomicReference<Future<?>> rest;

    final AtomicReference<Future<?>> first;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 30

              
    final Runnable task;

    final AtomicReference<Future<?>> rest;

    final AtomicReference<Future<?>> first;

    final ExecutorService executor;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 32

              
    final AtomicReference<Future<?>> rest;

    final AtomicReference<Future<?>> first;

    final ExecutorService executor;

    Thread runner;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 34

              
    final AtomicReference<Future<?>> first;

    final ExecutorService executor;

    Thread runner;

    static final FutureTask<Void> CANCELLED = new FutureTask<>(Functions.EMPTY_RUNNABLE, null);


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 36

              
    final ExecutorService executor;

    Thread runner;

    static final FutureTask<Void> CANCELLED = new FutureTask<>(Functions.EMPTY_RUNNABLE, null);

    InstantPeriodicTask(Runnable task, ExecutorService executor) {
        super();

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 53

                      runner = Thread.currentThread();
        try {
            task.run();
            runner = null;
            setRest(executor.submit(this));
        } catch (Throwable ex) {
            // Exceptions.throwIfFatal(ex); nowhere to go
            runner = null;
            RxJavaPlugins.onError(ex);

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 55

                          task.run();
            runner = null;
            setRest(executor.submit(this));
        } catch (Throwable ex) {
            // Exceptions.throwIfFatal(ex); nowhere to go
            runner = null;
            RxJavaPlugins.onError(ex);
            throw ex;
        }

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 57

                          setRest(executor.submit(this));
        } catch (Throwable ex) {
            // Exceptions.throwIfFatal(ex); nowhere to go
            runner = null;
            RxJavaPlugins.onError(ex);
            throw ex;
        }
        return null;
    }

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 67

                  @Override
    public void dispose() {
        Future<?> current = first.getAndSet(CANCELLED);
        if (current != null && current != CANCELLED) {
            current.cancel(runner != Thread.currentThread());
        }
        current = rest.getAndSet(CANCELLED);
        if (current != null && current != CANCELLED) {
            current.cancel(runner != Thread.currentThread());

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 68

                  public void dispose() {
        Future<?> current = first.getAndSet(CANCELLED);
        if (current != null && current != CANCELLED) {
            current.cancel(runner != Thread.currentThread());
        }
        current = rest.getAndSet(CANCELLED);
        if (current != null && current != CANCELLED) {
            current.cancel(runner != Thread.currentThread());
        }

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/testsupport/BaseTestConsumerEx.java
17 issues
Possible God Class (WMC=50, ATFD=8, TCC=4.412%)
Design

Line: 29

               * @param <T> the value type consumed
 * @param <U> the subclass of this BaseTestConsumer
 */
public abstract class BaseTestConsumerEx<T, U extends BaseTestConsumerEx<T, U>>
extends BaseTestConsumer<T, U> {

    protected int initialFusionMode;

    protected int establishedFusionMode;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 30

               * @param <U> the subclass of this BaseTestConsumer
 */
public abstract class BaseTestConsumerEx<T, U extends BaseTestConsumerEx<T, U>>
extends BaseTestConsumer<T, U> {

    protected int initialFusionMode;

    protected int establishedFusionMode;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 46

                   * Indicates that one of the awaitX method has timed out.
     * @since 2.0.7
     */
    protected boolean timeout;

    public BaseTestConsumerEx() {
        super();
    }


            

Reported by PMD.

The String literal 'unchecked' appears 8 times in this file; the first occurrence is on line 71
Error

Line: 71

                   * @return this
     * @since 2.1
     */
    @SuppressWarnings("unchecked")
    public final U assertNever(T value) {
        int s = values.size();

        for (int i = 0; i < s; i++) {
            T v = this.values.get(i);

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 104

                              if (valuePredicate.test(v)) {
                    throw fail("Value at position " + i + " matches predicate " + valuePredicate.toString() + ", which was not expected.");
                }
            } catch (Throwable ex) {
                throw ExceptionHelper.wrapOrThrow(ex);
            }
        }
        return (U)this;
    }

            

Reported by PMD.

The method 'assertTerminated()' has a cyclomatic complexity of 10.
Design

Line: 116

                   * @return this
     */
    @SuppressWarnings("unchecked")
    public final U assertTerminated() {
        if (done.getCount() != 0) {
            throw fail("Subscriber still running!");
        }
        long c = completions;
        if (c > 1) {

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 121

                          throw fail("Subscriber still running!");
        }
        long c = completions;
        if (c > 1) {
            throw fail("Terminated with multiple completions: " + c);
        }
        int s = errors.size();
        if (s > 1) {
            throw fail("Terminated with multiple errors: " + s);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 125

                          throw fail("Terminated with multiple completions: " + c);
        }
        int s = errors.size();
        if (s > 1) {
            throw fail("Terminated with multiple errors: " + s);
        }

        if (c != 0 && s != 0) {
            throw fail("Terminated with multiple completions and errors: " + c);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 158

                      if (s == 0) {
            throw fail("No errors");
        } else
        if (s == 1) {
            Throwable e = errors.get(0);
            String errorMessage = e.getMessage();
            if (!Objects.equals(message, errorMessage)) {
                throw fail("Error message differs; exptected: " + message + " but was: " + errorMessage);
            }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 160

                      } else
        if (s == 1) {
            Throwable e = errors.get(0);
            String errorMessage = e.getMessage();
            if (!Objects.equals(message, errorMessage)) {
                throw fail("Error message differs; exptected: " + message + " but was: " + errorMessage);
            }
        } else {
            throw fail("Multiple errors");

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/schedulers/SchedulerTestHelper.java
17 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 41

                          CapturingObserver<Object> observer = new CapturingObserver<>();
            Thread.setDefaultUncaughtExceptionHandler(handler);
            IllegalStateException error = new IllegalStateException("Should be delivered to handler");
            Flowable.error(error)
                    .subscribeOn(scheduler)
                    .subscribe(observer);

            if (!observer.completed.await(3, TimeUnit.SECONDS)) {
                fail("timed out");

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 41

                          CapturingObserver<Object> observer = new CapturingObserver<>();
            Thread.setDefaultUncaughtExceptionHandler(handler);
            IllegalStateException error = new IllegalStateException("Should be delivered to handler");
            Flowable.error(error)
                    .subscribeOn(scheduler)
                    .subscribe(observer);

            if (!observer.completed.await(3, TimeUnit.SECONDS)) {
                fail("timed out");

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 45

                                  .subscribeOn(scheduler)
                    .subscribe(observer);

            if (!observer.completed.await(3, TimeUnit.SECONDS)) {
                fail("timed out");
            }

            if (handler.count != 0) {
                handler.caught.printStackTrace();

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 50

                          }

            if (handler.count != 0) {
                handler.caught.printStackTrace();
            }
            assertEquals("Handler should not have received anything: " + handler.caught, 0, handler.count);
            assertEquals("Observer should have received an error", 1, observer.errorCount);
            assertEquals("Observer should not have received a next value", 0, observer.nextCount);


            

Reported by PMD.

Avoid printStackTrace(); use a logger call instead.
Design

Line: 50

                          }

            if (handler.count != 0) {
                handler.caught.printStackTrace();
            }
            assertEquals("Handler should not have received anything: " + handler.caught, 0, handler.count);
            assertEquals("Observer should have received an error", 1, observer.errorCount);
            assertEquals("Observer should not have received a next value", 0, observer.nextCount);


            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 59

                          Throwable cause = observer.error;
            while (cause != null) {
                if (error.equals(cause)) { break; }
                if (cause == cause.getCause()) { break; }
                cause = cause.getCause();
            }
            assertEquals("Our error should have been delivered to the observer", error, cause);
        } finally {
            Thread.setDefaultUncaughtExceptionHandler(originalHandler);

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 59

                          Throwable cause = observer.error;
            while (cause != null) {
                if (error.equals(cause)) { break; }
                if (cause == cause.getCause()) { break; }
                cause = cause.getCause();
            }
            assertEquals("Our error should have been delivered to the observer", error, cause);
        } finally {
            Thread.setDefaultUncaughtExceptionHandler(originalHandler);

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 60

                          while (cause != null) {
                if (error.equals(cause)) { break; }
                if (cause == cause.getCause()) { break; }
                cause = cause.getCause();
            }
            assertEquals("Our error should have been delivered to the observer", error, cause);
        } finally {
            Thread.setDefaultUncaughtExceptionHandler(originalHandler);
        }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 69

                  }

    private static final class CapturingUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
        int count;
        Throwable caught;
        CountDownLatch completed = new CountDownLatch(1);

        @Override
        public void uncaughtException(Thread t, Throwable e) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 70

              
    private static final class CapturingUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
        int count;
        Throwable caught;
        CountDownLatch completed = new CountDownLatch(1);

        @Override
        public void uncaughtException(Thread t, Throwable e) {
            count++;

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/schedulers/ImmediateThinSchedulerTest.java
17 issues
JUnit assertions should include a message
Design

Line: 39

                          }
        });

        assertEquals(1, count[0]);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void scheduleDirectTimed() {
        ImmediateThinScheduler.INSTANCE.scheduleDirect(Functions.EMPTY_RUNNABLE, 1, TimeUnit.SECONDS);

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 44

              
    @Test(expected = UnsupportedOperationException.class)
    public void scheduleDirectTimed() {
        ImmediateThinScheduler.INSTANCE.scheduleDirect(Functions.EMPTY_RUNNABLE, 1, TimeUnit.SECONDS);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void scheduleDirectPeriodic() {
        ImmediateThinScheduler.INSTANCE.schedulePeriodicallyDirect(Functions.EMPTY_RUNNABLE, 1, 1, TimeUnit.SECONDS);

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 49

              
    @Test(expected = UnsupportedOperationException.class)
    public void scheduleDirectPeriodic() {
        ImmediateThinScheduler.INSTANCE.schedulePeriodicallyDirect(Functions.EMPTY_RUNNABLE, 1, 1, TimeUnit.SECONDS);
    }

    @Test
    public void schedule() {
        final int[] count = { 0 };

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 53

                  }

    @Test
    public void schedule() {
        final int[] count = { 0 };

        Worker w = ImmediateThinScheduler.INSTANCE.createWorker();

        assertFalse(w.isDisposed());

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 56

                  public void schedule() {
        final int[] count = { 0 };

        Worker w = ImmediateThinScheduler.INSTANCE.createWorker();

        assertFalse(w.isDisposed());

        w.schedule(new Runnable() {
            @Override

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 58

              
        Worker w = ImmediateThinScheduler.INSTANCE.createWorker();

        assertFalse(w.isDisposed());

        w.schedule(new Runnable() {
            @Override
            public void run() {
                count[0]++;

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 58

              
        Worker w = ImmediateThinScheduler.INSTANCE.createWorker();

        assertFalse(w.isDisposed());

        w.schedule(new Runnable() {
            @Override
            public void run() {
                count[0]++;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 67

                          }
        });

        assertEquals(1, count[0]);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void scheduleTimed() {
        ImmediateThinScheduler.INSTANCE.createWorker().schedule(Functions.EMPTY_RUNNABLE, 1, TimeUnit.SECONDS);

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 72

              
    @Test(expected = UnsupportedOperationException.class)
    public void scheduleTimed() {
        ImmediateThinScheduler.INSTANCE.createWorker().schedule(Functions.EMPTY_RUNNABLE, 1, TimeUnit.SECONDS);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void schedulePeriodic() {
        ImmediateThinScheduler.INSTANCE.createWorker().schedulePeriodically(Functions.EMPTY_RUNNABLE, 1, 1, TimeUnit.SECONDS);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 72

              
    @Test(expected = UnsupportedOperationException.class)
    public void scheduleTimed() {
        ImmediateThinScheduler.INSTANCE.createWorker().schedule(Functions.EMPTY_RUNNABLE, 1, TimeUnit.SECONDS);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void schedulePeriodic() {
        ImmediateThinScheduler.INSTANCE.createWorker().schedulePeriodically(Functions.EMPTY_RUNNABLE, 1, 1, TimeUnit.SECONDS);

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/schedulers/TimedTest.java
17 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 27

              public class TimedTest extends RxJavaTest {

    @Test
    public void properties() {
        Timed<Integer> timed = new Timed<>(1, 5, TimeUnit.SECONDS);

        assertEquals(1, timed.value().intValue());
        assertEquals(5, timed.time());
        assertEquals(5000, timed.time(TimeUnit.MILLISECONDS));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                  public void properties() {
        Timed<Integer> timed = new Timed<>(1, 5, TimeUnit.SECONDS);

        assertEquals(1, timed.value().intValue());
        assertEquals(5, timed.time());
        assertEquals(5000, timed.time(TimeUnit.MILLISECONDS));
        assertSame(TimeUnit.SECONDS, timed.unit());
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 30

                  public void properties() {
        Timed<Integer> timed = new Timed<>(1, 5, TimeUnit.SECONDS);

        assertEquals(1, timed.value().intValue());
        assertEquals(5, timed.time());
        assertEquals(5000, timed.time(TimeUnit.MILLISECONDS));
        assertSame(TimeUnit.SECONDS, timed.unit());
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                      Timed<Integer> timed = new Timed<>(1, 5, TimeUnit.SECONDS);

        assertEquals(1, timed.value().intValue());
        assertEquals(5, timed.time());
        assertEquals(5000, timed.time(TimeUnit.MILLISECONDS));
        assertSame(TimeUnit.SECONDS, timed.unit());
    }

    @Test

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

              
        assertEquals(1, timed.value().intValue());
        assertEquals(5, timed.time());
        assertEquals(5000, timed.time(TimeUnit.MILLISECONDS));
        assertSame(TimeUnit.SECONDS, timed.unit());
    }

    @Test
    public void hashCodeOf() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                      assertEquals(1, timed.value().intValue());
        assertEquals(5, timed.time());
        assertEquals(5000, timed.time(TimeUnit.MILLISECONDS));
        assertSame(TimeUnit.SECONDS, timed.unit());
    }

    @Test
    public void hashCodeOf() {
        Timed<Integer> t1 = new Timed<>(1, 5, TimeUnit.SECONDS);

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 37

                  }

    @Test
    public void hashCodeOf() {
        Timed<Integer> t1 = new Timed<>(1, 5, TimeUnit.SECONDS);

        assertEquals(TimeUnit.SECONDS.hashCode() + 31 * (5 + 31 * 1), t1.hashCode());

        Timed<Integer> t2 = new Timed<>(0, 5, TimeUnit.SECONDS);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                  public void hashCodeOf() {
        Timed<Integer> t1 = new Timed<>(1, 5, TimeUnit.SECONDS);

        assertEquals(TimeUnit.SECONDS.hashCode() + 31 * (5 + 31 * 1), t1.hashCode());

        Timed<Integer> t2 = new Timed<>(0, 5, TimeUnit.SECONDS);

        assertEquals(TimeUnit.SECONDS.hashCode() + 31 * (5 + 31 * 0), t2.hashCode());
    }

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 40

                  public void hashCodeOf() {
        Timed<Integer> t1 = new Timed<>(1, 5, TimeUnit.SECONDS);

        assertEquals(TimeUnit.SECONDS.hashCode() + 31 * (5 + 31 * 1), t1.hashCode());

        Timed<Integer> t2 = new Timed<>(0, 5, TimeUnit.SECONDS);

        assertEquals(TimeUnit.SECONDS.hashCode() + 31 * (5 + 31 * 0), t2.hashCode());
    }

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 44

              
        Timed<Integer> t2 = new Timed<>(0, 5, TimeUnit.SECONDS);

        assertEquals(TimeUnit.SECONDS.hashCode() + 31 * (5 + 31 * 0), t2.hashCode());
    }

    @Test
    public void equalsWith() {
        Timed<Integer> t1 = new Timed<>(1, 5, TimeUnit.SECONDS);

            

Reported by PMD.