The following issues were found

src/test/java/io/reactivex/rxjava3/single/SingleCacheTest.java
51 issues
JUnit tests should include assert() or fail()
Design

Line: 27

              public class SingleCacheTest extends RxJavaTest {

    @Test
    public void normal() {
        Single<Integer> cache = Single.just(1).cache();

        cache
        .test()
        .assertResult(1);

            

Reported by PMD.

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

Line: 28

              
    @Test
    public void normal() {
        Single<Integer> cache = Single.just(1).cache();

        cache
        .test()
        .assertResult(1);


            

Reported by PMD.

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

Line: 30

                  public void normal() {
        Single<Integer> cache = Single.just(1).cache();

        cache
        .test()
        .assertResult(1);

        cache
        .test()

            

Reported by PMD.

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

Line: 30

                  public void normal() {
        Single<Integer> cache = Single.just(1).cache();

        cache
        .test()
        .assertResult(1);

        cache
        .test()

            

Reported by PMD.

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

Line: 34

                      .test()
        .assertResult(1);

        cache
        .test()
        .assertResult(1);
    }

    @Test

            

Reported by PMD.

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

Line: 34

                      .test()
        .assertResult(1);

        cache
        .test()
        .assertResult(1);
    }

    @Test

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 40

                  }

    @Test
    public void error() {
        Single<Object> cache = Single.error(new TestException())
        .cache();

        cache
        .test()

            

Reported by PMD.

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

Line: 44

                      Single<Object> cache = Single.error(new TestException())
        .cache();

        cache
        .test()
        .assertFailure(TestException.class);

        cache
        .test()

            

Reported by PMD.

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

Line: 48

                      .test()
        .assertFailure(TestException.class);

        cache
        .test()
        .assertFailure(TestException.class);
    }

    @Test

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 54

                  }

    @Test
    public void delayed() {
        PublishSubject<Integer> ps = PublishSubject.create();
        Single<Integer> cache = ps.single(-99).cache();

        TestObserver<Integer> to1 = cache.test();


            

Reported by PMD.

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableCreate.java
51 issues
Avoid reassigning parameters such as 't'
Design

Line: 137

                      }

        @Override
        public boolean tryOnError(Throwable t) {
           if (emitter.isCancelled() || done) {
               return false;
           }
           if (t == null) {
               t = ExceptionHelper.createNullPointerException("onError called with a null Throwable.");

            

Reported by PMD.

Avoid reassigning parameters such as 'e'
Design

Line: 273

                      }

        @Override
        public final void onError(Throwable e) {
            if (e == null) {
                e = ExceptionHelper.createNullPointerException("onError called with a null Throwable.");
            }
            if (!signalError(e)) {
                RxJavaPlugins.onError(e);

            

Reported by PMD.

Avoid reassigning parameters such as 'e'
Design

Line: 283

                      }

        @Override
        public final boolean tryOnError(Throwable e) {
            if (e == null) {
                e = ExceptionHelper.createNullPointerException("tryOnError called with a null Throwable.");
            }
            return signalError(e);
        }

            

Reported by PMD.

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

Line: 33

              
public final class FlowableCreate<T> extends Flowable<T> {

    final FlowableOnSubscribe<T> source;

    final BackpressureStrategy backpressure;

    public FlowableCreate(FlowableOnSubscribe<T> source, BackpressureStrategy backpressure) {
        this.source = source;

            

Reported by PMD.

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

Line: 35

              
    final FlowableOnSubscribe<T> source;

    final BackpressureStrategy backpressure;

    public FlowableCreate(FlowableOnSubscribe<T> source, BackpressureStrategy backpressure) {
        this.source = source;
        this.backpressure = backpressure;
    }

            

Reported by PMD.

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

Line: 72

                      t.onSubscribe(emitter);
        try {
            source.subscribe(emitter);
        } catch (Throwable ex) {
            Exceptions.throwIfFatal(ex);
            emitter.onError(ex);
        }
    }


            

Reported by PMD.

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

Line: 89

              
        private static final long serialVersionUID = 4883307006032401862L;

        final BaseEmitter<T> emitter;

        final AtomicThrowable errors;

        final SimplePlainQueue<T> queue;


            

Reported by PMD.

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

Line: 91

              
        final BaseEmitter<T> emitter;

        final AtomicThrowable errors;

        final SimplePlainQueue<T> queue;

        volatile boolean done;


            

Reported by PMD.

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

Line: 93

              
        final AtomicThrowable errors;

        final SimplePlainQueue<T> queue;

        volatile boolean done;

        SerializedEmitter(BaseEmitter<T> emitter) {
            this.emitter = emitter;

            

Reported by PMD.

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

Line: 95

              
        final SimplePlainQueue<T> queue;

        volatile boolean done;

        SerializedEmitter(BaseEmitter<T> emitter) {
            this.emitter = emitter;
            this.errors = new AtomicThrowable();
            this.queue = new SpscLinkedArrayQueue<>(16);

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/operators/completable/CompletableSwitchOnNextTest.java
51 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 33

                  public void normal() {
        Runnable run = mock(Runnable.class);

        Completable.switchOnNext(
                Flowable.range(1, 10)
                .map(v -> {
                    if (v % 2 == 0) {
                        return Completable.fromRunnable(run);
                    }

            

Reported by PMD.

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

Line: 33

                  public void normal() {
        Runnable run = mock(Runnable.class);

        Completable.switchOnNext(
                Flowable.range(1, 10)
                .map(v -> {
                    if (v % 2 == 0) {
                        return Completable.fromRunnable(run);
                    }

            

Reported by PMD.

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

Line: 34

                      Runnable run = mock(Runnable.class);

        Completable.switchOnNext(
                Flowable.range(1, 10)
                .map(v -> {
                    if (v % 2 == 0) {
                        return Completable.fromRunnable(run);
                    }
                    return Completable.complete();

            

Reported by PMD.

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

Line: 45

                      .test()
        .assertResult();

        verify(run, times(5)).run();
    }

    @Test
    public void normalDelayError() {
        Runnable run = mock(Runnable.class);

            

Reported by PMD.

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

Line: 52

                  public void normalDelayError() {
        Runnable run = mock(Runnable.class);

        Completable.switchOnNextDelayError(
                Flowable.range(1, 10)
                .map(v -> {
                    if (v % 2 == 0) {
                        return Completable.fromRunnable(run);
                    }

            

Reported by PMD.

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

Line: 52

                  public void normalDelayError() {
        Runnable run = mock(Runnable.class);

        Completable.switchOnNextDelayError(
                Flowable.range(1, 10)
                .map(v -> {
                    if (v % 2 == 0) {
                        return Completable.fromRunnable(run);
                    }

            

Reported by PMD.

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

Line: 53

                      Runnable run = mock(Runnable.class);

        Completable.switchOnNextDelayError(
                Flowable.range(1, 10)
                .map(v -> {
                    if (v % 2 == 0) {
                        return Completable.fromRunnable(run);
                    }
                    return Completable.complete();

            

Reported by PMD.

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

Line: 64

                      .test()
        .assertResult();

        verify(run, times(5)).run();
    }

    @Test
    public void noDelaySwitch() {
        PublishProcessor<Completable> pp = PublishProcessor.create();

            

Reported by PMD.

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

Line: 68

                  }

    @Test
    public void noDelaySwitch() {
        PublishProcessor<Completable> pp = PublishProcessor.create();

        TestObserver<Void> to = Completable.switchOnNext(pp).test();

        assertTrue(pp.hasSubscribers());

            

Reported by PMD.

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

Line: 71

                  public void noDelaySwitch() {
        PublishProcessor<Completable> pp = PublishProcessor.create();

        TestObserver<Void> to = Completable.switchOnNext(pp).test();

        assertTrue(pp.hasSubscribers());

        to.assertEmpty();


            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/observers/FutureSingleObserverTest.java
50 issues
The method 'cancel()' has a cyclomatic complexity of 13.
Design

Line: 34

              public class FutureSingleObserverTest extends RxJavaTest {

    @Test
    public void cancel() {
        final Future<?> f = Single.never().toFuture();

        assertFalse(f.isCancelled());
        assertFalse(f.isDone());


            

Reported by PMD.

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

Line: 34

              public class FutureSingleObserverTest extends RxJavaTest {

    @Test
    public void cancel() {
        final Future<?> f = Single.never().toFuture();

        assertFalse(f.isCancelled());
        assertFalse(f.isDone());


            

Reported by PMD.

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

Line: 35

              
    @Test
    public void cancel() {
        final Future<?> f = Single.never().toFuture();

        assertFalse(f.isCancelled());
        assertFalse(f.isDone());

        f.cancel(true);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                  public void cancel() {
        final Future<?> f = Single.never().toFuture();

        assertFalse(f.isCancelled());
        assertFalse(f.isDone());

        f.cancel(true);

        assertTrue(f.isCancelled());

            

Reported by PMD.

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

Line: 37

                  public void cancel() {
        final Future<?> f = Single.never().toFuture();

        assertFalse(f.isCancelled());
        assertFalse(f.isDone());

        f.cancel(true);

        assertTrue(f.isCancelled());

            

Reported by PMD.

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

Line: 38

                      final Future<?> f = Single.never().toFuture();

        assertFalse(f.isCancelled());
        assertFalse(f.isDone());

        f.cancel(true);

        assertTrue(f.isCancelled());
        assertTrue(f.isDone());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 38

                      final Future<?> f = Single.never().toFuture();

        assertFalse(f.isCancelled());
        assertFalse(f.isDone());

        f.cancel(true);

        assertTrue(f.isCancelled());
        assertTrue(f.isDone());

            

Reported by PMD.

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

Line: 40

                      assertFalse(f.isCancelled());
        assertFalse(f.isDone());

        f.cancel(true);

        assertTrue(f.isCancelled());
        assertTrue(f.isDone());

        try {

            

Reported by PMD.

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

Line: 42

              
        f.cancel(true);

        assertTrue(f.isCancelled());
        assertTrue(f.isDone());

        try {
            f.get();
            fail("Should have thrown!");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

              
        f.cancel(true);

        assertTrue(f.isCancelled());
        assertTrue(f.isDone());

        try {
            f.get();
            fail("Should have thrown!");

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/util/ObservableToFlowabeTestSync.java
50 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 31

                  static List<String> readAllLines(File f) {
        List<String> result = new ArrayList<>();
        try {
            BufferedReader in = new BufferedReader(new FileReader(f));
            try {
                String line;

                while ((line = in.readLine()) != null) {
                    result.add(line);

            

Reported by PMD.

System.out.println is used
Design

Line: 77

                          for (Method m : clazz.getMethods()) {
                if (!methods2.contains(m.getName()) && !methods2.contains(m.getName().replace("Observable", "Flowable"))) {
                    count++;
                    System.out.println();
                    System.out.print("java.lang.RuntimeException: missing > ");
                    System.out.println(m.getName());
                    System.out.print(" at ");
                    System.out.print(clazz.getName());
                    System.out.print(" (");

            

Reported by PMD.

System.out.print is used
Design

Line: 78

                              if (!methods2.contains(m.getName()) && !methods2.contains(m.getName().replace("Observable", "Flowable"))) {
                    count++;
                    System.out.println();
                    System.out.print("java.lang.RuntimeException: missing > ");
                    System.out.println(m.getName());
                    System.out.print(" at ");
                    System.out.print(clazz.getName());
                    System.out.print(" (");
                    System.out.print(clazz.getSimpleName());

            

Reported by PMD.

System.out.println is used
Design

Line: 79

                                  count++;
                    System.out.println();
                    System.out.print("java.lang.RuntimeException: missing > ");
                    System.out.println(m.getName());
                    System.out.print(" at ");
                    System.out.print(clazz.getName());
                    System.out.print(" (");
                    System.out.print(clazz.getSimpleName());
                    System.out.print(".java:");

            

Reported by PMD.

System.out.print is used
Design

Line: 80

                                  System.out.println();
                    System.out.print("java.lang.RuntimeException: missing > ");
                    System.out.println(m.getName());
                    System.out.print(" at ");
                    System.out.print(clazz.getName());
                    System.out.print(" (");
                    System.out.print(clazz.getSimpleName());
                    System.out.print(".java:");


            

Reported by PMD.

System.out.print is used
Design

Line: 81

                                  System.out.print("java.lang.RuntimeException: missing > ");
                    System.out.println(m.getName());
                    System.out.print(" at ");
                    System.out.print(clazz.getName());
                    System.out.print(" (");
                    System.out.print(clazz.getSimpleName());
                    System.out.print(".java:");

                    List<String> lines = readAllLines(f);

            

Reported by PMD.

System.out.print is used
Design

Line: 82

                                  System.out.println(m.getName());
                    System.out.print(" at ");
                    System.out.print(clazz.getName());
                    System.out.print(" (");
                    System.out.print(clazz.getSimpleName());
                    System.out.print(".java:");

                    List<String> lines = readAllLines(f);


            

Reported by PMD.

System.out.print is used
Design

Line: 83

                                  System.out.print(" at ");
                    System.out.print(clazz.getName());
                    System.out.print(" (");
                    System.out.print(clazz.getSimpleName());
                    System.out.print(".java:");

                    List<String> lines = readAllLines(f);

                    int j = 1;

            

Reported by PMD.

System.out.print is used
Design

Line: 84

                                  System.out.print(clazz.getName());
                    System.out.print(" (");
                    System.out.print(clazz.getSimpleName());
                    System.out.print(".java:");

                    List<String> lines = readAllLines(f);

                    int j = 1;
                    for (int i = 1; i <= lines.size(); i++) {

            

Reported by PMD.

System.out.print is used
Design

Line: 94

                                          j = i;
                        }
                    }
                    System.out.print(j);
                    System.out.println(")");

                    System.out.print(" at ");
                    System.out.print(clazz2.getName());
                    System.out.print(" (");

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/observers/DeferredScalarObserverTest.java
50 issues
This class has too many methods, consider refactoring it.
Design

Line: 30

              import io.reactivex.rxjava3.plugins.RxJavaPlugins;
import io.reactivex.rxjava3.testsupport.*;

public class DeferredScalarObserverTest extends RxJavaTest {

    static final class TakeFirst extends DeferredScalarObserver<Integer, Integer> {

        private static final long serialVersionUID = -2793723002312330530L;


            

Reported by PMD.

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

Line: 62

                          Disposable d = Disposable.empty();
            source.onSubscribe(d);

            assertTrue(d.isDisposed());

            source.onNext(1);

            to.assertResult(1);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 62

                          Disposable d = Disposable.empty();
            source.onSubscribe(d);

            assertTrue(d.isDisposed());

            source.onNext(1);

            to.assertResult(1);


            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 75

                  }

    @Test
    public void error() {
        TestObserver<Integer> to = new TestObserver<>();

        TakeFirst source = new TakeFirst(to);

        source.onSubscribe(Disposable.empty());

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 87

                  }

    @Test
    public void complete() {
        TestObserver<Integer> to = new TestObserver<>();

        TakeFirst source = new TakeFirst(to);

        source.onSubscribe(Disposable.empty());

            

Reported by PMD.

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

Line: 99

                  }

    @Test
    public void dispose() {
        TestObserver<Integer> to = new TestObserver<>();

        TakeFirst source = new TakeFirst(to);

        Disposable d = Disposable.empty();

            

Reported by PMD.

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

Line: 108

              
        source.onSubscribe(d);

        assertFalse(d.isDisposed());

        to.dispose();

        assertTrue(d.isDisposed());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 108

              
        source.onSubscribe(d);

        assertFalse(d.isDisposed());

        to.dispose();

        assertTrue(d.isDisposed());


            

Reported by PMD.

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

Line: 112

              
        to.dispose();

        assertTrue(d.isDisposed());

        assertTrue(source.isDisposed());
    }

    @Test

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 112

              
        to.dispose();

        assertTrue(d.isDisposed());

        assertTrue(source.isDisposed());
    }

    @Test

            

Reported by PMD.

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

Line: 32

              
public final class FlowableBufferBoundary<T, U extends Collection<? super T>, Open, Close>
extends AbstractFlowableWithUpstream<T, U> {
    final Supplier<U> bufferSupplier;
    final Publisher<? extends Open> bufferOpen;
    final Function<? super Open, ? extends Publisher<? extends Close>> bufferClose;

    public FlowableBufferBoundary(Flowable<T> source, Publisher<? extends Open> bufferOpen,
            Function<? super Open, ? extends Publisher<? extends Close>> bufferClose, Supplier<U> bufferSupplier) {

            

Reported by PMD.

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

Line: 33

              public final class FlowableBufferBoundary<T, U extends Collection<? super T>, Open, Close>
extends AbstractFlowableWithUpstream<T, U> {
    final Supplier<U> bufferSupplier;
    final Publisher<? extends Open> bufferOpen;
    final Function<? super Open, ? extends Publisher<? extends Close>> bufferClose;

    public FlowableBufferBoundary(Flowable<T> source, Publisher<? extends Open> bufferOpen,
            Function<? super Open, ? extends Publisher<? extends Close>> bufferClose, Supplier<U> bufferSupplier) {
        super(source);

            

Reported by PMD.

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

Line: 34

              extends AbstractFlowableWithUpstream<T, U> {
    final Supplier<U> bufferSupplier;
    final Publisher<? extends Open> bufferOpen;
    final Function<? super Open, ? extends Publisher<? extends Close>> bufferClose;

    public FlowableBufferBoundary(Flowable<T> source, Publisher<? extends Open> bufferOpen,
            Function<? super Open, ? extends Publisher<? extends Close>> bufferClose, Supplier<U> bufferSupplier) {
        super(source);
        this.bufferOpen = bufferOpen;

            

Reported by PMD.

The class 'BufferBoundarySubscriber' has a Standard Cyclomatic Complexity of 3 (Highest = 14).
Design

Line: 54

                      source.subscribe(parent);
    }

    static final class BufferBoundarySubscriber<T, C extends Collection<? super T>, Open, Close>
    extends AtomicInteger implements FlowableSubscriber<T>, Subscription {

        private static final long serialVersionUID = -8466418554264089604L;

        final Subscriber<? super C> downstream;

            

Reported by PMD.

The class 'BufferBoundarySubscriber' has a Modified Cyclomatic Complexity of 3 (Highest = 14).
Design

Line: 54

                      source.subscribe(parent);
    }

    static final class BufferBoundarySubscriber<T, C extends Collection<? super T>, Open, Close>
    extends AtomicInteger implements FlowableSubscriber<T>, Subscription {

        private static final long serialVersionUID = -8466418554264089604L;

        final Subscriber<? super C> downstream;

            

Reported by PMD.

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

Line: 55

                  }

    static final class BufferBoundarySubscriber<T, C extends Collection<? super T>, Open, Close>
    extends AtomicInteger implements FlowableSubscriber<T>, Subscription {

        private static final long serialVersionUID = -8466418554264089604L;

        final Subscriber<? super C> downstream;


            

Reported by PMD.

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

Line: 59

              
        private static final long serialVersionUID = -8466418554264089604L;

        final Subscriber<? super C> downstream;

        final Supplier<C> bufferSupplier;

        final Publisher<? extends Open> bufferOpen;


            

Reported by PMD.

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

Line: 61

              
        final Subscriber<? super C> downstream;

        final Supplier<C> bufferSupplier;

        final Publisher<? extends Open> bufferOpen;

        final Function<? super Open, ? extends Publisher<? extends Close>> bufferClose;


            

Reported by PMD.

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

Line: 63

              
        final Supplier<C> bufferSupplier;

        final Publisher<? extends Open> bufferOpen;

        final Function<? super Open, ? extends Publisher<? extends Close>> bufferClose;

        final CompositeDisposable subscribers;


            

Reported by PMD.

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

Line: 65

              
        final Publisher<? extends Open> bufferOpen;

        final Function<? super Open, ? extends Publisher<? extends Close>> bufferClose;

        final CompositeDisposable subscribers;

        final AtomicLong requested;


            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableFromSupplierTest.java
50 issues
This class has too many methods, consider refactoring it.
Design

Line: 36

              import io.reactivex.rxjava3.schedulers.Schedulers;
import io.reactivex.rxjava3.testsupport.TestHelper;

public class ObservableFromSupplierTest extends RxJavaTest {

    @SuppressWarnings("unchecked")
    @Test
    public void shouldNotInvokeFuncUntilSubscription() throws Throwable {
        Supplier<Object> func = mock(Supplier.class);

            

Reported by PMD.

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

Line: 38

              
public class ObservableFromSupplierTest extends RxJavaTest {

    @SuppressWarnings("unchecked")
    @Test
    public void shouldNotInvokeFuncUntilSubscription() throws Throwable {
        Supplier<Object> func = mock(Supplier.class);

        when(func.get()).thenReturn(new Object());

            

Reported by PMD.

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

Line: 43

                  public void shouldNotInvokeFuncUntilSubscription() throws Throwable {
        Supplier<Object> func = mock(Supplier.class);

        when(func.get()).thenReturn(new Object());

        Observable<Object> fromSupplierObservable = Observable.fromSupplier(func);

        verifyNoInteractions(func);


            

Reported by PMD.

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

Line: 49

              
        verifyNoInteractions(func);

        fromSupplierObservable.subscribe();

        verify(func).get();
    }

    @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 51

              
        fromSupplierObservable.subscribe();

        verify(func).get();
    }

    @SuppressWarnings("unchecked")
    @Test
    public void shouldCallOnNextAndOnCompleted() throws Throwable {

            

Reported by PMD.

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

Line: 59

                  public void shouldCallOnNextAndOnCompleted() throws Throwable {
        Supplier<String> func = mock(Supplier.class);

        when(func.get()).thenReturn("test_value");

        Observable<String> fromSupplierObservable = Observable.fromSupplier(func);

        Observer<Object> observer = TestHelper.mockObserver();


            

Reported by PMD.

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

Line: 59

                  public void shouldCallOnNextAndOnCompleted() throws Throwable {
        Supplier<String> func = mock(Supplier.class);

        when(func.get()).thenReturn("test_value");

        Observable<String> fromSupplierObservable = Observable.fromSupplier(func);

        Observer<Object> observer = TestHelper.mockObserver();


            

Reported by PMD.

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

Line: 65

              
        Observer<Object> observer = TestHelper.mockObserver();

        fromSupplierObservable.subscribe(observer);

        verify(observer).onNext("test_value");
        verify(observer).onComplete();
        verify(observer, never()).onError(any(Throwable.class));
    }

            

Reported by PMD.

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

Line: 67

              
        fromSupplierObservable.subscribe(observer);

        verify(observer).onNext("test_value");
        verify(observer).onComplete();
        verify(observer, never()).onError(any(Throwable.class));
    }

    @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 68

                      fromSupplierObservable.subscribe(observer);

        verify(observer).onNext("test_value");
        verify(observer).onComplete();
        verify(observer, never()).onError(any(Throwable.class));
    }

    @SuppressWarnings("unchecked")
    @Test

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableToFutureTest.java
50 issues
A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 32

              public class ObservableToFutureTest extends RxJavaTest {

    @Test
    public void success() throws Exception {
        @SuppressWarnings("unchecked")
        Future<Object> future = mock(Future.class);
        Object value = new Object();
        when(future.get()).thenReturn(value);


            

Reported by PMD.

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

Line: 33

              
    @Test
    public void success() throws Exception {
        @SuppressWarnings("unchecked")
        Future<Object> future = mock(Future.class);
        Object value = new Object();
        when(future.get()).thenReturn(value);

        Observer<Object> o = TestHelper.mockObserver();

            

Reported by PMD.

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

Line: 36

                      @SuppressWarnings("unchecked")
        Future<Object> future = mock(Future.class);
        Object value = new Object();
        when(future.get()).thenReturn(value);

        Observer<Object> o = TestHelper.mockObserver();

        TestObserver<Object> to = new TestObserver<>(o);


            

Reported by PMD.

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

Line: 36

                      @SuppressWarnings("unchecked")
        Future<Object> future = mock(Future.class);
        Object value = new Object();
        when(future.get()).thenReturn(value);

        Observer<Object> o = TestHelper.mockObserver();

        TestObserver<Object> to = new TestObserver<>(o);


            

Reported by PMD.

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

Line: 42

              
        TestObserver<Object> to = new TestObserver<>(o);

        Observable.fromFuture(future).subscribe(to);

        to.dispose();

        verify(o, times(1)).onNext(value);
        verify(o, times(1)).onComplete();

            

Reported by PMD.

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

Line: 46

              
        to.dispose();

        verify(o, times(1)).onNext(value);
        verify(o, times(1)).onComplete();
        verify(o, never()).onError(any(Throwable.class));
        verify(future, never()).cancel(true);
    }


            

Reported by PMD.

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

Line: 47

                      to.dispose();

        verify(o, times(1)).onNext(value);
        verify(o, times(1)).onComplete();
        verify(o, never()).onError(any(Throwable.class));
        verify(future, never()).cancel(true);
    }

    @Test

            

Reported by PMD.

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

Line: 48

              
        verify(o, times(1)).onNext(value);
        verify(o, times(1)).onComplete();
        verify(o, never()).onError(any(Throwable.class));
        verify(future, never()).cancel(true);
    }

    @Test
    public void successOperatesOnSuppliedScheduler() throws Exception {

            

Reported by PMD.

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

Line: 49

                      verify(o, times(1)).onNext(value);
        verify(o, times(1)).onComplete();
        verify(o, never()).onError(any(Throwable.class));
        verify(future, never()).cancel(true);
    }

    @Test
    public void successOperatesOnSuppliedScheduler() throws Exception {
        @SuppressWarnings("unchecked")

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 53

                  }

    @Test
    public void successOperatesOnSuppliedScheduler() throws Exception {
        @SuppressWarnings("unchecked")
        Future<Object> future = mock(Future.class);
        Object value = new Object();
        when(future.get()).thenReturn(value);


            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeFromCallableTest.java
50 issues
JUnit assertions should include a message
Design

Line: 51

                          .test()
            .assertResult();

        assertEquals(1, atomicInteger.get());
    }

    @Test
    public void fromCallableTwice() {
        final AtomicInteger atomicInteger = new AtomicInteger();

            

Reported by PMD.

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

Line: 55

                  }

    @Test
    public void fromCallableTwice() {
        final AtomicInteger atomicInteger = new AtomicInteger();

        Callable<Object> callable = new Callable<Object>() {
            @Override
            public Object call() throws Exception {

            

Reported by PMD.

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

Line: 66

                          }
        };

        Maybe.fromCallable(callable)
            .test()
            .assertResult();

        assertEquals(1, atomicInteger.get());


            

Reported by PMD.

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

Line: 66

                          }
        };

        Maybe.fromCallable(callable)
            .test()
            .assertResult();

        assertEquals(1, atomicInteger.get());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 70

                          .test()
            .assertResult();

        assertEquals(1, atomicInteger.get());

        Maybe.fromCallable(callable)
            .test()
            .assertResult();


            

Reported by PMD.

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

Line: 72

              
        assertEquals(1, atomicInteger.get());

        Maybe.fromCallable(callable)
            .test()
            .assertResult();

        assertEquals(2, atomicInteger.get());
    }

            

Reported by PMD.

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

Line: 72

              
        assertEquals(1, atomicInteger.get());

        Maybe.fromCallable(callable)
            .test()
            .assertResult();

        assertEquals(2, atomicInteger.get());
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 76

                          .test()
            .assertResult();

        assertEquals(2, atomicInteger.get());
    }

    @Test
    public void fromCallableInvokesLazy() {
        final AtomicInteger atomicInteger = new AtomicInteger();

            

Reported by PMD.

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

Line: 80

                  }

    @Test
    public void fromCallableInvokesLazy() {
        final AtomicInteger atomicInteger = new AtomicInteger();

        Maybe<Object> completable = Maybe.fromCallable(new Callable<Object>() {
            @Override
            public Object call() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 91

                          }
        });

        assertEquals(0, atomicInteger.get());

        completable
            .test()
            .assertResult();


            

Reported by PMD.