The following issues were found

android/guava-testlib/src/com/google/common/collect/testing/NavigableMapTestSuiteBuilder.java
11 issues
Avoid reassigning parameters such as 'insertionOrder'
Design

Line: 153

                  }

    @Override
    public Iterable<Entry<K, V>> order(List<Entry<K, V>> insertionOrder) {
      insertionOrder = castOrCopyToList(delegate.order(insertionOrder));
      reverse(insertionOrder);
      return insertionOrder;
    }


            

Reported by PMD.

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

Line: 52

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(NavigableMapNavigationTester.class);
    return testers;
  }

  @Override
  protected List<TestSuite> createDerivedSuites(

            

Reported by PMD.

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

Line: 63

                        parentBuilder) {
    List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);

    if (!parentBuilder.getFeatures().contains(NoRecurse.DESCENDING)) {
      derivedSuites.add(createDescendingSuite(parentBuilder));
    }

    if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
      // Other combinations are inherited from SortedMapTestSuiteBuilder.

            

Reported by PMD.

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

Line: 67

                    derivedSuites.add(createDescendingSuite(parentBuilder));
    }

    if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
      // Other combinations are inherited from SortedMapTestSuiteBuilder.
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));

            

Reported by PMD.

The method 'createSubMap(SortedMap, K, K)' has a cyclomatic complexity of 11.
Design

