The following issues were found

android/guava-tests/test/com/google/common/primitives/BytesTest.java
150 issues
Avoid reassigning parameters such as 'input'
Design

Line: 250

                  testReverse(new byte[] {-1, 1, -2, 2}, new byte[] {2, -2, 1, -1});
  }

  private static void testReverse(byte[] input, byte[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    Bytes.reverse(input);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 256

                  assertTrue(Arrays.equals(expectedOutput, input));
  }

  private static void testReverse(byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    Bytes.reverse(input, fromIndex, toIndex);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

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

Line: 35

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class BytesTest extends TestCase {
  private static final byte[] EMPTY = {};
  private static final byte[] ARRAY1 = {(byte) 1};
  private static final byte[] ARRAY234 = {(byte) 2, (byte) 3, (byte) 4};

  private static final byte[] VALUES = {Byte.MIN_VALUE, -1, 0, 1, Byte.MAX_VALUE};

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 42

              
  private static final byte[] VALUES = {Byte.MIN_VALUE, -1, 0, 1, Byte.MAX_VALUE};

  public void testHashCode() {
    for (byte value : VALUES) {
      assertEquals(((Byte) value).hashCode(), Bytes.hashCode(value));
    }
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

              
  public void testHashCode() {
    for (byte value : VALUES) {
      assertEquals(((Byte) value).hashCode(), Bytes.hashCode(value));
    }
  }

  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 48

                  }
  }

  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));

            

Reported by PMD.

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

