The following issues were found

src/test/java/io/reactivex/rxjava3/internal/operators/single/SingleTimerTest.java
9 issues
JUnit tests should include assert() or fail()
Design

Line: 32

              public class SingleTimerTest extends RxJavaTest {

    @Test
    public void disposed() {
        TestHelper.checkDisposed(Single.timer(1, TimeUnit.SECONDS, new TestScheduler()));
    }

    @Test
    public void timerInterruptible() throws Exception {

            

Reported by PMD.

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

Line: 37

                  }

    @Test
    public void timerInterruptible() throws Exception {
        ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
        try {
            for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Single.timer(1, TimeUnit.MILLISECONDS, s)

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 41

                      ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
        try {
            for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Single.timer(1, TimeUnit.MILLISECONDS, s)
                .map(new Function<Long, Long>() {
                    @Override
                    public Long apply(Long v) throws Exception {
                        try {

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 43

                          for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Single.timer(1, TimeUnit.MILLISECONDS, s)
                .map(new Function<Long, Long>() {
                    @Override
                    public Long apply(Long v) throws Exception {
                        try {
                        Thread.sleep(3000);
                        } catch (InterruptedException ex) {

            

Reported by PMD.

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

Line: 62

              
                Thread.sleep(500);

                assertTrue(s.getClass().getSimpleName(), interrupted.get());
            }
        } finally {
            exec.shutdown();
        }
    }

            

Reported by PMD.

Avoid unused imports such as 'io.reactivex.rxjava3.core'
Design

Line: 23

              
import org.junit.Test;

import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.schedulers.*;
import io.reactivex.rxjava3.testsupport.TestHelper;


            

Reported by PMD.

Avoid unused imports such as 'io.reactivex.rxjava3.schedulers'
Design

Line: 26

              import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.schedulers.*;
import io.reactivex.rxjava3.testsupport.TestHelper;

public class SingleTimerTest extends RxJavaTest {

    @Test

            

Reported by PMD.

Found 'DU'-anomaly for variable 'to' (lines '42'-'67').
Error

Line: 42

                      try {
            for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Single.timer(1, TimeUnit.MILLISECONDS, s)
                .map(new Function<Long, Long>() {
                    @Override
                    public Long apply(Long v) throws Exception {
                        try {
                        Thread.sleep(3000);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'to' (lines '42'-'67').
Error

Line: 42

                      try {
            for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Single.timer(1, TimeUnit.MILLISECONDS, s)
                .map(new Function<Long, Long>() {
                    @Override
                    public Long apply(Long v) throws Exception {
                        try {
                        Thread.sleep(3000);

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/operators/single/SingleMergeArrayTest.java
9 issues
JUnit tests should include assert() or fail()
Design

Line: 24

              public class SingleMergeArrayTest extends RxJavaTest {

    @Test
    public void normal() {
        Single.mergeArray(Single.just(1), Single.just(2), Single.just(3))
        .test()
        .assertResult(1, 2, 3);
    }


            

Reported by PMD.

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

Line: 25

              
    @Test
    public void normal() {
        Single.mergeArray(Single.just(1), Single.just(2), Single.just(3))
        .test()
        .assertResult(1, 2, 3);
    }

    @Test

            

Reported by PMD.

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

Line: 25

              
    @Test
    public void normal() {
        Single.mergeArray(Single.just(1), Single.just(2), Single.just(3))
        .test()
        .assertResult(1, 2, 3);
    }

    @Test

            

Reported by PMD.

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

Line: 31

                  }

    @Test
    public void error() {
        Single.mergeArray(Single.just(1), Single.error(new TestException()), Single.just(3))
        .test()
        .assertFailure(TestException.class, 1);
    }


            

Reported by PMD.

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

Line: 38

                  }

    @Test
    public void normalDelayError() {
        Single.mergeArrayDelayError(Single.just(1), Single.just(2), Single.just(3))
        .test()
        .assertResult(1, 2, 3);
    }


            

Reported by PMD.

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

Line: 39

              
    @Test
    public void normalDelayError() {
        Single.mergeArrayDelayError(Single.just(1), Single.just(2), Single.just(3))
        .test()
        .assertResult(1, 2, 3);
    }

    @Test

            

Reported by PMD.

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

Line: 39

              
    @Test
    public void normalDelayError() {
        Single.mergeArrayDelayError(Single.just(1), Single.just(2), Single.just(3))
        .test()
        .assertResult(1, 2, 3);
    }

    @Test

            

Reported by PMD.

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

Line: 45

                  }

    @Test
    public void errorDelayError() {
        Single.mergeArrayDelayError(Single.just(1), Single.error(new TestException()), Single.just(3))
        .test()
        .assertFailure(TestException.class, 1, 3);
    }
}

            

Reported by PMD.

Avoid unused imports such as 'io.reactivex.rxjava3.core'
Design

Line: 18

              
import org.junit.Test;

import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.exceptions.TestException;

public class SingleMergeArrayTest extends RxJavaTest {

    @Test

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/observers/DisposableLambdaObserverTest.java
9 issues
JUnit tests should include assert() or fail()
Design

Line: 34

              public class DisposableLambdaObserverTest extends RxJavaTest {

    @Test
    public void doubleOnSubscribe() {
        TestHelper.doubleOnSubscribe(new DisposableLambdaObserver<>(
                new TestObserver<>(), Functions.emptyConsumer(), Functions.EMPTY_ACTION
        ));
    }


            

Reported by PMD.

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

Line: 41

                  }

    @Test
    public void disposeCrash() {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            DisposableLambdaObserver<Integer> o = new DisposableLambdaObserver<>(
                    new TestObserver<>(), Functions.emptyConsumer(),
                    new Action() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 56

              
            o.onSubscribe(Disposable.empty());

            assertFalse(o.isDisposed());

            o.dispose();

            assertTrue(o.isDisposed());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 60

              
            o.dispose();

            assertTrue(o.isDisposed());

            TestHelper.assertUndeliverable(errors, 0, TestException.class);
        } finally {
            RxJavaPlugins.reset();
        }

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Assert'
Design

Line: 16

              
package io.reactivex.rxjava3.internal.observers;

import static org.junit.Assert.*;

import java.util.List;

import io.reactivex.rxjava3.disposables.Disposable;
import org.junit.Test;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'errors' (lines '42'-'66').
Error

Line: 42

              
    @Test
    public void disposeCrash() {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            DisposableLambdaObserver<Integer> o = new DisposableLambdaObserver<>(
                    new TestObserver<>(), Functions.emptyConsumer(),
                    new Action() {
                        @Override

            

Reported by PMD.

Found 'DU'-anomaly for variable 'errors' (lines '42'-'66').
Error

Line: 42

              
    @Test
    public void disposeCrash() {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            DisposableLambdaObserver<Integer> o = new DisposableLambdaObserver<>(
                    new TestObserver<>(), Functions.emptyConsumer(),
                    new Action() {
                        @Override

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '44'-'66').
Error

Line: 44

                  public void disposeCrash() {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            DisposableLambdaObserver<Integer> o = new DisposableLambdaObserver<>(
                    new TestObserver<>(), Functions.emptyConsumer(),
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            throw new TestException();

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '44'-'66').
Error

Line: 44

                  public void disposeCrash() {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            DisposableLambdaObserver<Integer> o = new DisposableLambdaObserver<>(
                    new TestObserver<>(), Functions.emptyConsumer(),
                    new Action() {
                        @Override
                        public void run() throws Exception {
                            throw new TestException();

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeFromCompletableTest.java
9 issues
JUnit tests should include assert() or fail()
Design

Line: 28

              
public class MaybeFromCompletableTest extends RxJavaTest {
    @Test
    public void fromCompletable() {
        Maybe.fromCompletable(Completable.complete())
            .test()
            .assertResult();
    }


            

Reported by PMD.

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

Line: 29

              public class MaybeFromCompletableTest extends RxJavaTest {
    @Test
    public void fromCompletable() {
        Maybe.fromCompletable(Completable.complete())
            .test()
            .assertResult();
    }

    @Test

            

Reported by PMD.

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

Line: 29

              public class MaybeFromCompletableTest extends RxJavaTest {
    @Test
    public void fromCompletable() {
        Maybe.fromCompletable(Completable.complete())
            .test()
            .assertResult();
    }

    @Test

            

Reported by PMD.

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

Line: 35

                  }

    @Test
    public void fromCompletableError() {
        Maybe.fromCompletable(Completable.error(new UnsupportedOperationException()))
            .test()
            .assertFailure(UnsupportedOperationException.class);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  public void source() {
        Completable c = Completable.complete();

        assertSame(c, ((HasUpstreamCompletableSource)Maybe.fromCompletable(c)).source());
    }

    @Test
    public void dispose() {
        TestHelper.checkDisposed(Maybe.fromCompletable(PublishProcessor.create().ignoreElements()));

            

Reported by PMD.

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

Line: 49

                  }

    @Test
    public void dispose() {
        TestHelper.checkDisposed(Maybe.fromCompletable(PublishProcessor.create().ignoreElements()));
    }

    @Test
    public void doubleOnSubscribe() {

            

Reported by PMD.

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

Line: 50

              
    @Test
    public void dispose() {
        TestHelper.checkDisposed(Maybe.fromCompletable(PublishProcessor.create().ignoreElements()));
    }

    @Test
    public void doubleOnSubscribe() {
        TestHelper.checkDoubleOnSubscribeCompletableToMaybe(new Function<Completable, MaybeSource<Object>>() {

            

Reported by PMD.

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

Line: 54

                  }

    @Test
    public void doubleOnSubscribe() {
        TestHelper.checkDoubleOnSubscribeCompletableToMaybe(new Function<Completable, MaybeSource<Object>>() {
            @Override
            public MaybeSource<Object> apply(Completable v) throws Exception {
                return Maybe.fromCompletable(v);
            }

            

Reported by PMD.

Avoid unused imports such as 'io.reactivex.rxjava3.core'
Design

Line: 20

              
import org.junit.Test;

import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.internal.fuseable.HasUpstreamCompletableSource;
import io.reactivex.rxjava3.processors.PublishProcessor;
import io.reactivex.rxjava3.testsupport.TestHelper;


            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/core/Retry.java
9 issues
System.err.println is used
Design

Line: 45

                                  return;
                } catch (Throwable t) {
                    caughtThrowable = t;
                    System.err.println(description.getDisplayName() + ": run " + (i + 1) + " failed");
                    int n = sleep;
                    if (backoff && i != 0) {
                        n = n * (2 << i);
                    }
                    Thread.sleep(n);

            

Reported by PMD.

System.err.println is used
Design

Line: 53

                                  Thread.sleep(n);
                }
            }
            System.err.println(description.getDisplayName() + ": giving up after " + retryCount + " failures");
            throw caughtThrowable;
        }
    }

    final int retryCount;

            

Reported by PMD.

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

Line: 27

              public class Retry implements TestRule {

    final class RetryStatement extends Statement {
        private final Statement base;
        private final Description description;

        RetryStatement(Statement base, Description description) {
            this.base = base;
            this.description = description;

            

Reported by PMD.

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

Line: 28

              
    final class RetryStatement extends Statement {
        private final Statement base;
        private final Description description;

        RetryStatement(Statement base, Description description) {
            this.base = base;
            this.description = description;
        }

            

Reported by PMD.

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

Line: 43

                              try {
                    base.evaluate();
                    return;
                } catch (Throwable t) {
                    caughtThrowable = t;
                    System.err.println(description.getDisplayName() + ": run " + (i + 1) + " failed");
                    int n = sleep;
                    if (backoff && i != 0) {
                        n = n * (2 << i);

            

Reported by PMD.

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

Line: 58

                      }
    }

    final int retryCount;

    final int sleep;

    final boolean backoff;


            

Reported by PMD.

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

Line: 60

              
    final int retryCount;

    final int sleep;

    final boolean backoff;

    public Retry(int retryCount, int sleep, boolean backoff) {
        this.retryCount = retryCount;

            

Reported by PMD.

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

Line: 62

              
    final int sleep;

    final boolean backoff;

    public Retry(int retryCount, int sleep, boolean backoff) {
        this.retryCount = retryCount;
        this.sleep = sleep;
        this.backoff = backoff;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'caughtThrowable' (lines '37'-'55').
Error

Line: 37

              
        @Override
        public void evaluate() throws Throwable {
            Throwable caughtThrowable = null;

            for (int i = 0; i < retryCount; i++) {
                try {
                    base.evaluate();
                    return;

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/observers/BlockingMultiObserverTest.java
9 issues
JUnit tests should include assert() or fail()
Design

Line: 29

              public class BlockingMultiObserverTest extends RxJavaTest {

    @Test
    public void dispose() {
        BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<>();
        bmo.dispose();

        Disposable d = Disposable.empty();


            

Reported by PMD.

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

Line: 49

                          }
        }, 100, TimeUnit.MILLISECONDS);

        assertEquals(1, bmo.blockingGet(0).intValue());
    }

    @Test
    public void blockingAwait() {
        final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<>();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                          }
        }, 100, TimeUnit.MILLISECONDS);

        assertEquals(1, bmo.blockingGet(0).intValue());
    }

    @Test
    public void blockingAwait() {
        final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<>();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                          }
        }, 100, TimeUnit.MILLISECONDS);

        assertTrue(bmo.blockingAwait(1, TimeUnit.MINUTES));
    }

    @Test
    public void blockingGetDefaultInterrupt() {
        final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<>();

            

Reported by PMD.

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

Line: 70

                  public void blockingGetDefaultInterrupt() {
        final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<>();

        Thread.currentThread().interrupt();
        try {
            bmo.blockingGet(0);
            fail("Should have thrown");
        } catch (RuntimeException ex) {
            assertTrue(ex.getCause() instanceof InterruptedException);

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 74

                      try {
            bmo.blockingGet(0);
            fail("Should have thrown");
        } catch (RuntimeException ex) {
            assertTrue(ex.getCause() instanceof InterruptedException);
        } finally {
            Thread.interrupted();
        }
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 75

                          bmo.blockingGet(0);
            fail("Should have thrown");
        } catch (RuntimeException ex) {
            assertTrue(ex.getCause() instanceof InterruptedException);
        } finally {
            Thread.interrupted();
        }
    }
}

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Assert'
Design

Line: 16

              
package io.reactivex.rxjava3.internal.observers;

import static org.junit.Assert.*;

import java.util.concurrent.TimeUnit;

import org.junit.Test;


            

Reported by PMD.

Avoid unused imports such as 'io.reactivex.rxjava3.disposables'
Design

Line: 23

              import org.junit.Test;

import io.reactivex.rxjava3.core.RxJavaTest;
import io.reactivex.rxjava3.disposables.*;
import io.reactivex.rxjava3.schedulers.Schedulers;

public class BlockingMultiObserverTest extends RxJavaTest {

    @Test

            

Reported by PMD.

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

Line: 30

              
        PublishProcessor<Integer> pp = PublishProcessor.create();

        pp.ignoreElements().test(true);

        assertFalse(pp.hasSubscribers());
    }

    @Test

            

Reported by PMD.

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

Line: 30

              
        PublishProcessor<Integer> pp = PublishProcessor.create();

        pp.ignoreElements().test(true);

        assertFalse(pp.hasSubscribers());
    }

    @Test

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

              
        pp.ignoreElements().test(true);

        assertFalse(pp.hasSubscribers());
    }

    @Test
    public void methodTestNoCancel() {
        PublishSubject<Integer> ps = PublishSubject.create();

            

Reported by PMD.

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

Line: 32

              
        pp.ignoreElements().test(true);

        assertFalse(pp.hasSubscribers());
    }

    @Test
    public void methodTestNoCancel() {
        PublishSubject<Integer> ps = PublishSubject.create();

            

Reported by PMD.

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

Line: 39

                  public void methodTestNoCancel() {
        PublishSubject<Integer> ps = PublishSubject.create();

        ps.ignoreElements().test(false);

        assertTrue(ps.hasObservers());
    }
}

            

Reported by PMD.

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

Line: 39

                  public void methodTestNoCancel() {
        PublishSubject<Integer> ps = PublishSubject.create();

        ps.ignoreElements().test(false);

        assertTrue(ps.hasObservers());
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

              
        ps.ignoreElements().test(false);

        assertTrue(ps.hasObservers());
    }
}

            

Reported by PMD.

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

Line: 41

              
        ps.ignoreElements().test(false);

        assertTrue(ps.hasObservers());
    }
}

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Assert'
Design

Line: 16

              
package io.reactivex.rxjava3.internal.operators.completable;

import static org.junit.Assert.*;

import org.junit.Test;

import io.reactivex.rxjava3.core.RxJavaTest;
import io.reactivex.rxjava3.processors.PublishProcessor;

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/observers/BasicFuseableObserverTest.java
9 issues
Found 'DU'-anomaly for variable 'o' (lines '29'-'56').
Error

Line: 29

                  @Test(expected = UnsupportedOperationException.class)
    public void offer() {
        TestObserverEx<Integer> to = new TestObserverEx<>();
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(to) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '29'-'56').
Error

Line: 29

                  @Test(expected = UnsupportedOperationException.class)
    public void offer() {
        TestObserverEx<Integer> to = new TestObserverEx<>();
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(to) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '29'-'56').
Error

Line: 29

                  @Test(expected = UnsupportedOperationException.class)
    public void offer() {
        TestObserverEx<Integer> to = new TestObserverEx<>();
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(to) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '29'-'56').
Error

Line: 29

                  @Test(expected = UnsupportedOperationException.class)
    public void offer() {
        TestObserverEx<Integer> to = new TestObserverEx<>();
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(to) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '29'-'56').
Error

Line: 29

                  @Test(expected = UnsupportedOperationException.class)
    public void offer() {
        TestObserverEx<Integer> to = new TestObserverEx<>();
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(to) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '60'-'78').
Error

Line: 60

              
    @Test(expected = UnsupportedOperationException.class)
    public void offer2() {
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(new TestObserver<>()) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '60'-'78').
Error

Line: 60

              
    @Test(expected = UnsupportedOperationException.class)
    public void offer2() {
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(new TestObserver<>()) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '60'-'78').
Error

Line: 60

              
    @Test(expected = UnsupportedOperationException.class)
    public void offer2() {
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(new TestObserver<>()) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'o' (lines '60'-'78').
Error

Line: 60

              
    @Test(expected = UnsupportedOperationException.class)
    public void offer2() {
        BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(new TestObserver<>()) {
            @Nullable
            @Override
            public Integer poll() throws Exception {
                return null;
            }

            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeFromSingleTest.java
9 issues
JUnit tests should include assert() or fail()
Design

Line: 28

              
public class MaybeFromSingleTest extends RxJavaTest {
    @Test
    public void fromSingle() {
        Maybe.fromSingle(Single.just(1))
            .test()
            .assertResult(1);
    }


            

Reported by PMD.

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

Line: 29

              public class MaybeFromSingleTest extends RxJavaTest {
    @Test
    public void fromSingle() {
        Maybe.fromSingle(Single.just(1))
            .test()
            .assertResult(1);
    }

    @Test

            

Reported by PMD.

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

Line: 29

              public class MaybeFromSingleTest extends RxJavaTest {
    @Test
    public void fromSingle() {
        Maybe.fromSingle(Single.just(1))
            .test()
            .assertResult(1);
    }

    @Test

            

Reported by PMD.

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

Line: 35

                  }

    @Test
    public void fromSingleThrows() {
        Maybe.fromSingle(Single.error(new UnsupportedOperationException()))
            .test()
            .assertFailure(UnsupportedOperationException.class);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  public void source() {
        Single<Integer> c = Single.never();

        assertSame(c, ((HasUpstreamSingleSource<?>)Maybe.fromSingle(c)).source());
    }

    @Test
    public void dispose() {
        TestHelper.checkDisposed(Maybe.fromSingle(PublishProcessor.create().singleOrError()));

            

Reported by PMD.

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

Line: 49

                  }

    @Test
    public void dispose() {
        TestHelper.checkDisposed(Maybe.fromSingle(PublishProcessor.create().singleOrError()));
    }

    @Test
    public void doubleOnSubscribe() {

            

Reported by PMD.

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

Line: 50

              
    @Test
    public void dispose() {
        TestHelper.checkDisposed(Maybe.fromSingle(PublishProcessor.create().singleOrError()));
    }

    @Test
    public void doubleOnSubscribe() {
        TestHelper.checkDoubleOnSubscribeSingleToMaybe(new Function<Single<Object>, MaybeSource<Object>>() {

            

Reported by PMD.

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

Line: 54

                  }

    @Test
    public void doubleOnSubscribe() {
        TestHelper.checkDoubleOnSubscribeSingleToMaybe(new Function<Single<Object>, MaybeSource<Object>>() {
            @Override
            public MaybeSource<Object> apply(Single<Object> v) throws Exception {
                return Maybe.fromSingle(v);
            }

            

Reported by PMD.

Avoid unused imports such as 'io.reactivex.rxjava3.core'
Design

Line: 20

              
import org.junit.Test;

import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.internal.fuseable.HasUpstreamSingleSource;
import io.reactivex.rxjava3.processors.PublishProcessor;
import io.reactivex.rxjava3.testsupport.TestHelper;


            

Reported by PMD.

src/test/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeTimerTest.java
9 issues
JUnit tests should include assert() or fail()
Design

Line: 32

              public class MaybeTimerTest extends RxJavaTest {

    @Test
    public void dispose() {
        TestHelper.checkDisposed(Maybe.timer(1, TimeUnit.SECONDS, new TestScheduler()));
    }

    @Test
    public void timerInterruptible() throws Exception {

            

Reported by PMD.

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

Line: 37

                  }

    @Test
    public void timerInterruptible() throws Exception {
        ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
        try {
            for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Maybe.timer(1, TimeUnit.MILLISECONDS, s)

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 41

                      ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
        try {
            for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Maybe.timer(1, TimeUnit.MILLISECONDS, s)
                .map(new Function<Long, Long>() {
                    @Override
                    public Long apply(Long v) throws Exception {
                        try {

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 43

                          for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Maybe.timer(1, TimeUnit.MILLISECONDS, s)
                .map(new Function<Long, Long>() {
                    @Override
                    public Long apply(Long v) throws Exception {
                        try {
                        Thread.sleep(3000);
                        } catch (InterruptedException ex) {

            

Reported by PMD.

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

Line: 62

              
                Thread.sleep(500);

                assertTrue(s.getClass().getSimpleName(), interrupted.get());
            }
        } finally {
            exec.shutdown();
        }
    }

            

Reported by PMD.

Avoid unused imports such as 'io.reactivex.rxjava3.core'
Design

Line: 23

              
import org.junit.Test;

import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.schedulers.*;
import io.reactivex.rxjava3.testsupport.TestHelper;


            

Reported by PMD.

Avoid unused imports such as 'io.reactivex.rxjava3.schedulers'
Design

Line: 26

              import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.schedulers.*;
import io.reactivex.rxjava3.testsupport.TestHelper;

public class MaybeTimerTest extends RxJavaTest {

    @Test

            

Reported by PMD.

Found 'DU'-anomaly for variable 'to' (lines '42'-'67').
Error

Line: 42

                      try {
            for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Maybe.timer(1, TimeUnit.MILLISECONDS, s)
                .map(new Function<Long, Long>() {
                    @Override
                    public Long apply(Long v) throws Exception {
                        try {
                        Thread.sleep(3000);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'to' (lines '42'-'67').
Error

Line: 42

                      try {
            for (Scheduler s : new Scheduler[] { Schedulers.single(), Schedulers.computation(), Schedulers.newThread(), Schedulers.io(), Schedulers.from(exec, true) }) {
                final AtomicBoolean interrupted = new AtomicBoolean();
                TestObserver<Long> to = Maybe.timer(1, TimeUnit.MILLISECONDS, s)
                .map(new Function<Long, Long>() {
                    @Override
                    public Long apply(Long v) throws Exception {
                        try {
                        Thread.sleep(3000);

            

Reported by PMD.