Line: 93

                  }

    @Override
    NavigableMap<K, V> createSubMap(SortedMap<K, V> sortedMap, K firstExclusive, K lastExclusive) {
      NavigableMap<K, V> map = (NavigableMap<K, V>) sortedMap;
      if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) {
        return map.headMap(lastInclusive, true);
      } else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) {
        return map.tailMap(firstExclusive, false);

            

Reported by PMD.

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

Line: 123

                            ?, ? extends OneSizeTestContainerGenerator<Map<K, V>, Entry<K, V>>>
          parentBuilder) {
    final TestSortedMapGenerator<K, V> delegate =
        (TestSortedMapGenerator<K, V>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(NoRecurse.DESCENDING);
    features.addAll(parentBuilder.getFeatures());


            

Reported by PMD.

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

Line: 149

                  @Override
    public NavigableMap<K, V> create(Object... entries) {
      NavigableMap<K, V> map = (NavigableMap<K, V>) delegate.create(entries);
      return map.descendingMap();
    }

    @Override
    public Iterable<Entry<K, V>> order(List<Entry<K, V>> insertionOrder) {
      insertionOrder = castOrCopyToList(delegate.order(insertionOrder));

            

Reported by PMD.

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

Line: 165

              
    @Override
    public Entry<K, V> belowSamplesLesser() {
      return delegate().aboveSamplesGreater();
    }

    @Override
    public Entry<K, V> belowSamplesGreater() {
      return delegate().aboveSamplesLesser();

            

Reported by PMD.

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

Line: 170

              
    @Override
    public Entry<K, V> belowSamplesGreater() {
      return delegate().aboveSamplesLesser();
    }

    @Override
    public Entry<K, V> aboveSamplesLesser() {
      return delegate().belowSamplesGreater();

            

Reported by PMD.

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

Line: 175

              
    @Override
    public Entry<K, V> aboveSamplesLesser() {
      return delegate().belowSamplesGreater();
    }

    @Override
    public Entry<K, V> aboveSamplesGreater() {
      return delegate().belowSamplesLesser();

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/SetMultimapPutTester.java
11 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

              public class SetMultimapPutTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
  // Tests for non-duplicate values are in MultimapPutTester

  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(absent = ZERO)
  public void testPutDuplicateValuePreservesSize() {
    assertFalse(multimap().put(k0(), v0()));
    assertEquals(getNumElements(), multimap().size());
  }

            

Reported by PMD.

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

Line: 44

              
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(absent = ZERO)
  public void testPutDuplicateValuePreservesSize() {
    assertFalse(multimap().put(k0(), v0()));
    assertEquals(getNumElements(), multimap().size());
  }

  @MapFeature.Require(SUPPORTS_PUT)

            

Reported by PMD.

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

Line: 45

                @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(absent = ZERO)
  public void testPutDuplicateValuePreservesSize() {
    assertFalse(multimap().put(k0(), v0()));
    assertEquals(getNumElements(), multimap().size());
  }

  @MapFeature.Require(SUPPORTS_PUT)
  public void testPutDuplicateValue() {

            

Reported by PMD.

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

Line: 46

                @CollectionSize.Require(absent = ZERO)
  public void testPutDuplicateValuePreservesSize() {
    assertFalse(multimap().put(k0(), v0()));
    assertEquals(getNumElements(), multimap().size());
  }

  @MapFeature.Require(SUPPORTS_PUT)
  public void testPutDuplicateValue() {
    List<Entry<K, V>> entries = copyToList(multimap().entries());

            

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

                  assertEquals(getNumElements(), multimap().size());
  }

  @MapFeature.Require(SUPPORTS_PUT)
  public void testPutDuplicateValue() {
    List<Entry<K, V>> entries = copyToList(multimap().entries());

    for (Entry<K, V> entry : entries) {
      resetContainer();

            

Reported by PMD.

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

Line: 50

                }

  @MapFeature.Require(SUPPORTS_PUT)
  public void testPutDuplicateValue() {
    List<Entry<K, V>> entries = copyToList(multimap().entries());

    for (Entry<K, V> entry : entries) {
      resetContainer();
      K k = entry.getKey();

            

Reported by PMD.

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

Line: 51

              
  @MapFeature.Require(SUPPORTS_PUT)
  public void testPutDuplicateValue() {
    List<Entry<K, V>> entries = copyToList(multimap().entries());

    for (Entry<K, V> entry : entries) {
      resetContainer();
      K k = entry.getKey();
      V v = entry.getValue();

            

Reported by PMD.

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

Line: 58

                    K k = entry.getKey();
      V v = entry.getValue();

      Set<V> values = multimap().get(k);
      Set<V> expectedValues = copyToSet(values);

      assertFalse(multimap().put(k, v));
      assertEquals(expectedValues, values);
      assertGet(k, expectedValues);

            

Reported by PMD.

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

Line: 61

                    Set<V> values = multimap().get(k);
      Set<V> expectedValues = copyToSet(values);

      assertFalse(multimap().put(k, v));
      assertEquals(expectedValues, values);
      assertGet(k, expectedValues);
    }
  }


            

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

                  }
  }

  @MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES})
  @CollectionSize.Require(absent = ZERO)
  public void testPutDuplicateValue_null() {
    initMultimapWithNullValue();
    assertFalse(multimap().put(getKeyForNullValue(), null));
    expectContents(createArrayWithNullValue());

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
11 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 45

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(SortedSetNavigationTester.class);
    return testers;
  }

  @Override
  public TestSuite createTestSuite() {

            

Reported by PMD.

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

Line: 51

              
  @Override
  public TestSuite createTestSuite() {
    if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
      List<Feature<?>> features = Helpers.copyToList(getFeatures());
      features.add(CollectionFeature.KNOWN_ORDER);
      withFeatures(features);
    }
    return super.createTestSuite();

            

Reported by PMD.

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

Line: 53

                public TestSuite createTestSuite() {
    if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
      List<Feature<?>> features = Helpers.copyToList(getFeatures());
      features.add(CollectionFeature.KNOWN_ORDER);
      withFeatures(features);
    }
    return super.createTestSuite();
  }


            

Reported by PMD.

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

Line: 65

                        parentBuilder) {
    List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);

    if (!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
    }


            

Reported by PMD.

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

Line: 87

                    final Bound from,
      final Bound to) {
    final TestSortedSetGenerator<E> delegate =
        (TestSortedSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>(parentBuilder.getFeatures());
    features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);


            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/SortedIterablesTest.java
11 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 28

               */
@GwtCompatible
public class SortedIterablesTest extends TestCase {
  public void testSameComparator() {
    assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Sets.newTreeSet()));
    // Before JDK6 (including under GWT), the TreeMap keySet is a plain Set.
    if (Maps.newTreeMap().keySet() instanceof SortedSet) {
      assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Maps.newTreeMap().keySet()));
    }

            

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

               */
@GwtCompatible
public class SortedIterablesTest extends TestCase {
  public void testSameComparator() {
    assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Sets.newTreeSet()));
    // Before JDK6 (including under GWT), the TreeMap keySet is a plain Set.
    if (Maps.newTreeMap().keySet() instanceof SortedSet) {
      assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Maps.newTreeMap().keySet()));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

              @GwtCompatible
public class SortedIterablesTest extends TestCase {
  public void testSameComparator() {
    assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Sets.newTreeSet()));
    // Before JDK6 (including under GWT), the TreeMap keySet is a plain Set.
    if (Maps.newTreeMap().keySet() instanceof SortedSet) {
      assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Maps.newTreeMap().keySet()));
    }
    assertTrue(

            

Reported by PMD.

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

Line: 31

                public void testSameComparator() {
    assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Sets.newTreeSet()));
    // Before JDK6 (including under GWT), the TreeMap keySet is a plain Set.
    if (Maps.newTreeMap().keySet() instanceof SortedSet) {
      assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Maps.newTreeMap().keySet()));
    }
    assertTrue(
        SortedIterables.hasSameComparator(
            Ordering.natural().reverse(), Sets.newTreeSet(Ordering.natural().reverse())));

            