Line: 48

                  }
  }

  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                }

  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));
    assertTrue(Bytes.contains(ARRAY234, (byte) 3));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 50

              
  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));
    assertTrue(Bytes.contains(ARRAY234, (byte) 3));
    assertTrue(Bytes.contains(ARRAY234, (byte) 4));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));
    assertTrue(Bytes.contains(ARRAY234, (byte) 3));
    assertTrue(Bytes.contains(ARRAY234, (byte) 4));
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/OptionalTest.java
149 issues
Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 213

                public void testEqualsAndHashCode() {
    new EqualsTester()
        .addEqualityGroup(Optional.absent(), reserialize(Optional.absent()))
        .addEqualityGroup(Optional.of(new Long(5)), reserialize(Optional.of(new Long(5))))
        .addEqualityGroup(Optional.of(new Long(42)), reserialize(Optional.of(new Long(42))))
        .testEquals();
  }

  public void testToString_absent() {

            

Reported by PMD.

Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 213

                public void testEqualsAndHashCode() {
    new EqualsTester()
        .addEqualityGroup(Optional.absent(), reserialize(Optional.absent()))
        .addEqualityGroup(Optional.of(new Long(5)), reserialize(Optional.of(new Long(5))))
        .addEqualityGroup(Optional.of(new Long(42)), reserialize(Optional.of(new Long(42))))
        .testEquals();
  }

  public void testToString_absent() {

            

Reported by PMD.

Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 214

                  new EqualsTester()
        .addEqualityGroup(Optional.absent(), reserialize(Optional.absent()))
        .addEqualityGroup(Optional.of(new Long(5)), reserialize(Optional.of(new Long(5))))
        .addEqualityGroup(Optional.of(new Long(42)), reserialize(Optional.of(new Long(42))))
        .testEquals();
  }

  public void testToString_absent() {
    assertEquals("Optional.absent()", Optional.absent().toString());

            

Reported by PMD.

Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 214

                  new EqualsTester()
        .addEqualityGroup(Optional.absent(), reserialize(Optional.absent()))
        .addEqualityGroup(Optional.of(new Long(5)), reserialize(Optional.of(new Long(5))))
        .addEqualityGroup(Optional.of(new Long(42)), reserialize(Optional.of(new Long(42))))
        .testEquals();
  }

  public void testToString_absent() {
    assertEquals("Optional.absent()", Optional.absent().toString());

            

Reported by PMD.

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

Line: 39

               * @author Kurt Alfred Kluever
 */
@GwtCompatible(emulated = true)
public final class OptionalTest extends TestCase {
  public void testAbsent() {
    Optional<String> optionalName = Optional.absent();
    assertFalse(optionalName.isPresent());
  }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 40

               */
@GwtCompatible(emulated = true)
public final class OptionalTest extends TestCase {
  public void testAbsent() {
    Optional<String> optionalName = Optional.absent();
    assertFalse(optionalName.isPresent());
  }

  public void testOf() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

              public final class OptionalTest extends TestCase {
  public void testAbsent() {
    Optional<String> optionalName = Optional.absent();
    assertFalse(optionalName.isPresent());
  }

  public void testOf() {
    assertEquals("training", Optional.of("training").get());
  }

            

Reported by PMD.

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

Line: 42

              public final class OptionalTest extends TestCase {
  public void testAbsent() {
    Optional<String> optionalName = Optional.absent();
    assertFalse(optionalName.isPresent());
  }

  public void testOf() {
    assertEquals("training", Optional.of("training").get());
  }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 45

                  assertFalse(optionalName.isPresent());
  }

  public void testOf() {
    assertEquals("training", Optional.of("training").get());
  }

  public void testOf_null() {
    try {

            

Reported by PMD.

The String literal 'training' appears 7 times in this file; the first occurrence is on line 46
Error

Line: 46

                }

  public void testOf() {
    assertEquals("training", Optional.of("training").get());
  }

  public void testOf_null() {
    try {
      Optional.of(null);

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
148 issues
Avoid throwing raw exception types.
Design

Line: 152

                    try {
        exitRun.await();
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }

    @Override
    protected void shutDown() {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 295

                    try {
        enterRun.await();
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }

    @Override
    protected void shutDown() {

            

Reported by PMD.

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

Line: 39

               *
 * @author Jesse Wilson
 */
public class AbstractExecutionThreadServiceTest extends TestCase {

  private final TearDownStack tearDownStack = new TearDownStack(true);
  private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);


            

Reported by PMD.

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

Line: 41

               */
public class AbstractExecutionThreadServiceTest extends TestCase {

  private final TearDownStack tearDownStack = new TearDownStack(true);
  private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;

            

Reported by PMD.

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

Line: 42

              public class AbstractExecutionThreadServiceTest extends TestCase {

  private final TearDownStack tearDownStack = new TearDownStack(true);
  private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =

            

Reported by PMD.

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

Line: 43

              
  private final TearDownStack tearDownStack = new TearDownStack(true);
  private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =
      new Executor() {

            

Reported by PMD.

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

Line: 45

                private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =
      new Executor() {
        @Override
        public void execute(Runnable command) {

            

Reported by PMD.

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

Line: 46

                private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =
      new Executor() {
        @Override
        public void execute(Runnable command) {
          executionThread = new Thread(command);

            

Reported by PMD.

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

Line: 47

              
  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =
      new Executor() {
        @Override
        public void execute(Runnable command) {
          executionThread = new Thread(command);
          executionThread.setUncaughtExceptionHandler(

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 63

                      }
      };

  @Override
  protected final void tearDown() {
    tearDownStack.runTearDown();
    assertNull(
        "exceptions should not be propagated to uncaught exception handlers",
        thrownByExecutionThread);

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
148 issues
Avoid throwing raw exception types.
Design

Line: 152

                    try {
        exitRun.await();
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }

    @Override
    protected void shutDown() {

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 295

                    try {
        enterRun.await();
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }

    @Override
    protected void shutDown() {

            

Reported by PMD.

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

Line: 39

               *
 * @author Jesse Wilson
 */
public class AbstractExecutionThreadServiceTest extends TestCase {

  private final TearDownStack tearDownStack = new TearDownStack(true);
  private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);


            

Reported by PMD.

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

Line: 41

               */
public class AbstractExecutionThreadServiceTest extends TestCase {

  private final TearDownStack tearDownStack = new TearDownStack(true);
  private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;

            

Reported by PMD.

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

Line: 42

              public class AbstractExecutionThreadServiceTest extends TestCase {

  private final TearDownStack tearDownStack = new TearDownStack(true);
  private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =

            

Reported by PMD.

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

Line: 43

              
  private final TearDownStack tearDownStack = new TearDownStack(true);
  private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =
      new Executor() {

            

Reported by PMD.

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

Line: 45

                private final CountDownLatch enterRun = new CountDownLatch(1);
  private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =
      new Executor() {
        @Override
        public void execute(Runnable command) {

            

Reported by PMD.

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

Line: 46

                private final CountDownLatch exitRun = new CountDownLatch(1);

  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =
      new Executor() {
        @Override
        public void execute(Runnable command) {
          executionThread = new Thread(command);

            

Reported by PMD.

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

Line: 47

              
  private Thread executionThread;
  private Throwable thrownByExecutionThread;
  private final Executor exceptionCatchingExecutor =
      new Executor() {
        @Override
        public void execute(Runnable command) {
          executionThread = new Thread(command);
          executionThread.setUncaughtExceptionHandler(

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 63

                      }
      };

  @Override
  protected final void tearDown() {
    tearDownStack.runTearDown();
    assertNull(
        "exceptions should not be propagated to uncaught exception handlers",
        thrownByExecutionThread);

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
147 issues
This class has too many methods, consider refactoring it.
Design

Line: 32

               *
 * @author Sven Mawson
 */
public class SettableFutureTest extends TestCase {

  private SettableFuture<String> future;
  private ListenableFutureTester tester;

  @Override

            

Reported by PMD.

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

Line: 34

               */
public class SettableFutureTest extends TestCase {

  private SettableFuture<String> future;
  private ListenableFutureTester tester;

  @Override
  protected void setUp() throws Exception {
    super.setUp();

            

Reported by PMD.

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

Line: 35

              public class SettableFutureTest extends TestCase {

  private SettableFuture<String> future;
  private ListenableFutureTester tester;

  @Override
  protected void setUp() throws Exception {
    super.setUp();


            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 37

                private SettableFuture<String> future;
  private ListenableFutureTester tester;

  @Override
  protected void setUp() throws Exception {
    super.setUp();

    future = SettableFuture.create();
    tester = new ListenableFutureTester(future);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 46

                  tester.setUp();
  }

  public void testDefaultState() throws Exception {
    try {
      future.get(5, TimeUnit.MILLISECONDS);
      fail();
    } catch (TimeoutException expected) {
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                public void testDefaultState() throws Exception {
    try {
      future.get(5, TimeUnit.MILLISECONDS);
      fail();
    } catch (TimeoutException expected) {
    }
  }



            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 49

                public void testDefaultState() throws Exception {
    try {
      future.get(5, TimeUnit.MILLISECONDS);
      fail();
    } catch (TimeoutException expected) {
    }
  }



            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 55

                }


  public void testSetValue() throws Exception {
    assertTrue(future.set("value"));
    tester.testCompletedFuture("value");
  }



            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 56

              

  public void testSetValue() throws Exception {
    assertTrue(future.set("value"));
    tester.testCompletedFuture("value");
  }


  public void testSetFailure() throws Exception {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 61

                }


  public void testSetFailure() throws Exception {
    assertTrue(future.setException(new Exception("failure")));
    tester.testFailedFuture("failure");
  }



            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
147 issues
This class has too many methods, consider refactoring it.
Design

Line: 32

               *
 * @author Sven Mawson
 */
public class SettableFutureTest extends TestCase {

  private SettableFuture<String> future;
  private ListenableFutureTester tester;

  @Override

            

Reported by PMD.

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

Line: 34

               */
public class SettableFutureTest extends TestCase {

  private SettableFuture<String> future;
  private ListenableFutureTester tester;

  @Override
  protected void setUp() throws Exception {
    super.setUp();

            

Reported by PMD.

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

Line: 35

              public class SettableFutureTest extends TestCase {

  private SettableFuture<String> future;
  private ListenableFutureTester tester;

  @Override
  protected void setUp() throws Exception {
    super.setUp();


            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 37

                private SettableFuture<String> future;
  private ListenableFutureTester tester;

  @Override
  protected void setUp() throws Exception {
    super.setUp();

    future = SettableFuture.create();
    tester = new ListenableFutureTester(future);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 46

                  tester.setUp();
  }

  public void testDefaultState() throws Exception {
    try {
      future.get(5, TimeUnit.MILLISECONDS);
      fail();
    } catch (TimeoutException expected) {
    }

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 49

                public void testDefaultState() throws Exception {
    try {
      future.get(5, TimeUnit.MILLISECONDS);
      fail();
    } catch (TimeoutException expected) {
    }
  }



            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                public void testDefaultState() throws Exception {
    try {
      future.get(5, TimeUnit.MILLISECONDS);
      fail();
    } catch (TimeoutException expected) {
    }
  }



            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 55

                }


  public void testSetValue() throws Exception {
    assertTrue(future.set("value"));
    tester.testCompletedFuture("value");
  }



            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 56

              

  public void testSetValue() throws Exception {
    assertTrue(future.set("value"));
    tester.testCompletedFuture("value");
  }


  public void testSetFailure() throws Exception {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 61

                }


  public void testSetFailure() throws Exception {
    assertTrue(future.setException(new Exception("failure")));
    tester.testFailedFuture("failure");
  }



            

Reported by PMD.

guava-tests/test/com/google/common/base/JoinerTest.java
147 issues
Overridable method 'iterator' called during object construction
Error

Line: 338

                  private final Iterator<Integer> iterator;

    public IterableIterator() {
      this.iterator = iterator();
    }

    @Override
    public Iterator<Integer> iterator() {
      return INTEGERS.iterator();

            

Reported by PMD.

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

Line: 43

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class JoinerTest extends TestCase {
  private static final Joiner J = Joiner.on("-");

  // <Integer> needed to prevent warning :(
  private static final Iterable<Integer> ITERABLE_ = Arrays.<Integer>asList();
  private static final Iterable<Integer> ITERABLE_1 = Arrays.asList(1);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 59

                private static final Iterable<Integer> ITERABLE_FOUR_NULLS =
      Arrays.asList((Integer) null, null, null, null);

  public void testNoSpecialNullBehavior() {
    checkNoOutput(J, ITERABLE_);
    checkResult(J, ITERABLE_1, "1");
    checkResult(J, ITERABLE_12, "1-2");
    checkResult(J, ITERABLE_123, "1-2-3");


            

Reported by PMD.

The String literal '1-2' appears 5 times in this file; the first occurrence is on line 62
Error

Line: 62

                public void testNoSpecialNullBehavior() {
    checkNoOutput(J, ITERABLE_);
    checkResult(J, ITERABLE_1, "1");
    checkResult(J, ITERABLE_12, "1-2");
    checkResult(J, ITERABLE_123, "1-2-3");

    try {
      J.join(ITERABLE_NULL);
      fail();

            

Reported by PMD.

The String literal '1-2-3' appears 4 times in this file; the first occurrence is on line 63
Error

Line: 63

                  checkNoOutput(J, ITERABLE_);
    checkResult(J, ITERABLE_1, "1");
    checkResult(J, ITERABLE_12, "1-2");
    checkResult(J, ITERABLE_123, "1-2-3");

    try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 67

              
    try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 67

              
    try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();

            

Reported by PMD.

Avoid catching NullPointerException; consider removing the cause of the NPE.
Error

Line: 68

                  try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

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

Line: 68

                  try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 72

                  }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();
    } catch (NullPointerException expected) {
    }

    try {
      J.join(ITERABLE_NULL.iterator());

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/JoinerTest.java
147 issues
Overridable method 'iterator' called during object construction
Error

Line: 338

                  private final Iterator<Integer> iterator;

    public IterableIterator() {
      this.iterator = iterator();
    }

    @Override
    public Iterator<Integer> iterator() {
      return INTEGERS.iterator();

            

Reported by PMD.

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

Line: 43

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class JoinerTest extends TestCase {
  private static final Joiner J = Joiner.on("-");

  // <Integer> needed to prevent warning :(
  private static final Iterable<Integer> ITERABLE_ = Arrays.<Integer>asList();
  private static final Iterable<Integer> ITERABLE_1 = Arrays.asList(1);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 59

                private static final Iterable<Integer> ITERABLE_FOUR_NULLS =
      Arrays.asList((Integer) null, null, null, null);

  public void testNoSpecialNullBehavior() {
    checkNoOutput(J, ITERABLE_);
    checkResult(J, ITERABLE_1, "1");
    checkResult(J, ITERABLE_12, "1-2");
    checkResult(J, ITERABLE_123, "1-2-3");


            

Reported by PMD.

The String literal '1-2' appears 5 times in this file; the first occurrence is on line 62
Error

Line: 62

                public void testNoSpecialNullBehavior() {
    checkNoOutput(J, ITERABLE_);
    checkResult(J, ITERABLE_1, "1");
    checkResult(J, ITERABLE_12, "1-2");
    checkResult(J, ITERABLE_123, "1-2-3");

    try {
      J.join(ITERABLE_NULL);
      fail();

            

Reported by PMD.

The String literal '1-2-3' appears 4 times in this file; the first occurrence is on line 63
Error

Line: 63

                  checkNoOutput(J, ITERABLE_);
    checkResult(J, ITERABLE_1, "1");
    checkResult(J, ITERABLE_12, "1-2");
    checkResult(J, ITERABLE_123, "1-2-3");

    try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 67

              
    try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 67

              
    try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();

            

Reported by PMD.

Avoid catching NullPointerException; consider removing the cause of the NPE.
Error

Line: 68

                  try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

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

Line: 68

                  try {
      J.join(ITERABLE_NULL);
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 72

                  }
    try {
      J.join(ITERABLE_1_NULL_2);
      fail();
    } catch (NullPointerException expected) {
    }

    try {
      J.join(ITERABLE_NULL.iterator());

            

Reported by PMD.

guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
145 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 90

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMultimap<K, V> implements Serializable {
  /*
   * Here's an outline of the overall design.
   *
   * The map variable contains the collection of values associated with each

            

Reported by PMD.

Possible God Class (WMC=52, ATFD=12, TCC=26.411%)
Design

Line: 90

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMultimap<K, V> implements Serializable {
  /*
   * Here's an outline of the overall design.
   *
   * The map variable contains the collection of values associated with each

            

Reported by PMD.

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

Line: 91

              @GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMultimap<K, V> implements Serializable {
  /*
   * Here's an outline of the overall design.
   *
   * The map variable contains the collection of values associated with each
   * key. When a key-value pair is added to a multimap that didn't previously

            

Reported by PMD.

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

Line: 198

                    } else {
        throw new AssertionError("New Collection violated the Collection spec");
      }
    } else if (collection.add(value)) {
      totalSize++;
      return true;
    } else {
      return false;
    }

            

Reported by PMD.

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

Line: 232

                  // TODO(lowasser): investigate atomic failure?
    Collection<V> collection = getOrCreateCollection(key);
    Collection<V> oldValues = createCollection();
    oldValues.addAll(collection);

    totalSize -= collection.size();
    collection.clear();

    while (iterator.hasNext()) {

            

Reported by PMD.

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

Line: 234

                  Collection<V> oldValues = createCollection();
    oldValues.addAll(collection);

    totalSize -= collection.size();
    collection.clear();

    while (iterator.hasNext()) {
      if (collection.add(iterator.next())) {
        totalSize++;

            

Reported by PMD.

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

Line: 235

                  oldValues.addAll(collection);

    totalSize -= collection.size();
    collection.clear();

    while (iterator.hasNext()) {
      if (collection.add(iterator.next())) {
        totalSize++;
      }

            

Reported by PMD.

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

Line: 260

                  }

    Collection<V> output = createCollection();
    output.addAll(collection);
    totalSize -= collection.size();
    collection.clear();

    return unmodifiableCollectionSubclass(output);
  }

            

Reported by PMD.

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

Line: 261

              
    Collection<V> output = createCollection();
    output.addAll(collection);
    totalSize -= collection.size();
    collection.clear();

    return unmodifiableCollectionSubclass(output);
  }


            

Reported by PMD.

guava-tests/test/com/google/common/reflect/TypesTest.java
144 issues
This class has too many methods, consider refactoring it.
Design

Line: 46

               * @author Ben Yu
 */
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypesTest extends TestCase {
  public void testNewParameterizedType_ownerTypeImplied() throws Exception {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<Entry<String, Integer>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 47

               */
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypesTest extends TestCase {
  public void testNewParameterizedType_ownerTypeImplied() throws Exception {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<Entry<String, Integer>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);

            

Reported by PMD.

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

Line: 47

               */
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypesTest extends TestCase {
  public void testNewParameterizedType_ownerTypeImplied() throws Exception {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<Entry<String, Integer>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 52

                      (ParameterizedType) new TypeCapture<Entry<String, Integer>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);
    assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =

            

Reported by PMD.

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

Line: 53

                  ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);
    assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                  ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);
    assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();

            

Reported by PMD.

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

Line: 56

                  assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(HashMap.class, String.class, int[][].class);


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 56

                  assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(HashMap.class, String.class, int[][].class);


            

Reported by PMD.

Avoid using implementation types like 'HashMap'; use the interface instead
Design

Line: 60

                  ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(HashMap.class, String.class, int[][].class);

    new EqualsTester().addEqualityGroup(jvmType, ourType).testEquals();
    assertEquals(jvmType.toString(), ourType.toString());
    assertEquals(jvmType.hashCode(), ourType.hashCode());
    assertEquals(HashMap.class, ourType.getRawType());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                      Types.newParameterizedType(HashMap.class, String.class, int[][].class);

    new EqualsTester().addEqualityGroup(jvmType, ourType).testEquals();
    assertEquals(jvmType.toString(), ourType.toString());
    assertEquals(jvmType.hashCode(), ourType.hashCode());
    assertEquals(HashMap.class, ourType.getRawType());
    assertThat(ourType.getActualTypeArguments())
        .asList()
        .containsExactlyElementsIn(asList(jvmType.getActualTypeArguments()))

            

Reported by PMD.