The following issues were found

guava-testlib/src/com/google/common/collect/testing/testers/QueueOfferTester.java
8 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: 36

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class QueueOfferTester<E> extends AbstractQueueTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  public void testOffer_supportedNotPresent() {
    assertTrue("offer(notPresent) should return true", getQueue().offer(e3()));
    expectAdded(e3());
  }


            

Reported by PMD.

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

Line: 38

              public class QueueOfferTester<E> extends AbstractQueueTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  public void testOffer_supportedNotPresent() {
    assertTrue("offer(notPresent) should return true", getQueue().offer(e3()));
    expectAdded(e3());
  }

  @CollectionFeature.Require({SUPPORTS_ADD, ALLOWS_NULL_VALUES})
  public void testOffer_nullSupported() {

            

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

                  expectAdded(e3());
  }

  @CollectionFeature.Require({SUPPORTS_ADD, ALLOWS_NULL_VALUES})
  public void testOffer_nullSupported() {
    assertTrue("offer(null) should return true", getQueue().offer(null));
    expectAdded((E) null);
  }


            

Reported by PMD.

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

Line: 44

              
  @CollectionFeature.Require({SUPPORTS_ADD, ALLOWS_NULL_VALUES})
  public void testOffer_nullSupported() {
    assertTrue("offer(null) should return true", getQueue().offer(null));
    expectAdded((E) null);
  }

  @CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES)
  public void testOffer_nullUnsupported() {

            

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

                  expectAdded((E) null);
  }

  @CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES)
  public void testOffer_nullUnsupported() {
    try {
      getQueue().offer(null);
      fail("offer(null) should throw");
    } catch (NullPointerException expected) {

            

Reported by PMD.

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

Line: 51

                @CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES)
  public void testOffer_nullUnsupported() {
    try {
      getQueue().offer(null);
      fail("offer(null) should throw");
    } catch (NullPointerException expected) {
    }
    expectUnchanged();
    expectNullMissingWhenNullUnsupported("Should not contain null after unsupported offer(null)");

            

Reported by PMD.

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

Line: 53

                  try {
      getQueue().offer(null);
      fail("offer(null) should throw");
    } catch (NullPointerException expected) {
    }
    expectUnchanged();
    expectNullMissingWhenNullUnsupported("Should not contain null after unsupported offer(null)");
  }
}

            

Reported by PMD.

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

Line: 53

                  try {
      getQueue().offer(null);
      fail("offer(null) should throw");
    } catch (NullPointerException expected) {
    }
    expectUnchanged();
    expectNullMissingWhenNullUnsupported("Should not contain null after unsupported offer(null)");
  }
}

            

Reported by PMD.

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

Line: 35

                    ContiguousSet.create(Range.closed(0, 10), DiscreteDomain.integers());

  @Param({"10", "100", "1000", "10000", "100000"})
  int datasetSize;

  @Param QuantilesAlgorithm algorithm;

  private double[][] datasets = new double[0x100][];


            

Reported by PMD.

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