Reported by PMD.

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

Line: 32

                  assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Sets.newTreeSet()));
    // Before JDK6 (including under GWT), the TreeMap keySet is a plain Set.
    if (Maps.newTreeMap().keySet() instanceof SortedSet) {
      assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Maps.newTreeMap().keySet()));
    }
    assertTrue(
        SortedIterables.hasSameComparator(
            Ordering.natural().reverse(), Sets.newTreeSet(Ordering.natural().reverse())));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

                  assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Sets.newTreeSet()));
    // Before JDK6 (including under GWT), the TreeMap keySet is a plain Set.
    if (Maps.newTreeMap().keySet() instanceof SortedSet) {
      assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Maps.newTreeMap().keySet()));
    }
    assertTrue(
        SortedIterables.hasSameComparator(
            Ordering.natural().reverse(), Sets.newTreeSet(Ordering.natural().reverse())));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                  if (Maps.newTreeMap().keySet() instanceof SortedSet) {
      assertTrue(SortedIterables.hasSameComparator(Ordering.natural(), Maps.newTreeMap().keySet()));
    }
    assertTrue(
        SortedIterables.hasSameComparator(
            Ordering.natural().reverse(), Sets.newTreeSet(Ordering.natural().reverse())));
  }

  public void testComparator() {

            

Reported by PMD.

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

Line: 36

                  }
    assertTrue(
        SortedIterables.hasSameComparator(
            Ordering.natural().reverse(), Sets.newTreeSet(Ordering.natural().reverse())));
  }

  public void testComparator() {
    assertEquals(Ordering.natural(), SortedIterables.comparator(Sets.newTreeSet()));
  }

            

Reported by PMD.

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

Line: 36

                  }
    assertTrue(
        SortedIterables.hasSameComparator(
            Ordering.natural().reverse(), Sets.newTreeSet(Ordering.natural().reverse())));
  }

  public void testComparator() {
    assertEquals(Ordering.natural(), SortedIterables.comparator(Sets.newTreeSet()));
  }

            

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

                          Ordering.natural().reverse(), Sets.newTreeSet(Ordering.natural().reverse())));
  }

  public void testComparator() {
    assertEquals(Ordering.natural(), SortedIterables.comparator(Sets.newTreeSet()));
  }
}

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
11 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 50

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(SortedMapNavigationTester.class);
    return testers;
  }

  @Override
  public TestSuite createTestSuite() {

            

Reported by PMD.

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

Line: 56

              
  @Override
  public TestSuite createTestSuite() {
    if (!getFeatures().contains(KNOWN_ORDER)) {
      List<Feature<?>> features = Helpers.copyToList(getFeatures());
      features.add(KNOWN_ORDER);
      withFeatures(features);
    }
    return super.createTestSuite();

            

Reported by PMD.

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

Line: 58

                public TestSuite createTestSuite() {
    if (!getFeatures().contains(KNOWN_ORDER)) {
      List<Feature<?>> features = Helpers.copyToList(getFeatures());
      features.add(KNOWN_ORDER);
      withFeatures(features);
    }
    return super.createTestSuite();
  }


            

Reported by PMD.

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

Line: 71

                        parentBuilder) {
    List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);

    if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
    }


            

Reported by PMD.

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

Line: 114

                    final Bound from,
      final Bound to) {
    final TestSortedMapGenerator<K, V> delegate =
        (TestSortedMapGenerator<K, V>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());


            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 54

                        parentBuilder) {
    List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));

    if (!parentBuilder.getFeatures().contains(SUBSET_VIEW)) {
      // Other combinations are inherited from SortedSetTestSuiteBuilder.
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));

            

Reported by PMD.

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

Line: 62

                    derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
    }
    if (!parentBuilder.getFeatures().contains(DESCENDING_VIEW)) {
      derivedSuites.add(createDescendingSuite(parentBuilder));
    }
    return derivedSuites;
  }


            

