The following issues were found

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

Line: 28

              public class SynchronizedTableTest extends AbstractTableTest {
  private static final class TestTable<R, C, V> implements Table<R, C, V>, Serializable {
    final Table<R, C, V> delegate = HashBasedTable.create();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public String toString() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.toString();

            

Reported by PMD.

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

Line: 26

              import org.checkerframework.checker.nullness.qual.Nullable;

public class SynchronizedTableTest extends AbstractTableTest {
  private static final class TestTable<R, C, V> implements Table<R, C, V>, Serializable {
    final Table<R, C, V> delegate = HashBasedTable.create();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public String toString() {

            

Reported by PMD.

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

Line: 27

              
public class SynchronizedTableTest extends AbstractTableTest {
  private static final class TestTable<R, C, V> implements Table<R, C, V>, Serializable {
    final Table<R, C, V> delegate = HashBasedTable.create();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public String toString() {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

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

Line: 28

              public class SynchronizedTableTest extends AbstractTableTest {
  private static final class TestTable<R, C, V> implements Table<R, C, V>, Serializable {
    final Table<R, C, V> delegate = HashBasedTable.create();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public String toString() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.toString();

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/TestStringMultisetGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 47

                  return create(array);
  }

  protected abstract Multiset<String> create(String[] elements);

  @Override
  public String[] createArray(int length) {
    return new String[length];
  }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '39'-'42').
Error

Line: 39

              
  @Override
  public Multiset<String> create(Object... elements) {
    String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '40'-'45').
Error

Line: 40

                @Override
  public Multiset<String> create(Object... elements) {
    String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);
  }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '42'-'42').
Error

Line: 42

                  String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);
  }

  protected abstract Multiset<String> create(String[] elements);

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/MapIsEmptyTester.java
4 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: 35

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapIsEmptyTester<K, V> extends AbstractMapTester<K, V> {
  @CollectionSize.Require(ZERO)
  public void testIsEmpty_yes() {
    assertTrue("isEmpty() should return true", getMap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 37

              public class MapIsEmptyTester<K, V> extends AbstractMapTester<K, V> {
  @CollectionSize.Require(ZERO)
  public void testIsEmpty_yes() {
    assertTrue("isEmpty() should return true", getMap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testIsEmpty_no() {
    assertFalse("isEmpty() should return false", getMap().isEmpty());

            

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

                  assertTrue("isEmpty() should return true", getMap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testIsEmpty_no() {
    assertFalse("isEmpty() should return false", getMap().isEmpty());
  }
}

            

Reported by PMD.

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

Line: 42

              
  @CollectionSize.Require(absent = ZERO)
  public void testIsEmpty_no() {
    assertFalse("isEmpty() should return false", getMap().isEmpty());
  }
}

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/TestStringSetMultimapGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 73

                  return create(array);
  }

  protected abstract SetMultimap<String, String> create(Entry<String, String>[] entries);

  @Override
  @SuppressWarnings("unchecked")
  public final Entry<String, String>[] createArray(int length) {
    return new Entry[length];

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '63'-'68').
Error

Line: 63

                @Override
  public final SetMultimap<String, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '64'-'71').
Error

Line: 64

                public final SetMultimap<String, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '68'-'68').
Error

Line: 68

                  for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;
    }
    return create(array);
  }

  protected abstract SetMultimap<String, String> create(Entry<String, String>[] entries);

            

Reported by PMD.

guava-tests/benchmark/com/google/common/math/BigIntegerMathRoundingBenchmark.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 41

                private static final BigInteger[] positive = new BigInteger[ARRAY_SIZE];

  @Param({"DOWN", "UP", "FLOOR", "CEILING", "HALF_EVEN", "HALF_UP", "HALF_DOWN"})
  RoundingMode mode;

  @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positive[i] = randomPositiveBigInteger(1024);

            

Reported by PMD.

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

Line: 43

                @Param({"DOWN", "UP", "FLOOR", "CEILING", "HALF_EVEN", "HALF_UP", "HALF_DOWN"})
  RoundingMode mode;

  @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positive[i] = randomPositiveBigInteger(1024);
      nonzero1[i] = randomNonZeroBigInteger(1024);
      nonzero2[i] = randomNonZeroBigInteger(1024);

            

Reported by PMD.

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

Line: 77

                  int tmp = 0;
    for (int i = 0; i < reps; i++) {
      int j = i & ARRAY_MASK;
      tmp += BigIntegerMath.sqrt(positive[j], mode).intValue();
    }
    return tmp;
  }

  @Benchmark

            

Reported by PMD.

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

Line: 87

                  int tmp = 0;
    for (int i = 0; i < reps; i++) {
      int j = i & ARRAY_MASK;
      tmp += BigIntegerMath.divide(nonzero1[j], nonzero2[j], mode).intValue();
    }
    return tmp;
  }

  @Benchmark

            

Reported by PMD.

guava-tests/test/com/google/common/collect/ForwardingMultimapTest.java
4 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: 31

               */
public class ForwardingMultimapTest extends TestCase {

  @SuppressWarnings("rawtypes")
  public void testForwarding() {
    new ForwardingWrapperTester()
        .testForwarding(
            Multimap.class,
            new Function<Multimap, Multimap>() {

            

Reported by PMD.

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

Line: 32

              public class ForwardingMultimapTest extends TestCase {

  @SuppressWarnings("rawtypes")
  public void testForwarding() {
    new ForwardingWrapperTester()
        .testForwarding(
            Multimap.class,
            new Function<Multimap, Multimap>() {
              @Override

            

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

                          });
  }

  public void testEquals() {
    Multimap<Integer, String> map1 = ImmutableMultimap.of(1, "one");
    Multimap<Integer, String> map2 = ImmutableMultimap.of(2, "two");
    new EqualsTester()
        .addEqualityGroup(map1, wrap(map1), wrap(map1))
        .addEqualityGroup(map2, wrap(map2))

            

Reported by PMD.

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

Line: 44

                          });
  }

  public void testEquals() {
    Multimap<Integer, String> map1 = ImmutableMultimap.of(1, "one");
    Multimap<Integer, String> map2 = ImmutableMultimap.of(2, "two");
    new EqualsTester()
        .addEqualityGroup(map1, wrap(map1), wrap(map1))
        .addEqualityGroup(map2, wrap(map2))

            

Reported by PMD.

guava-tests/benchmark/com/google/common/math/IntMathRoundingBenchmark.java
4 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 40

                private static final int[] nonzero = new int[ARRAY_SIZE];
  private static final int[] ints = new int[ARRAY_SIZE];

  @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positive[i] = randomPositiveBigInteger(Integer.SIZE - 2).intValue();
      nonzero[i] = randomNonZeroBigInteger(Integer.SIZE - 2).intValue();
      ints[i] = RANDOM_SOURCE.nextInt();

            

Reported by PMD.

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

Line: 43

                @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positive[i] = randomPositiveBigInteger(Integer.SIZE - 2).intValue();
      nonzero[i] = randomNonZeroBigInteger(Integer.SIZE - 2).intValue();
      ints[i] = RANDOM_SOURCE.nextInt();
    }
  }


            

Reported by PMD.

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

Line: 44

                void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positive[i] = randomPositiveBigInteger(Integer.SIZE - 2).intValue();
      nonzero[i] = randomNonZeroBigInteger(Integer.SIZE - 2).intValue();
      ints[i] = RANDOM_SOURCE.nextInt();
    }
  }

  @Param({"DOWN", "UP", "FLOOR", "CEILING", "HALF_EVEN", "HALF_UP", "HALF_DOWN"})

            

Reported by PMD.

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

Line: 50

                }

  @Param({"DOWN", "UP", "FLOOR", "CEILING", "HALF_EVEN", "HALF_UP", "HALF_DOWN"})
  RoundingMode mode;

  @Benchmark
  int log2(int reps) {
    int tmp = 0;
    for (int i = 0; i < reps; i++) {

            

Reported by PMD.

guava-tests/benchmark/com/google/common/math/LongMathRoundingBenchmark.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 37

               */
public class LongMathRoundingBenchmark {
  @Param({"DOWN", "UP", "FLOOR", "CEILING", "HALF_EVEN", "HALF_UP", "HALF_DOWN"})
  RoundingMode mode;

  private static final long[] positive = new long[ARRAY_SIZE];
  private static final long[] nonzero = new long[ARRAY_SIZE];
  private static final long[] longs = new long[ARRAY_SIZE];


            

Reported by PMD.

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

Line: 43

                private static final long[] nonzero = new long[ARRAY_SIZE];
  private static final long[] longs = new long[ARRAY_SIZE];

  @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positive[i] = randomPositiveBigInteger(Long.SIZE - 2).longValue();
      nonzero[i] = randomNonZeroBigInteger(Long.SIZE - 2).longValue();
      longs[i] = RANDOM_SOURCE.nextLong();

            

Reported by PMD.

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

Line: 46

                @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positive[i] = randomPositiveBigInteger(Long.SIZE - 2).longValue();
      nonzero[i] = randomNonZeroBigInteger(Long.SIZE - 2).longValue();
      longs[i] = RANDOM_SOURCE.nextLong();
    }
  }


            

Reported by PMD.

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

Line: 47

                void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positive[i] = randomPositiveBigInteger(Long.SIZE - 2).longValue();
      nonzero[i] = randomNonZeroBigInteger(Long.SIZE - 2).longValue();
      longs[i] = RANDOM_SOURCE.nextLong();
    }
  }

  @Benchmark

            

Reported by PMD.

guava-tests/benchmark/com/google/common/primitives/UnsignedLongsBenchmark.java
4 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 39

                private static final String[] hexStrings = new String[ARRAY_SIZE];
  private static final String[] prefixedHexStrings = new String[ARRAY_SIZE];

  @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      longs[i] = random();
      divisors[i] = randomDivisor(longs[i]);
      decimalStrings[i] = UnsignedLongs.toString(longs[i]);

            

Reported by PMD.

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

Line: 115

                  for (int i = 0; i < scaledReps; i++) {
      int j = i & ARRAY_MASK;
      long x = longs[j];
      tmp += UnsignedLongs.toString(x).length();
      tmp += UnsignedLongs.toString(x, 16).length();
      tmp += UnsignedLongs.toString(x, 2).length();
    }
    return tmp;
  }

            

