The following issues were found

android/guava-testlib/src/com/google/common/escape/testing/EscaperAsserts.java
3 issues
Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 52

                  try {
      escaper.escape((String) null);
      Assert.fail("exception not thrown when escaping a null string");
    } catch (NullPointerException e) {
      // pass
    }
  }

  /**

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 52

                  try {
      escaper.escape((String) null);
      Assert.fail("exception not thrown when escaping a null string");
    } catch (NullPointerException e) {
      // pass
    }
  }

  /**

            

Reported by PMD.

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

Line: 52

                  try {
      escaper.escape((String) null);
      Assert.fail("exception not thrown when escaping a null string");
    } catch (NullPointerException e) {
      // pass
    }
  }

  /**

            

Reported by PMD.

android/guava-testlib/src/com/google/common/util/concurrent/testing/TestingExecutors.java
3 issues
Field shutdown has the same name as a method
Error

Line: 98

                private static final class NoOpScheduledExecutorService extends AbstractListeningExecutorService
      implements ListeningScheduledExecutorService {

    private volatile boolean shutdown;

    @Override
    public void shutdown() {
      shutdown = true;
    }

            

Reported by PMD.

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

Line: 98

                private static final class NoOpScheduledExecutorService extends AbstractListeningExecutorService
      implements ListeningScheduledExecutorService {

    private volatile boolean shutdown;

    @Override
    public void shutdown() {
      shutdown = true;
    }

            

Reported by PMD.

Avoid unused imports such as 'com.google.common.util.concurrent.MoreExecutors'
Design

Line: 27

              import com.google.common.util.concurrent.AbstractListeningExecutorService;
import com.google.common.util.concurrent.ListenableScheduledFuture;
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Delayed;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

            

Reported by PMD.

android/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java
3 issues
Avoid throwing null pointer exceptions.
Design

Line: 39

                              // TODO: MinimalCollection should perhaps throw
                for (Object element : elements) {
                  if (element == null) {
                    throw new NullPointerException();
                  }
                }
                return MinimalCollection.of(elements);
              }
            })

            

Reported by PMD.

This class name ends with Test but contains no test cases
Error

Line: 30

               *
 * @author Kevin Bourrillion
 */