Line: 37

                @Param({"10", "100", "1000", "10000", "100000"})
  int datasetSize;

  @Param QuantilesAlgorithm algorithm;

  private double[][] datasets = new double[0x100][];

  @BeforeExperiment
  void setUp() {

            

Reported by PMD.

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

Line: 39

              
  @Param QuantilesAlgorithm algorithm;

  private double[][] datasets = new double[0x100][];

  @BeforeExperiment
  void setUp() {
    Random rng = new Random();
    for (int i = 0; i < 0x100; i++) {

            

Reported by PMD.

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

Line: 41

              
  private double[][] datasets = new double[0x100][];

  @BeforeExperiment
  void setUp() {
    Random rng = new Random();
    for (int i = 0; i < 0x100; i++) {
      datasets[i] = new double[datasetSize];
      for (int j = 0; j < datasetSize; j++) {

            

Reported by PMD.

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

Line: 89

                double percentiles90And99(int reps) {
    double dummy = 0.0;
    for (int i = 0; i < reps; i++) {
      dummy += algorithm.multipleQuantiles(ImmutableSet.of(90, 99), 100, dataset(i)).get(90);
    }
    return dummy;
  }

  @Benchmark

            

Reported by PMD.

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

Line: 98

                double threePercentiles(int reps) {
    double dummy = 0.0;
    for (int i = 0; i < reps; i++) {
      dummy += algorithm.multipleQuantiles(ImmutableSet.of(90, 95, 99), 100, dataset(i)).get(90);
    }
    return dummy;
  }

  @Benchmark

            

Reported by PMD.

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

Line: 107

                double allDeciles(int reps) {
    double dummy = 0.0;
    for (int i = 0; i < reps; i++) {
      dummy += algorithm.multipleQuantiles(ALL_DECILE_INDEXES, 10, dataset(i)).get(9);
    }
    return dummy;
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'rng' (lines '43'-'50').
Error

Line: 43

              
  @BeforeExperiment
  void setUp() {
    Random rng = new Random();
    for (int i = 0; i < 0x100; i++) {
      datasets[i] = new double[datasetSize];
      for (int j = 0; j < datasetSize; j++) {
        datasets[i][j] = rng.nextDouble();
      }

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/ListAddTester.java
8 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: 42

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListAddTester<E> extends AbstractListTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)
  public void testAdd_supportedPresent() {
    assertTrue("add(present) should return true", getList().add(e0()));
    expectAdded(e0());
  }

            

Reported by PMD.

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

Line: 45

                @CollectionFeature.Require(SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)
  public void testAdd_supportedPresent() {
    assertTrue("add(present) should return true", getList().add(e0()));
    expectAdded(e0());
  }

  @CollectionFeature.Require(absent = SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)

            

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

                  expectAdded(e0());
  }

  @CollectionFeature.Require(absent = SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)
  /*
   * absent = ZERO isn't required, since unmodList.add() must
   * throw regardless, but it keeps the method name accurate.
   */

            

Reported by PMD.

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

Line: 57

                 */
  public void testAdd_unsupportedPresent() {
    try {
      getList().add(e0());
      fail("add(present) should throw");
    } catch (UnsupportedOperationException 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: 63

                  }
  }

  @CollectionFeature.Require(value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES})
  @CollectionSize.Require(absent = ZERO)
  public void testAdd_supportedNullPresent() {
    E[] array = createArrayWithNullElement();
    collection = getSubjectGenerator().create(array);
    assertTrue("add(nullPresent) should return true", getList().add(null));

            

Reported by PMD.

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

Line: 67

                @CollectionSize.Require(absent = ZERO)
  public void testAdd_supportedNullPresent() {
    E[] array = createArrayWithNullElement();
    collection = getSubjectGenerator().create(array);
    assertTrue("add(nullPresent) should return true", getList().add(null));

    List<E> expected = Helpers.copyToList(array);
    expected.add(null);
    expectContents(expected);

            

Reported by PMD.

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

Line: 68

                public void testAdd_supportedNullPresent() {
    E[] array = createArrayWithNullElement();
    collection = getSubjectGenerator().create(array);
    assertTrue("add(nullPresent) should return true", getList().add(null));

    List<E> expected = Helpers.copyToList(array);
    expected.add(null);
    expectContents(expected);
  }

            

Reported by PMD.

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

Line: 71

                  assertTrue("add(nullPresent) should return true", getList().add(null));

    List<E> expected = Helpers.copyToList(array);
    expected.add(null);
    expectContents(expected);
  }

  /**
   * Returns the {@link Method} instance for {@link #testAdd_supportedNullPresent()} so that tests

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/CollectionContainsTester.java
8 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: 40

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionContainsTester<E> extends AbstractCollectionTester<E> {
  @CollectionSize.Require(absent = ZERO)
  public void testContains_yes() {
    assertTrue("contains(present) should return true", collection.contains(e0()));
  }

  public void testContains_no() {

            

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

                  assertTrue("contains(present) should return true", collection.contains(e0()));
  }

  public void testContains_no() {
    assertFalse("contains(notPresent) should return false", collection.contains(e3()));
  }

  @CollectionFeature.Require(ALLOWS_NULL_QUERIES)
  public void testContains_nullNotContainedButQueriesSupported() {

            

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

                  assertFalse("contains(notPresent) should return false", collection.contains(e3()));
  }

  @CollectionFeature.Require(ALLOWS_NULL_QUERIES)
  public void testContains_nullNotContainedButQueriesSupported() {
    assertFalse("contains(null) should return false", collection.contains(null));
  }

  @CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES)

            

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

                  assertFalse("contains(null) should return false", collection.contains(null));
  }

  @CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES)
  public void testContains_nullNotContainedAndUnsupported() {
    expectNullMissingWhenNullUnsupported("contains(null) should return false or throw");
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)

            

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

                  expectNullMissingWhenNullUnsupported("contains(null) should return false or throw");
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testContains_nonNullWhenNullContained() {
    initCollectionWithNullElement();
    assertFalse("contains(notPresent) should return false", collection.contains(e3()));
  }

            

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

                  assertFalse("contains(notPresent) should return false", collection.contains(e3()));
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testContains_nullContained() {
    initCollectionWithNullElement();
    assertTrue("contains(null) should return true", collection.contains(null));
  }

            

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

                  assertTrue("contains(null) should return true", collection.contains(null));
  }

  public void testContains_wrongType() {
    try {
      assertFalse(
          "contains(wrongType) should return false or throw", collection.contains(WrongType.VALUE));
    } catch (ClassCastException tolerated) {
    }

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 77

                  try {
      assertFalse(
          "contains(wrongType) should return false or throw", collection.contains(WrongType.VALUE));
    } catch (ClassCastException tolerated) {
    }
  }
}

            

Reported by PMD.

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

Line: 35

               * @author Sverre Sundsdal
 */
public class MinMaxPriorityQueueBenchmark {
  @Param private ComparatorType comparator;

  // TODO(kevinb): add 1000000 back when we have the ability to throw
  // NotApplicableException in the expensive comparator case.
  @Param({"100", "10000"})
  private int size;

            

Reported by PMD.

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

Line: 40

                // TODO(kevinb): add 1000000 back when we have the ability to throw
  // NotApplicableException in the expensive comparator case.
  @Param({"100", "10000"})
  private int size;

  @Param private HeapType heap;

  private Queue<Integer> queue;


            

Reported by PMD.

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

Line: 42

                @Param({"100", "10000"})
  private int size;

  @Param private HeapType heap;

  private Queue<Integer> queue;

  private final Random random = new Random();


            

Reported by PMD.

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

Line: 44

              
  @Param private HeapType heap;

  private Queue<Integer> queue;

  private final Random random = new Random();

  @BeforeExperiment
  void setUp() {

            

Reported by PMD.

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

Line: 46

              
  private Queue<Integer> queue;

  private final Random random = new Random();

  @BeforeExperiment
  void setUp() {
    queue = heap.create(comparator.get());
    for (int i = 0; i < size; i++) {

            

Reported by PMD.

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

Line: 48

              
  private final Random random = new Random();

  @BeforeExperiment
  void setUp() {
    queue = heap.create(comparator.get());
    for (int i = 0; i < size; i++) {
      queue.add(random.nextInt());
    }

            

Reported by PMD.

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

Line: 81

                 * pollMax using the same code that benchmarks poll.
   */
  static final class InvertedMinMaxPriorityQueue<T> extends ForwardingQueue<T> {
    MinMaxPriorityQueue<T> mmHeap;

    public InvertedMinMaxPriorityQueue(Comparator<T> comparator) {
      mmHeap = MinMaxPriorityQueue.orderedBy(comparator).create();
    }


            

Reported by PMD.

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

Line: 102

                  MIN_MAX {
      @Override
      public Queue<Integer> create(Comparator<Integer> comparator) {
        return MinMaxPriorityQueue.orderedBy(comparator).create();
      }
    },
    PRIORITY_QUEUE {
      @Override
      public Queue<Integer> create(Comparator<Integer> comparator) {

            

Reported by PMD.

guava-tests/test/com/google/common/collect/AbstractMultimapAsMapImplementsMapTest.java
8 issues
A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 49

                }

  @Override
  protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
    return "zero";
  }

  @Override
  protected Collection<Integer> getValueNotInPopulatedMap() throws UnsupportedOperationException {

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 54

                }

  @Override
  protected Collection<Integer> getValueNotInPopulatedMap() throws UnsupportedOperationException {
    return Lists.newArrayList(0);
  }

  /**
   * The version of this test supplied by {@link MapInterfaceTest} fails for this particular Map

            

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

                 * of a call to {@code remove()}. Thus, the expectation doesn't hold that {@code map.remove(x)}
   * returns the same value which {@code map.get(x)} did immediately beforehand.
   */
  @Override
  public void testRemove() {
    final Map<String, Collection<Integer>> map;
    final String keyToRemove;
    try {
      map = makePopulatedMap();

            

Reported by PMD.

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

Line: 65

                 * returns the same value which {@code map.get(x)} did immediately beforehand.
   */
  @Override
  public void testRemove() {
    final Map<String, Collection<Integer>> map;
    final String keyToRemove;
    try {
      map = makePopulatedMap();
    } catch (UnsupportedOperationException e) {

            

Reported by PMD.

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

Line: 73

                  } catch (UnsupportedOperationException e) {
      return;
    }
    keyToRemove = map.keySet().iterator().next();
    if (supportsRemove) {
      int initialSize = map.size();
      map.get(keyToRemove);
      map.remove(keyToRemove);
      // This line doesn't hold - see the Javadoc comments above.

            

Reported by PMD.

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

Line: 73

                  } catch (UnsupportedOperationException e) {
      return;
    }
    keyToRemove = map.keySet().iterator().next();
    if (supportsRemove) {
      int initialSize = map.size();
      map.get(keyToRemove);
      map.remove(keyToRemove);
      // This line doesn't hold - see the Javadoc comments above.

            

Reported by PMD.

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

Line: 73

                  } catch (UnsupportedOperationException e) {
      return;
    }
    keyToRemove = map.keySet().iterator().next();
    if (supportsRemove) {
      int initialSize = map.size();
      map.get(keyToRemove);
      map.remove(keyToRemove);
      // This line doesn't hold - see the Javadoc comments above.

            

Reported by PMD.

Found 'DU'-anomaly for variable 'map' (lines '69'-'90').
Error

Line: 69

                  final Map<String, Collection<Integer>> map;
    final String keyToRemove;
    try {
      map = makePopulatedMap();
    } catch (UnsupportedOperationException e) {
      return;
    }
    keyToRemove = map.keySet().iterator().next();
    if (supportsRemove) {

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/SortedMapGenerators.java
8 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 90

                    return new Ordering<Entry<String, Integer>>() {
        @Override
        public int compare(Entry<String, Integer> left, Entry<String, Integer> right) {
          return left.getKey().compareTo(right.getKey());
        }
      }.sortedCopy(insertionOrder);
    }

    @Override

            

Reported by PMD.

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

Line: 103

                      Entry<String, Integer> entry = (Entry<String, Integer>) o;
        builder.put(entry);
      }
      return builder.build().entrySet().asList();
    }
  }

  public static class ImmutableSortedMapKeyListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 103

                      Entry<String, Integer> entry = (Entry<String, Integer>) o;
        builder.put(entry);
      }
      return builder.build().entrySet().asList();
    }
  }

  public static class ImmutableSortedMapKeyListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 114

                    for (int i = 0; i < elements.length; i++) {
        builder.put(elements[i], i);
      }
      return builder.build().keySet().asList();
    }

    @Override
    public List<String> order(List<String> insertionOrder) {
      return Ordering.natural().sortedCopy(insertionOrder);

            

Reported by PMD.

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

Line: 114

                    for (int i = 0; i < elements.length; i++) {
        builder.put(elements[i], i);
      }
      return builder.build().keySet().asList();
    }

    @Override
    public List<String> order(List<String> insertionOrder) {
      return Ordering.natural().sortedCopy(insertionOrder);

            

Reported by PMD.

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

Line: 119

              
    @Override
    public List<String> order(List<String> insertionOrder) {
      return Ordering.natural().sortedCopy(insertionOrder);
    }
  }

  public static class ImmutableSortedMapValueListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 130

                    for (int i = 0; i < elements.length; i++) {
        builder.put(i, elements[i]);
      }
      return builder.build().values().asList();
    }
  }
}

            

Reported by PMD.

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

Line: 130

                    for (int i = 0; i < elements.length; i++) {
        builder.put(i, elements[i]);
      }
      return builder.build().values().asList();
    }
  }
}

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultisetForEachEntryTester.java
8 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: 42

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetForEachEntryTester<E> extends AbstractMultisetTester<E> {
  public void testForEachEntry() {
    List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
    List<Entry<E>> actual = new ArrayList<>();
    getMultiset()
        .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
    Helpers.assertEqualIgnoringOrder(expected, actual);

            

Reported by PMD.

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

Line: 43

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetForEachEntryTester<E> extends AbstractMultisetTester<E> {
  public void testForEachEntry() {
    List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
    List<Entry<E>> actual = new ArrayList<>();
    getMultiset()
        .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
    Helpers.assertEqualIgnoringOrder(expected, actual);
  }

            

Reported by PMD.

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

Line: 45

                public void testForEachEntry() {
    List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
    List<Entry<E>> actual = new ArrayList<>();
    getMultiset()
        .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
    Helpers.assertEqualIgnoringOrder(expected, actual);
  }

  @CollectionFeature.Require(KNOWN_ORDER)

            

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

                  Helpers.assertEqualIgnoringOrder(expected, actual);
  }

  @CollectionFeature.Require(KNOWN_ORDER)
  public void testForEachEntryOrdered() {
    List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
    List<Entry<E>> actual = new ArrayList<>();
    getMultiset()
        .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));

            

Reported by PMD.

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

Line: 52

              
  @CollectionFeature.Require(KNOWN_ORDER)
  public void testForEachEntryOrdered() {
    List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
    List<Entry<E>> actual = new ArrayList<>();
    getMultiset()
        .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
    assertEquals(expected, actual);
  }

            

Reported by PMD.

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

Line: 54

                public void testForEachEntryOrdered() {
    List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
    List<Entry<E>> actual = new ArrayList<>();
    getMultiset()
        .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
    assertEquals(expected, actual);
  }

  public void testForEachEntryDuplicates() {

            

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

                  assertEquals(expected, actual);
  }

  public void testForEachEntryDuplicates() {
    initThreeCopies();
    List<Entry<E>> expected = Collections.singletonList(Multisets.immutableEntry(e0(), 3));
    List<Entry<E>> actual = new ArrayList<>();
    getMultiset()
        .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));

            

Reported by PMD.

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

Line: 63

                  initThreeCopies();
    List<Entry<E>> expected = Collections.singletonList(Multisets.immutableEntry(e0(), 3));
    List<Entry<E>> actual = new ArrayList<>();
    getMultiset()
        .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
    assertEquals(expected, actual);
  }

  /**

            

Reported by PMD.

guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java
8 issues
This class has too many methods, consider refactoring it.
Design

Line: 44

               * @author Louis Wasserman
 */
public class ForwardingNavigableSetTest extends TestCase {
  static class StandardImplForwardingNavigableSet<T> extends ForwardingNavigableSet<T> {
    private final NavigableSet<T> backingSet;

    StandardImplForwardingNavigableSet(NavigableSet<T> backingSet) {
      this.backingSet = backingSet;
    }

            

Reported by PMD.

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

Line: 45

               */
public class ForwardingNavigableSetTest extends TestCase {
  static class StandardImplForwardingNavigableSet<T> extends ForwardingNavigableSet<T> {
    private final NavigableSet<T> backingSet;

    StandardImplForwardingNavigableSet(NavigableSet<T> backingSet) {
      this.backingSet = backingSet;
    }


            

Reported by PMD.

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

Line: 162

                  }
  }

  public static Test suite() {
    TestSuite suite = new TestSuite();

    suite.addTestSuite(ForwardingNavigableSetTest.class);
    suite.addTest(
        SetTestSuiteBuilder.using(

            

Reported by PMD.

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

Line: 191

                              new TestStringSetGenerator() {
                  @Override
                  protected Set<String> create(String[] elements) {
                    SafeTreeSet<String> set = new SafeTreeSet<>(Ordering.natural().nullsFirst());
                    Collections.addAll(set, elements);
                    return new StandardImplForwardingNavigableSet<>(set);
                  }

                  @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: 214

                  return suite;
  }

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

            

Reported by PMD.

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

Line: 215

                }

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

            

Reported by PMD.

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

Line: 227

                          });
  }

  public void testEquals() {
    NavigableSet<String> set1 = ImmutableSortedSet.of("one");
    NavigableSet<String> set2 = ImmutableSortedSet.of("two");
    new EqualsTester()
        .addEqualityGroup(set1, wrap(set1), wrap(set1))
        .addEqualityGroup(set2, wrap(set2))

            

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

                          });
  }

  public void testEquals() {
    NavigableSet<String> set1 = ImmutableSortedSet.of("one");
    NavigableSet<String> set2 = ImmutableSortedSet.of("two");
    new EqualsTester()
        .addEqualityGroup(set1, wrap(set1), wrap(set1))
        .addEqualityGroup(set2, wrap(set2))

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/AbstractMultimapAsMapImplementsMapTest.java
8 issues
A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 49

                }

  @Override
  protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
    return "zero";
  }

  @Override
  protected Collection<Integer> getValueNotInPopulatedMap() throws UnsupportedOperationException {

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 54

                }

  @Override
  protected Collection<Integer> getValueNotInPopulatedMap() throws UnsupportedOperationException {
    return Lists.newArrayList(0);
  }

  /**
   * The version of this test supplied by {@link MapInterfaceTest} fails for this particular Map

            

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

                 * of a call to {@code remove()}. Thus, the expectation doesn't hold that {@code map.remove(x)}
   * returns the same value which {@code map.get(x)} did immediately beforehand.
   */
  @Override
  public void testRemove() {
    final Map<String, Collection<Integer>> map;
    final String keyToRemove;
    try {
      map = makePopulatedMap();

            

Reported by PMD.

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

Line: 65

                 * returns the same value which {@code map.get(x)} did immediately beforehand.
   */
  @Override
  public void testRemove() {
    final Map<String, Collection<Integer>> map;
    final String keyToRemove;
    try {
      map = makePopulatedMap();
    } catch (UnsupportedOperationException e) {

            

Reported by PMD.

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

Line: 73

                  } catch (UnsupportedOperationException e) {
      return;
    }
    keyToRemove = map.keySet().iterator().next();
    if (supportsRemove) {
      int initialSize = map.size();
      map.get(keyToRemove);
      map.remove(keyToRemove);
      // This line doesn't hold - see the Javadoc comments above.

            

Reported by PMD.

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

Line: 73

                  } catch (UnsupportedOperationException e) {
      return;
    }
    keyToRemove = map.keySet().iterator().next();
    if (supportsRemove) {
      int initialSize = map.size();
      map.get(keyToRemove);
      map.remove(keyToRemove);
      // This line doesn't hold - see the Javadoc comments above.

            

Reported by PMD.

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

Line: 73

                  } catch (UnsupportedOperationException e) {
      return;
    }
    keyToRemove = map.keySet().iterator().next();
    if (supportsRemove) {
      int initialSize = map.size();
      map.get(keyToRemove);
      map.remove(keyToRemove);
      // This line doesn't hold - see the Javadoc comments above.

            

Reported by PMD.

Found 'DU'-anomaly for variable 'map' (lines '69'-'90').
Error

Line: 69

                  final Map<String, Collection<Integer>> map;
    final String keyToRemove;
    try {
      map = makePopulatedMap();
    } catch (UnsupportedOperationException e) {
      return;
    }
    keyToRemove = map.keySet().iterator().next();
    if (supportsRemove) {

            

Reported by PMD.