Reported by PMD.

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

Line: 116

                    int j = i & ARRAY_MASK;
      long x = longs[j];
      tmp += UnsignedLongs.toString(x).length();
      tmp += UnsignedLongs.toString(x, 16).length();
      tmp += UnsignedLongs.toString(x, 2).length();
    }
    return tmp;
  }


            

Reported by PMD.

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

Line: 117

                    long x = longs[j];
      tmp += UnsignedLongs.toString(x).length();
      tmp += UnsignedLongs.toString(x, 16).length();
      tmp += UnsignedLongs.toString(x, 2).length();
    }
    return tmp;
  }

  private static long random() {

            

Reported by PMD.

guava-tests/benchmark/com/google/common/collect/PowerSetBenchmark.java
3 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

               */
public class PowerSetBenchmark {
  @Param({"2", "4", "8", "16"})
  int elements;

  Set<Set<Integer>> powerSet;

  @BeforeExperiment
  void setUp() {

            

Reported by PMD.

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

Line: 35

                @Param({"2", "4", "8", "16"})
  int elements;

  Set<Set<Integer>> powerSet;

  @BeforeExperiment
  void setUp() {
    Set<Integer> set = ContiguousSet.create(Range.closed(1, elements), integers());
    powerSet = Sets.powerSet(set);

            

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

              
  Set<Set<Integer>> powerSet;

  @BeforeExperiment
  void setUp() {
    Set<Integer> set = ContiguousSet.create(Range.closed(1, elements), integers());
    powerSet = Sets.powerSet(set);
  }


            

Reported by PMD.