The following issues were found

guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java
82 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 39

               * @author Dimitris Andreou
 */
public class AbstractStreamingHasherTest extends TestCase {
  public void testBytes() {
    Sink sink = new Sink(4); // byte order insignificant here
    byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
    sink.putByte((byte) 1);
    sink.putBytes(new byte[] {2, 3, 4, 5, 6});
    sink.putByte((byte) 7);

            

Reported by PMD.

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

Line: 39

               * @author Dimitris Andreou
 */
public class AbstractStreamingHasherTest extends TestCase {
  public void testBytes() {
    Sink sink = new Sink(4); // byte order insignificant here
    byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
    sink.putByte((byte) 1);
    sink.putBytes(new byte[] {2, 3, 4, 5, 6});
    sink.putByte((byte) 7);

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 47

                  sink.putByte((byte) 7);
    sink.putBytes(new byte[] {});
    sink.putBytes(new byte[] {8});
    HashCode unused = sink.hash();
    sink.assertInvariants(8);
    sink.assertBytes(expected);
  }

  public void testShort() {

            

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: 52

                  sink.assertBytes(expected);
  }

  public void testShort() {
    Sink sink = new Sink(4);
    sink.putShort((short) 0x0201);
    HashCode unused = sink.hash();
    sink.assertInvariants(2);
    sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros

            

Reported by PMD.

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

Line: 52

                  sink.assertBytes(expected);
  }

  public void testShort() {
    Sink sink = new Sink(4);
    sink.putShort((short) 0x0201);
    HashCode unused = sink.hash();
    sink.assertInvariants(2);
    sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 55

                public void testShort() {
    Sink sink = new Sink(4);
    sink.putShort((short) 0x0201);
    HashCode unused = sink.hash();
    sink.assertInvariants(2);
    sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros
  }

  public void testInt() {

            

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: 60

                  sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros
  }

  public void testInt() {
    Sink sink = new Sink(4);
    sink.putInt(0x04030201);
    HashCode unused = sink.hash();
    sink.assertInvariants(4);
    sink.assertBytes(new byte[] {1, 2, 3, 4});

            

Reported by PMD.

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

Line: 60

                  sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros
  }

  public void testInt() {
    Sink sink = new Sink(4);
    sink.putInt(0x04030201);
    HashCode unused = sink.hash();
    sink.assertInvariants(4);
    sink.assertBytes(new byte[] {1, 2, 3, 4});

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 63

                public void testInt() {
    Sink sink = new Sink(4);
    sink.putInt(0x04030201);
    HashCode unused = sink.hash();
    sink.assertInvariants(4);
    sink.assertBytes(new byte[] {1, 2, 3, 4});
  }

  public void testLong() {

            

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: 68

                  sink.assertBytes(new byte[] {1, 2, 3, 4});
  }

  public void testLong() {
    Sink sink = new Sink(8);
    sink.putLong(0x0807060504030201L);
    HashCode unused = sink.hash();
    sink.assertInvariants(8);
    sink.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8});

            

Reported by PMD.

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

Line: 216

                  try {
      barrier.await();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

            

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: 41

              @GwtCompatible(emulated = true)
public class TrustedListenableFutureTaskTest extends TestCase {

  public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());

            

Reported by PMD.

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

Line: 41

              @GwtCompatible(emulated = true)
public class TrustedListenableFutureTaskTest extends TestCase {

  public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

              
  public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

            

Reported by PMD.

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

Line: 43

              
  public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

            

Reported by PMD.

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

Line: 44

                public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }


            

Reported by PMD.

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

Line: 45

                  TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

  public void testCancelled() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

  public void testCancelled() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                  assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

  public void testCancelled() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));

            

Reported by PMD.

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

Line: 46

                  assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

  public void testCancelled() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java
82 issues
Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 38

               * @author Mike Bostock
 */
public class SynchronizedMapTest extends TestCase {
  public final Object mutex = new Integer(1); // something Serializable

  protected <K, V> Map<K, V> create() {
    TestMap<K, V> inner = new TestMap<>(new HashMap<K, V>(), mutex);
    Map<K, V> outer = Synchronized.map(inner, mutex);
    return outer;

            

Reported by PMD.

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

Line: 37

               *
 * @author Mike Bostock
 */
public class SynchronizedMapTest extends TestCase {
  public final Object mutex = new Integer(1); // something Serializable

  protected <K, V> Map<K, V> create() {
    TestMap<K, V> inner = new TestMap<>(new HashMap<K, V>(), mutex);
    Map<K, V> outer = Synchronized.map(inner, mutex);

            

Reported by PMD.

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

Line: 38

               * @author Mike Bostock
 */
public class SynchronizedMapTest extends TestCase {
  public final Object mutex = new Integer(1); // something Serializable

  protected <K, V> Map<K, V> create() {
    TestMap<K, V> inner = new TestMap<>(new HashMap<K, V>(), mutex);
    Map<K, V> outer = Synchronized.map(inner, mutex);
    return outer;

            

Reported by PMD.

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

Line: 46

                  return outer;
  }

  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);

            

Reported by PMD.

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

Line: 47

                }

  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);
      this.delegate = delegate;

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 48

              
  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);
      this.delegate = delegate;
      this.mutex = mutex;

            

Reported by PMD.

Private field 'delegate' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 48

              
  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);
      this.delegate = delegate;
      this.mutex = mutex;

            

Reported by PMD.

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

Line: 48

              
  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);
      this.delegate = delegate;
      this.mutex = mutex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

              
    @Override
    public int size() {
      assertTrue(Thread.holdsLock(mutex));
      return super.size();
    }

    @Override
    public boolean isEmpty() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 69

              
    @Override
    public boolean isEmpty() {
      assertTrue(Thread.holdsLock(mutex));
      return super.isEmpty();
    }

    @Override
    public V remove(Object object) {

            

Reported by PMD.

guava-tests/test/com/google/common/io/ByteSourceTest.java
82 issues
Possible God Class (WMC=48, ATFD=19, TCC=25.747%)
Design

Line: 49

               *
 * @author Colin Decker
 */
public class ByteSourceTest extends IoTestCase {

  @AndroidIncompatible // Android doesn't understand suites whose tests lack default constructors.
  public static TestSuite suite() {
    TestSuite suite = new TestSuite();
    for (boolean asCharSource : new boolean[] {false, true}) {

            

Reported by PMD.

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

Line: 49

               *
 * @author Colin Decker
 */
public class ByteSourceTest extends IoTestCase {

  @AndroidIncompatible // Android doesn't understand suites whose tests lack default constructors.
  public static TestSuite suite() {
    TestSuite suite = new TestSuite();
    for (boolean asCharSource : new boolean[] {false, true}) {

            

Reported by PMD.

The class 'ByteSourceTest' has a Standard Cyclomatic Complexity of 2 (Highest = 12).
Design

Line: 49

               *
 * @author Colin Decker
 */
public class ByteSourceTest extends IoTestCase {

  @AndroidIncompatible // Android doesn't understand suites whose tests lack default constructors.
  public static TestSuite suite() {
    TestSuite suite = new TestSuite();
    for (boolean asCharSource : new boolean[] {false, true}) {

            

Reported by PMD.

The class 'ByteSourceTest' has a Modified Cyclomatic Complexity of 2 (Highest = 12).
Design

Line: 49

               *
 * @author Colin Decker
 */
public class ByteSourceTest extends IoTestCase {

  @AndroidIncompatible // Android doesn't understand suites whose tests lack default constructors.
  public static TestSuite suite() {
    TestSuite suite = new TestSuite();
    for (boolean asCharSource : new boolean[] {false, true}) {

            

Reported by PMD.

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

Line: 70

              
  private static final byte[] bytes = newPreFilledByteArray(10000);

  private TestByteSource source;

  @Override
  protected void setUp() throws Exception {
    source = new TestByteSource(bytes);
  }

            

Reported by PMD.

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

Line: 72

              
  private TestByteSource source;

  @Override
  protected void setUp() throws Exception {
    source = new TestByteSource(bytes);
  }

  public void testOpenBufferedStream() throws IOException {

            

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: 77

                  source = new TestByteSource(bytes);
  }

  public void testOpenBufferedStream() throws IOException {
    InputStream in = source.openBufferedStream();
    assertTrue(source.wasStreamOpened());
    assertFalse(source.wasStreamClosed());

    ByteArrayOutputStream out = new ByteArrayOutputStream();

            

Reported by PMD.

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

Line: 77

                  source = new TestByteSource(bytes);
  }

  public void testOpenBufferedStream() throws IOException {
    InputStream in = source.openBufferedStream();
    assertTrue(source.wasStreamOpened());
    assertFalse(source.wasStreamClosed());

    ByteArrayOutputStream out = new ByteArrayOutputStream();

            

Reported by PMD.

Ensure that resources like this InputStream object are closed after use
Error

Line: 78

                }

  public void testOpenBufferedStream() throws IOException {
    InputStream in = source.openBufferedStream();
    assertTrue(source.wasStreamOpened());
    assertFalse(source.wasStreamClosed());

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ByteStreams.copy(in, out);

            

Reported by PMD.

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

Line: 84

              
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ByteStreams.copy(in, out);
    in.close();
    out.close();

    assertTrue(source.wasStreamClosed());
    assertArrayEquals(bytes, out.toByteArray());
  }

            

Reported by PMD.

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

Line: 216

                  try {
      barrier.await();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

            

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: 41

              @GwtCompatible(emulated = true)
public class TrustedListenableFutureTaskTest extends TestCase {

  public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());

            

Reported by PMD.

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

Line: 41

              @GwtCompatible(emulated = true)
public class TrustedListenableFutureTaskTest extends TestCase {

  public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

              
  public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

            

Reported by PMD.

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

Line: 43

              
  public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

            

Reported by PMD.

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

Line: 44

                public void testSuccessful() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

  public void testCancelled() throws Exception {

            

Reported by PMD.

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

Line: 45

                  TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));
    assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

  public void testCancelled() throws Exception {

            

Reported by PMD.

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

Line: 46

                  assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

  public void testCancelled() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                  assertFalse(task.isDone());
    task.run();
    assertTrue(task.isDone());
    assertFalse(task.isCancelled());
    assertEquals(2, getDone(task).intValue());
  }

  public void testCancelled() throws Exception {
    TrustedListenableFutureTask<Integer> task = TrustedListenableFutureTask.create(returning(2));

            

Reported by PMD.

android/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java
82 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 39

               * @author Dimitris Andreou
 */
public class AbstractStreamingHasherTest extends TestCase {
  public void testBytes() {
    Sink sink = new Sink(4); // byte order insignificant here
    byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
    sink.putByte((byte) 1);
    sink.putBytes(new byte[] {2, 3, 4, 5, 6});
    sink.putByte((byte) 7);

            

Reported by PMD.

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

Line: 39

               * @author Dimitris Andreou
 */
public class AbstractStreamingHasherTest extends TestCase {
  public void testBytes() {
    Sink sink = new Sink(4); // byte order insignificant here
    byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
    sink.putByte((byte) 1);
    sink.putBytes(new byte[] {2, 3, 4, 5, 6});
    sink.putByte((byte) 7);

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 47

                  sink.putByte((byte) 7);
    sink.putBytes(new byte[] {});
    sink.putBytes(new byte[] {8});
    HashCode unused = sink.hash();
    sink.assertInvariants(8);
    sink.assertBytes(expected);
  }

  public void testShort() {

            

Reported by PMD.

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

Line: 52

                  sink.assertBytes(expected);
  }

  public void testShort() {
    Sink sink = new Sink(4);
    sink.putShort((short) 0x0201);
    HashCode unused = sink.hash();
    sink.assertInvariants(2);
    sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros

            

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: 52

                  sink.assertBytes(expected);
  }

  public void testShort() {
    Sink sink = new Sink(4);
    sink.putShort((short) 0x0201);
    HashCode unused = sink.hash();
    sink.assertInvariants(2);
    sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 55

                public void testShort() {
    Sink sink = new Sink(4);
    sink.putShort((short) 0x0201);
    HashCode unused = sink.hash();
    sink.assertInvariants(2);
    sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros
  }

  public void testInt() {

            

Reported by PMD.

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

Line: 60

                  sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros
  }

  public void testInt() {
    Sink sink = new Sink(4);
    sink.putInt(0x04030201);
    HashCode unused = sink.hash();
    sink.assertInvariants(4);
    sink.assertBytes(new byte[] {1, 2, 3, 4});

            

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: 60

                  sink.assertBytes(new byte[] {1, 2, 0, 0}); // padded with zeros
  }

  public void testInt() {
    Sink sink = new Sink(4);
    sink.putInt(0x04030201);
    HashCode unused = sink.hash();
    sink.assertInvariants(4);
    sink.assertBytes(new byte[] {1, 2, 3, 4});

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 63

                public void testInt() {
    Sink sink = new Sink(4);
    sink.putInt(0x04030201);
    HashCode unused = sink.hash();
    sink.assertInvariants(4);
    sink.assertBytes(new byte[] {1, 2, 3, 4});
  }

  public void testLong() {

            

Reported by PMD.

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

Line: 68

                  sink.assertBytes(new byte[] {1, 2, 3, 4});
  }

  public void testLong() {
    Sink sink = new Sink(8);
    sink.putLong(0x0807060504030201L);
    HashCode unused = sink.hash();
    sink.assertInvariants(8);
    sink.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8});

            

Reported by PMD.

guava-tests/test/com/google/common/collect/SynchronizedMapTest.java
82 issues
Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 38

               * @author Mike Bostock
 */
public class SynchronizedMapTest extends TestCase {
  public final Object mutex = new Integer(1); // something Serializable

  protected <K, V> Map<K, V> create() {
    TestMap<K, V> inner = new TestMap<>(new HashMap<K, V>(), mutex);
    Map<K, V> outer = Synchronized.map(inner, mutex);
    return outer;

            

Reported by PMD.

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

Line: 37

               *
 * @author Mike Bostock
 */
public class SynchronizedMapTest extends TestCase {
  public final Object mutex = new Integer(1); // something Serializable

  protected <K, V> Map<K, V> create() {
    TestMap<K, V> inner = new TestMap<>(new HashMap<K, V>(), mutex);
    Map<K, V> outer = Synchronized.map(inner, mutex);

            

Reported by PMD.

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

Line: 38

               * @author Mike Bostock
 */
public class SynchronizedMapTest extends TestCase {
  public final Object mutex = new Integer(1); // something Serializable

  protected <K, V> Map<K, V> create() {
    TestMap<K, V> inner = new TestMap<>(new HashMap<K, V>(), mutex);
    Map<K, V> outer = Synchronized.map(inner, mutex);
    return outer;

            

Reported by PMD.

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

Line: 46

                  return outer;
  }

  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);

            

Reported by PMD.

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

Line: 47

                }

  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);
      this.delegate = delegate;

            

Reported by PMD.

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

Line: 48

              
  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);
      this.delegate = delegate;
      this.mutex = mutex;

            

Reported by PMD.

Private field 'delegate' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 48

              
  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);
      this.delegate = delegate;
      this.mutex = mutex;

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 48

              
  static class TestMap<K, V> extends ForwardingMap<K, V> implements Serializable {
    public final Object mutex;
    private Map<K, V> delegate;

    public TestMap(Map<K, V> delegate, Object mutex) {
      checkNotNull(mutex);
      this.delegate = delegate;
      this.mutex = mutex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

              
    @Override
    public int size() {
      assertTrue(Thread.holdsLock(mutex));
      return super.size();
    }

    @Override
    public boolean isEmpty() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 69

              
    @Override
    public boolean isEmpty() {
      assertTrue(Thread.holdsLock(mutex));
      return super.isEmpty();
    }

    @Override
    public V remove(Object object) {

            

Reported by PMD.

guava-tests/test/com/google/common/cache/AbstractCacheTest.java
81 issues
The class 'AbstractCacheTest' has a Modified Cyclomatic Complexity of 4 (Highest = 11).
Design

Line: 33

               *
 * @author Charles Fry
 */
public class AbstractCacheTest extends TestCase {

  public void testGetIfPresent() {
    final AtomicReference<Object> valueRef = new AtomicReference<>();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {

            

Reported by PMD.

The class 'AbstractCacheTest' has a Standard Cyclomatic Complexity of 4 (Highest = 11).
Design

Line: 33

               *
 * @author Charles Fry
 */
public class AbstractCacheTest extends TestCase {

  public void testGetIfPresent() {
    final AtomicReference<Object> valueRef = new AtomicReference<>();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {

            

Reported by PMD.

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

Line: 35

               */
public class AbstractCacheTest extends TestCase {

  public void testGetIfPresent() {
    final AtomicReference<Object> valueRef = new AtomicReference<>();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {
          @Override
          public Object getIfPresent(Object key) {

            

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: 35

               */
public class AbstractCacheTest extends TestCase {

  public void testGetIfPresent() {
    final AtomicReference<Object> valueRef = new AtomicReference<>();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {
          @Override
          public Object getIfPresent(Object key) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                        }
        };

    assertNull(cache.getIfPresent(new Object()));

    Object newValue = new Object();
    valueRef.set(newValue);
    assertSame(newValue, cache.getIfPresent(new Object()));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

              
    Object newValue = new Object();
    valueRef.set(newValue);
    assertSame(newValue, cache.getIfPresent(new Object()));
  }

  public void testGetAllPresent_empty() {
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {

            

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: 52

                  assertSame(newValue, cache.getIfPresent(new Object()));
  }

  public void testGetAllPresent_empty() {
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {
          @Override
          public Object getIfPresent(Object key) {
            return null;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 61

                        }
        };

    assertEquals(ImmutableMap.of(), cache.getAllPresent(ImmutableList.of(new Object())));
  }

  public void testGetAllPresent_cached() {
    final Object cachedKey = new Object();
    final Object cachedValue = new Object();

            

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: 64

                  assertEquals(ImmutableMap.of(), cache.getAllPresent(ImmutableList.of(new Object())));
  }

  public void testGetAllPresent_cached() {
    final Object cachedKey = new Object();
    final Object cachedValue = new Object();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {
          @Override

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 75

                        }
        };

    assertEquals(
        ImmutableMap.of(cachedKey, cachedValue),
        cache.getAllPresent(ImmutableList.of(cachedKey, new Object())));
  }

  public void testInvalidateAll() {

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/AbstractCacheTest.java
81 issues
The class 'AbstractCacheTest' has a Modified Cyclomatic Complexity of 4 (Highest = 11).
Design

Line: 33

               *
 * @author Charles Fry
 */
public class AbstractCacheTest extends TestCase {

  public void testGetIfPresent() {
    final AtomicReference<Object> valueRef = new AtomicReference<>();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {

            

Reported by PMD.

The class 'AbstractCacheTest' has a Standard Cyclomatic Complexity of 4 (Highest = 11).
Design

Line: 33

               *
 * @author Charles Fry
 */
public class AbstractCacheTest extends TestCase {

  public void testGetIfPresent() {
    final AtomicReference<Object> valueRef = new AtomicReference<>();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {

            

Reported by PMD.

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

Line: 35

               */
public class AbstractCacheTest extends TestCase {

  public void testGetIfPresent() {
    final AtomicReference<Object> valueRef = new AtomicReference<>();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {
          @Override
          public Object getIfPresent(Object key) {

            

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: 35

               */
public class AbstractCacheTest extends TestCase {

  public void testGetIfPresent() {
    final AtomicReference<Object> valueRef = new AtomicReference<>();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {
          @Override
          public Object getIfPresent(Object key) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                        }
        };

    assertNull(cache.getIfPresent(new Object()));

    Object newValue = new Object();
    valueRef.set(newValue);
    assertSame(newValue, cache.getIfPresent(new Object()));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

              
    Object newValue = new Object();
    valueRef.set(newValue);
    assertSame(newValue, cache.getIfPresent(new Object()));
  }

  public void testGetAllPresent_empty() {
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {

            

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: 52

                  assertSame(newValue, cache.getIfPresent(new Object()));
  }

  public void testGetAllPresent_empty() {
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {
          @Override
          public Object getIfPresent(Object key) {
            return null;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 61

                        }
        };

    assertEquals(ImmutableMap.of(), cache.getAllPresent(ImmutableList.of(new Object())));
  }

  public void testGetAllPresent_cached() {
    final Object cachedKey = new Object();
    final Object cachedValue = new Object();

            

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: 64

                  assertEquals(ImmutableMap.of(), cache.getAllPresent(ImmutableList.of(new Object())));
  }

  public void testGetAllPresent_cached() {
    final Object cachedKey = new Object();
    final Object cachedValue = new Object();
    Cache<Object, Object> cache =
        new AbstractCache<Object, Object>() {
          @Override

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 75

                        }
        };

    assertEquals(
        ImmutableMap.of(cachedKey, cachedValue),
        cache.getAllPresent(ImmutableList.of(cachedKey, new Object())));
  }

  public void testInvalidateAll() {

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/AsciiTest.java
80 issues
Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 134

                  assertTrue(Ascii.equalsIgnoreCase(LOWER, UPPER));
    assertTrue(Ascii.equalsIgnoreCase(UPPER, LOWER));
    // Create new strings here to avoid early-out logic.
    assertTrue(Ascii.equalsIgnoreCase(new String(IGNORED), new String(IGNORED)));
    // Compare to: "\u00c1".equalsIgnoreCase("\u00e1") == true
    assertFalse(Ascii.equalsIgnoreCase("\u00c1", "\u00e1"));
    // Test chars just outside the alphabetic range ('A'-1 vs 'a'-1, 'Z'+1 vs 'z'+1)
    assertFalse(Ascii.equalsIgnoreCase("@", "`"));
    assertFalse(Ascii.equalsIgnoreCase("[", "{"));

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 134

                  assertTrue(Ascii.equalsIgnoreCase(LOWER, UPPER));
    assertTrue(Ascii.equalsIgnoreCase(UPPER, LOWER));
    // Create new strings here to avoid early-out logic.
    assertTrue(Ascii.equalsIgnoreCase(new String(IGNORED), new String(IGNORED)));
    // Compare to: "\u00c1".equalsIgnoreCase("\u00e1") == true
    assertFalse(Ascii.equalsIgnoreCase("\u00c1", "\u00e1"));
    // Test chars just outside the alphabetic range ('A'-1 vs 'a'-1, 'Z'+1 vs 'z'+1)
    assertFalse(Ascii.equalsIgnoreCase("@", "`"));
    assertFalse(Ascii.equalsIgnoreCase("[", "{"));

            

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

                private static final String LOWER = "abcdefghijklmnopqrstuvwxyz";
  private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

            

Reported by PMD.

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

Line: 40

                private static final String LOWER = "abcdefghijklmnopqrstuvwxyz";
  private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

                private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

              
  public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

                public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {
    assertEquals(UPPER, Ascii.toUpperCase(LOWER));

            

Reported by PMD.

The String literal 'foobar' appears 19 times in this file; the first occurrence is on line 44
Error

Line: 44

                  assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {
    assertEquals(UPPER, Ascii.toUpperCase(LOWER));
    assertSame(UPPER, Ascii.toUpperCase(UPPER));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

                  assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {
    assertEquals(UPPER, Ascii.toUpperCase(LOWER));
    assertSame(UPPER, Ascii.toUpperCase(UPPER));

            

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

                  assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {
    assertEquals(UPPER, Ascii.toUpperCase(LOWER));
    assertSame(UPPER, Ascii.toUpperCase(UPPER));
    assertEquals(IGNORED, Ascii.toUpperCase(IGNORED));
    assertEquals("FOOBAR", Ascii.toUpperCase("FoOBAr"));
  }

            

Reported by PMD.