Reported by PMD.

The method 'createSubSet(SortedSet, E, E)' has a cyclomatic complexity of 11.
Design

Line: 76

                  }

    @Override
    NavigableSet<E> createSubSet(SortedSet<E> sortedSet, E firstExclusive, E lastExclusive) {
      NavigableSet<E> set = (NavigableSet<E>) sortedSet;
      if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) {
        return set.headSet(lastInclusive, true);
      } else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) {
        return set.tailSet(firstExclusive, false);

            

Reported by PMD.

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

Line: 106

                            ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());


            

Reported by PMD.

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

Line: 138

                            @Override
              public Set<E> create(Object... elements) {
                NavigableSet<E> navigableSet = (NavigableSet<E>) delegate.create(elements);
                return navigableSet.descendingSet();
              }
            })
        .named(parentBuilder.getName() + " descending")
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())

            

Reported by PMD.

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

Line: 150

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(NavigableSetNavigationTester.class);
    return testers;
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '105'-'145').
Error

Line: 105

                    final FeatureSpecificTestSuiteBuilder<
              ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '105'-'145').
Error

Line: 105

                    final FeatureSpecificTestSuiteBuilder<
              ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '105'-'145').
Error

Line: 105

                    final FeatureSpecificTestSuiteBuilder<
              ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '105'-'145').
Error

Line: 105

                    final FeatureSpecificTestSuiteBuilder<
              ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/TablesTransformValuesTest.java
11 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: 53

                }

  // Null support depends on the underlying table and function.
  @GwtIncompatible // NullPointerTester
  @Override
  public void testNullPointerInstance() {}

  // put() and putAll() aren't supported.
  @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: 58

                public void testNullPointerInstance() {}

  // put() and putAll() aren't supported.
  @Override
  public void testPut() {
    try {
      table.put("foo", 1, 'a');
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException expected) {

            

Reported by PMD.

The String literal 'foo' appears 6 times in this file; the first occurrence is on line 61
Error

Line: 61

                @Override
  public void testPut() {
    try {
      table.put("foo", 1, 'a');
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException expected) {
    }
    assertSize(0);
  }

            

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

                  assertSize(0);
  }

  @Override
  public void testPutAllTable() {
    table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
    Table<String, Integer, Character> other = HashBasedTable.create();
    other.put("foo", 1, 'd');
    other.put("bar", 2, 'e');

            

Reported by PMD.

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

Line: 69

                }

  @Override
  public void testPutAllTable() {
    table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
    Table<String, Integer, Character> other = HashBasedTable.create();
    other.put("foo", 1, 'd');
    other.put("bar", 2, 'e');
    other.put("cat", 2, 'f');

            

Reported by PMD.

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

Line: 72

                public void testPutAllTable() {
    table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
    Table<String, Integer, Character> other = HashBasedTable.create();
    other.put("foo", 1, 'd');
    other.put("bar", 2, 'e');
    other.put("cat", 2, 'f');
    try {
      table.putAll(other);
      fail("Expected UnsupportedOperationException");

            

Reported by PMD.

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

Line: 73

                  table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
    Table<String, Integer, Character> other = HashBasedTable.create();
    other.put("foo", 1, 'd');
    other.put("bar", 2, 'e');
    other.put("cat", 2, 'f');
    try {
      table.putAll(other);
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException expected) {

            

Reported by PMD.

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

Line: 74

                  Table<String, Integer, Character> other = HashBasedTable.create();
    other.put("foo", 1, 'd');
    other.put("bar", 2, 'e');
    other.put("cat", 2, 'f');
    try {
      table.putAll(other);
      fail("Expected UnsupportedOperationException");
    } 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: 86

                  assertSize(3);
  }

  @Override
  public void testPutNull() {}

  @Override
  public void testPutNullReplace() {}


            

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

                @Override
  public void testPutNull() {}

  @Override
  public void testPutNullReplace() {}

  @Override
  public void testRowClearAndPut() {}
}

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/MapHashCodeTester.java
10 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

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapHashCodeTester<K, V> extends AbstractMapTester<K, V> {
  public void testHashCode() {
    int expectedHashCode = 0;
    for (Entry<K, V> entry : getSampleEntries()) {
      expectedHashCode += hash(entry);
    }
    assertEquals(

            

Reported by PMD.

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

Line: 47

                  assertEquals(
        "A Map's hashCode() should be the sum of those of its entries.",
        expectedHashCode,
        getMap().hashCode());
  }

  @CollectionSize.Require(absent = CollectionSize.ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testHashCode_containingNullKey() {

            

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

                      getMap().hashCode());
  }

  @CollectionSize.Require(absent = CollectionSize.ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testHashCode_containingNullKey() {
    Entry<K, V> entryWithNull = entry(null, v3());
    runEntryWithNullTest(entryWithNull);
  }

            

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

                  runEntryWithNullTest(entryWithNull);
  }

  @CollectionSize.Require(absent = CollectionSize.ZERO)
  @MapFeature.Require(ALLOWS_NULL_VALUES)
  public void testHashCode_containingNullValue() {
    Entry<K, V> entryWithNull = entry(k3(), null);
    runEntryWithNullTest(entryWithNull);
  }

            

Reported by PMD.

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

Line: 67

                private void runEntryWithNullTest(Entry<K, V> entryWithNull) {
    Collection<Entry<K, V>> entries = getSampleEntries(getNumEntries() - 1);

    entries.add(entryWithNull);

    int expectedHashCode = 0;
    for (Entry<K, V> entry : entries) {
      expectedHashCode += hash(entry);
    }

            

Reported by PMD.

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

Line: 74

                    expectedHashCode += hash(entry);
    }

    resetContainer(getSubjectGenerator().create(entries.toArray()));
    assertEquals(
        "A Map's hashCode() should be the sum of those of its entries (where "
            + "a null element in an entry counts as having a hash of zero).",
        expectedHashCode,
        getMap().hashCode());

            

Reported by PMD.

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

Line: 74

                    expectedHashCode += hash(entry);
    }

    resetContainer(getSubjectGenerator().create(entries.toArray()));
    assertEquals(
        "A Map's hashCode() should be the sum of those of its entries (where "
            + "a null element in an entry counts as having a hash of zero).",
        expectedHashCode,
        getMap().hashCode());

            

Reported by PMD.

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

Line: 79

                      "A Map's hashCode() should be the sum of those of its entries (where "
            + "a null element in an entry counts as having a hash of zero).",
        expectedHashCode,
        getMap().hashCode());
  }

  private static int hash(Entry<?, ?> e) {
    return (e.getKey() == null ? 0 : e.getKey().hashCode())
        ^ (e.getValue() == null ? 0 : e.getValue().hashCode());

            

Reported by PMD.

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

Line: 83

                }

  private static int hash(Entry<?, ?> e) {
    return (e.getKey() == null ? 0 : e.getKey().hashCode())
        ^ (e.getValue() == null ? 0 : e.getValue().hashCode());
  }
}

            

Reported by PMD.

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

Line: 84

              
  private static int hash(Entry<?, ?> e) {
    return (e.getKey() == null ? 0 : e.getKey().hashCode())
        ^ (e.getValue() == null ? 0 : e.getValue().hashCode());
  }
}

            