public class MinimalCollectionTest extends TestCase {
  public static Test suite() {
    return CollectionTestSuiteBuilder.using(
            new TestStringCollectionGenerator() {
              @Override
              public Collection<String> create(String[] elements) {

            

Reported by PMD.

JUnit 4 indicates test suites via annotations, not the suite method.
Design

Line: 31

               * @author Kevin Bourrillion
 */
public class MinimalCollectionTest extends TestCase {
  public static Test suite() {
    return CollectionTestSuiteBuilder.using(
            new TestStringCollectionGenerator() {
              @Override
              public Collection<String> create(String[] elements) {
                // TODO: MinimalCollection should perhaps throw

            

Reported by PMD.

android/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.

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

Line: 40

                private static final double[] positiveDoubles = new double[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++) {
      doubleInIntRange[i] = randomDouble(Integer.SIZE - 2);

            

Reported by PMD.

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

Line: 42

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

  @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      doubleInIntRange[i] = randomDouble(Integer.SIZE - 2);
      doubleInLongRange[i] = randomDouble(Long.SIZE - 2);
      positiveDoubles[i] = randomPositiveDouble();

            

Reported by PMD.

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

Line: 76

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

  @Benchmark

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/ListCreationTester.java
3 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: 38

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListCreationTester<E> extends AbstractListTester<E> {
  @CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
  @CollectionSize.Require(absent = {ZERO, ONE})
  public void testCreateWithDuplicates() {
    E[] array = createSamplesArray();
    array[1] = e0();
    collection = getSubjectGenerator().create(array);

            

Reported by PMD.

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

Line: 43

                public void testCreateWithDuplicates() {
    E[] array = createSamplesArray();
    array[1] = e0();
    collection = getSubjectGenerator().create(array);

    expectContents(array);
  }
}

            

Reported by PMD.

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

Line: 41

                @CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
  @CollectionSize.Require(absent = {ZERO, ONE})
  public void testCreateWithDuplicates() {
    E[] array = createSamplesArray();
    array[1] = e0();
    collection = getSubjectGenerator().create(array);

    expectContents(array);
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/TestingRemovalListeners.java
3 issues
All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 28

               * @author mike nonemacher
 */
@GwtCompatible(emulated = true)
class TestingRemovalListeners {

  /** Returns a new no-op {@code RemovalListener}. */
  static <K, V> NullRemovalListener<K, V> nullRemovalListener() {
    return new NullRemovalListener<>();
  }

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 48

              
  /** {@link RemovalListener} that adds all {@link RemovalNotification} objects to a queue. */
  @GwtIncompatible // ConcurrentLinkedQueue
  static class QueuingRemovalListener<K, V> extends ConcurrentLinkedQueue<RemovalNotification<K, V>>
      implements RemovalListener<K, V> {

    @Override
    public void onRemoval(RemovalNotification<K, V> notification) {
      add(notification);

            

Reported by PMD.

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

Line: 63

                 */
  static class CountingRemovalListener<K, V> implements RemovalListener<K, V> {
    private final AtomicInteger count = new AtomicInteger();
    private volatile RemovalNotification<K, V> lastNotification;

    @Override
    public void onRemoval(RemovalNotification<K, V> notification) {
      count.incrementAndGet();
      lastNotification = notification;

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/SetMultimapReplaceValuesTester.java
3 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: 37

              public class SetMultimapReplaceValuesTester<K, V>
    extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {

  @MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
  public void testReplaceValuesHandlesDuplicates() {
    @SuppressWarnings("unchecked")
    List<V> values = Arrays.asList(v0(), v1(), v0());

    for (K k : sampleKeys()) {

            

Reported by PMD.

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

Line: 44

              
    for (K k : sampleKeys()) {
      resetContainer();
      multimap().replaceValues(k, values);
      assertGet(k, v0(), v1());
    }
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'values' (lines '40'-'47').
Error

Line: 40

                @MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
  public void testReplaceValuesHandlesDuplicates() {
    @SuppressWarnings("unchecked")
    List<V> values = Arrays.asList(v0(), v1(), v0());

    for (K k : sampleKeys()) {
      resetContainer();
      multimap().replaceValues(k, values);
      assertGet(k, v0(), v1());

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/SetMultimapEqualsTester.java
3 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: 34

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapEqualsTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
  @CollectionSize.Require(SEVERAL)
  public void testOrderingDoesntAffectEqualsComparisons() {
    SetMultimap<K, V> multimap1 =
        getSubjectGenerator()
            .create(
                Helpers.mapEntry(k0(), v0()),

            

Reported by PMD.

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

Line: 37

                @CollectionSize.Require(SEVERAL)
  public void testOrderingDoesntAffectEqualsComparisons() {
    SetMultimap<K, V> multimap1 =
        getSubjectGenerator()
            .create(
                Helpers.mapEntry(k0(), v0()),
                Helpers.mapEntry(k0(), v1()),
                Helpers.mapEntry(k0(), v4()));
    SetMultimap<K, V> multimap2 =

            

Reported by PMD.

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

Line: 43

                              Helpers.mapEntry(k0(), v1()),
                Helpers.mapEntry(k0(), v4()));
    SetMultimap<K, V> multimap2 =
        getSubjectGenerator()
            .create(
                Helpers.mapEntry(k0(), v1()),
                Helpers.mapEntry(k0(), v0()),
                Helpers.mapEntry(k0(), v4()));
    new EqualsTester().addEqualityGroup(multimap1, multimap2).testEquals();

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/ImmutableMultimapAsMapImplementsMapTest.java
3 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 39

              
  @Override
  protected Map<String, Collection<Integer>> makeEmptyMap() {
    return ImmutableMultimap.<String, Integer>of().asMap();
  }

  @Override
  protected Map<String, Collection<Integer>> makePopulatedMap() {
    Multimap<String, Integer> delegate = HashMultimap.create();

            

Reported by PMD.

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

Line: 39

              
  @Override
  protected Map<String, Collection<Integer>> makeEmptyMap() {
    return ImmutableMultimap.<String, Integer>of().asMap();
  }

  @Override
  protected Map<String, Collection<Integer>> makePopulatedMap() {
    Multimap<String, Integer> delegate = HashMultimap.create();

            

Reported by PMD.

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

Line: 46

                protected Map<String, Collection<Integer>> makePopulatedMap() {
    Multimap<String, Integer> delegate = HashMultimap.create();
    populate(delegate);
    return ImmutableMultimap.copyOf(delegate).asMap();
  }
}

            

Reported by PMD.