Reported by PMD.

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

Line: 78

                  abstract Appendable get(int sz);
  }

  @Param CopyStrategy strategy;
  @Param TargetSupplier target;

  @Param({"10", "1024", "1048576"})
  int size;


            

Reported by PMD.

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

Line: 79

                }

  @Param CopyStrategy strategy;
  @Param TargetSupplier target;

  @Param({"10", "1024", "1048576"})
  int size;

  String data;

            

Reported by PMD.

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

Line: 82

                @Param TargetSupplier target;

  @Param({"10", "1024", "1048576"})
  int size;

  String data;

  @BeforeExperiment
  public void setUp() {

            

Reported by PMD.

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

Line: 84

                @Param({"10", "1024", "1048576"})
  int size;

  String data;

  @BeforeExperiment
  public void setUp() {
    // precalculate some random strings of ascii characters.
    StringBuilder sb = new StringBuilder();

            

Reported by PMD.

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

Line: 86

              
  String data;

  @BeforeExperiment
  public void setUp() {
    // precalculate some random strings of ascii characters.
    StringBuilder sb = new StringBuilder();
    Random random = new Random(0xdeadbeef); // for unpredictable but reproducible behavior
    sb.ensureCapacity(size);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 107

                  final CopyStrategy localStrategy = strategy;
    for (int i = 0; i < reps; i++) {
      Appendable appendable = localTarget.get(localData.length());
      r += localStrategy.copy(new StringReader(localData), appendable);
    }
    return r;
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'random' (lines '90'-'97').
Error

Line: 90

                public void setUp() {
    // precalculate some random strings of ascii characters.
    StringBuilder sb = new StringBuilder();
    Random random = new Random(0xdeadbeef); // for unpredictable but reproducible behavior
    sb.ensureCapacity(size);
    for (int k = 0; k < size; k++) {
      // [9-127) includes all ascii non-control characters
      sb.append((char) (random.nextInt(127 - 9) + 9));
    }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'localData' (lines '102'-'110').
Error

Line: 102

                @Benchmark
  public long timeCopy(int reps) throws IOException {
    long r = 0;
    final String localData = data;
    final TargetSupplier localTarget = target;
    final CopyStrategy localStrategy = strategy;
    for (int i = 0; i < reps; i++) {
      Appendable appendable = localTarget.get(localData.length());
      r += localStrategy.copy(new StringReader(localData), appendable);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'localTarget' (lines '103'-'110').
Error

Line: 103

                public long timeCopy(int reps) throws IOException {
    long r = 0;
    final String localData = data;
    final TargetSupplier localTarget = target;
    final CopyStrategy localStrategy = strategy;
    for (int i = 0; i < reps; i++) {
      Appendable appendable = localTarget.get(localData.length());
      r += localStrategy.copy(new StringReader(localData), appendable);
    }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'localStrategy' (lines '104'-'110').
Error

Line: 104

                  long r = 0;
    final String localData = data;
    final TargetSupplier localTarget = target;
    final CopyStrategy localStrategy = strategy;
    for (int i = 0; i < reps; i++) {
      Appendable appendable = localTarget.get(localData.length());
      r += localStrategy.copy(new StringReader(localData), appendable);
    }
    return r;

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java
10 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: 32

               */
public class StandardSystemPropertyTest extends TestCase {

  public void testGetKeyMatchesString() {
    for (StandardSystemProperty property : StandardSystemProperty.values()) {
      String fieldName = property.name();
      String expected = Ascii.toLowerCase(fieldName).replaceAll("_", ".");
      assertEquals(expected, property.key());
    }

            

Reported by PMD.

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

Line: 35

                public void testGetKeyMatchesString() {
    for (StandardSystemProperty property : StandardSystemProperty.values()) {
      String fieldName = property.name();
      String expected = Ascii.toLowerCase(fieldName).replaceAll("_", ".");
      assertEquals(expected, property.key());
    }
  }

  public void testGetValue() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

                  for (StandardSystemProperty property : StandardSystemProperty.values()) {
      String fieldName = property.name();
      String expected = Ascii.toLowerCase(fieldName).replaceAll("_", ".");
      assertEquals(expected, property.key());
    }
  }

  public void testGetValue() {
    for (StandardSystemProperty property : StandardSystemProperty.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: 40

                  }
  }

  public void testGetValue() {
    for (StandardSystemProperty property : StandardSystemProperty.values()) {
      assertEquals(System.getProperty(property.key()), property.value());
    }
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

              
  public void testGetValue() {
    for (StandardSystemProperty property : StandardSystemProperty.values()) {
      assertEquals(System.getProperty(property.key()), property.value());
    }
  }

  public void testToString() {
    for (StandardSystemProperty property : StandardSystemProperty.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: 46

                  }
  }

  public void testToString() {
    for (StandardSystemProperty property : StandardSystemProperty.values()) {
      assertEquals(property.key() + "=" + property.value(), property.toString());
    }
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 48

              
  public void testToString() {
    for (StandardSystemProperty property : StandardSystemProperty.values()) {
      assertEquals(property.key() + "=" + property.value(), property.toString());
    }
  }

  public void testNoNullValues() {
    for (StandardSystemProperty property : StandardSystemProperty.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: 52

                  }
  }

  public void testNoNullValues() {
    for (StandardSystemProperty property : StandardSystemProperty.values()) {
      // Even though the contract in System.getProperties() specifies that a value will exist for
      // all of the listed keys, for some reason the "java.compiler" key returns null in some JVMs.
      if (property == JAVA_COMPILER) {
        continue;

            

Reported by PMD.

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

Line: 64

                    if (property == JAVA_EXT_DIRS) {
        continue;
      }
      assertWithMessage(property.toString()).that(property.value()).isNotNull();
    }
  }
}

            

Reported by PMD.

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

Line: 64

                    if (property == JAVA_EXT_DIRS) {
        continue;
      }
      assertWithMessage(property.toString()).that(property.value()).isNotNull();
    }
  }
}

            

Reported by PMD.