The following issues were found

guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java
24 issues
High amount of different objects as members denotes a high coupling
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect.testing;

import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;


            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect.testing;

import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;


            

Reported by PMD.

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

Line: 71

                protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());

    testers.add(CollectionSerializationEqualTester.class);
    testers.add(ListAddAllAtIndexTester.class);
    testers.add(ListAddAllTester.class);
    testers.add(ListAddAtIndexTester.class);
    testers.add(ListAddTester.class);
    testers.add(ListCreationTester.class);

            

Reported by PMD.

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

Line: 72

                  List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());

    testers.add(CollectionSerializationEqualTester.class);
    testers.add(ListAddAllAtIndexTester.class);
    testers.add(ListAddAllTester.class);
    testers.add(ListAddAtIndexTester.class);
    testers.add(ListAddTester.class);
    testers.add(ListCreationTester.class);
    testers.add(ListEqualsTester.class);

            

Reported by PMD.

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

Line: 73

              
    testers.add(CollectionSerializationEqualTester.class);
    testers.add(ListAddAllAtIndexTester.class);
    testers.add(ListAddAllTester.class);
    testers.add(ListAddAtIndexTester.class);
    testers.add(ListAddTester.class);
    testers.add(ListCreationTester.class);
    testers.add(ListEqualsTester.class);
    testers.add(ListGetTester.class);

            

Reported by PMD.

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

Line: 74

                  testers.add(CollectionSerializationEqualTester.class);
    testers.add(ListAddAllAtIndexTester.class);
    testers.add(ListAddAllTester.class);
    testers.add(ListAddAtIndexTester.class);
    testers.add(ListAddTester.class);
    testers.add(ListCreationTester.class);
    testers.add(ListEqualsTester.class);
    testers.add(ListGetTester.class);
    testers.add(ListHashCodeTester.class);

            

Reported by PMD.

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

Line: 75

                  testers.add(ListAddAllAtIndexTester.class);
    testers.add(ListAddAllTester.class);
    testers.add(ListAddAtIndexTester.class);
    testers.add(ListAddTester.class);
    testers.add(ListCreationTester.class);
    testers.add(ListEqualsTester.class);
    testers.add(ListGetTester.class);
    testers.add(ListHashCodeTester.class);
    testers.add(ListIndexOfTester.class);

            

Reported by PMD.

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

Line: 76

                  testers.add(ListAddAllTester.class);
    testers.add(ListAddAtIndexTester.class);
    testers.add(ListAddTester.class);
    testers.add(ListCreationTester.class);
    testers.add(ListEqualsTester.class);
    testers.add(ListGetTester.class);
    testers.add(ListHashCodeTester.class);
    testers.add(ListIndexOfTester.class);
    testers.add(ListLastIndexOfTester.class);

            

Reported by PMD.

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

Line: 77

                  testers.add(ListAddAtIndexTester.class);
    testers.add(ListAddTester.class);
    testers.add(ListCreationTester.class);
    testers.add(ListEqualsTester.class);
    testers.add(ListGetTester.class);
    testers.add(ListHashCodeTester.class);
    testers.add(ListIndexOfTester.class);
    testers.add(ListLastIndexOfTester.class);
    testers.add(ListListIteratorTester.class);

            

Reported by PMD.

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

Line: 78

                  testers.add(ListAddTester.class);
    testers.add(ListCreationTester.class);
    testers.add(ListEqualsTester.class);
    testers.add(ListGetTester.class);
    testers.add(ListHashCodeTester.class);
    testers.add(ListIndexOfTester.class);
    testers.add(ListLastIndexOfTester.class);
    testers.add(ListListIteratorTester.class);
    testers.add(ListRemoveAllTester.class);

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultimapKeySetTester.java
24 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 MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testKeySet() {
    for (Entry<K, V> entry : getSampleElements()) {
      assertTrue(multimap().keySet().contains(entry.getKey()));
    }
  }


            

Reported by PMD.

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

Line: 42

              public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testKeySet() {
    for (Entry<K, V> entry : getSampleElements()) {
      assertTrue(multimap().keySet().contains(entry.getKey()));
    }
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)

            

Reported by PMD.

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

Line: 42

              public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testKeySet() {
    for (Entry<K, V> entry : getSampleElements()) {
      assertTrue(multimap().keySet().contains(entry.getKey()));
    }
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)

            

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

                  }
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testKeySetContainsNullKeyPresent() {
    initMultimapWithNullKey();
    assertTrue(multimap().keySet().contains(null));
  }

            

Reported by PMD.

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

Line: 50

                @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testKeySetContainsNullKeyPresent() {
    initMultimapWithNullKey();
    assertTrue(multimap().keySet().contains(null));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().contains(null));

            

Reported by PMD.

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

Line: 50

                @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testKeySetContainsNullKeyPresent() {
    initMultimapWithNullKey();
    assertTrue(multimap().keySet().contains(null));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().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: 53

                  assertTrue(multimap().keySet().contains(null));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().contains(null));
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 55

              
  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().contains(null));
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetRemovePropagatesToMultimap() {
    int key0Count = multimap().get(k0()).size();

            

Reported by PMD.

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

Line: 55

              
  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().contains(null));
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetRemovePropagatesToMultimap() {
    int key0Count = multimap().get(k0()).size();

            

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

                  assertFalse(multimap().keySet().contains(null));
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetRemovePropagatesToMultimap() {
    int key0Count = multimap().get(k0()).size();
    assertEquals(key0Count > 0, multimap().keySet().remove(k0()));
    assertEquals(getNumElements() - key0Count, multimap().size());
    assertGet(k0());

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/ListMultimapRemoveTester.java
24 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: 41

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapRemoveTester<K, V> extends AbstractListMultimapTester<K, V> {
  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(SEVERAL)
  public void testMultimapRemoveDeletesFirstOccurrence() {
    resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));


            

Reported by PMD.

The String literal 'unchecked' appears 4 times in this file; the first occurrence is on line 41
Error

Line: 41

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapRemoveTester<K, V> extends AbstractListMultimapTester<K, V> {
  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(SEVERAL)
  public void testMultimapRemoveDeletesFirstOccurrence() {
    resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));


            

Reported by PMD.

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

Line: 47

                public void testMultimapRemoveDeletesFirstOccurrence() {
    resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));

    List<V> list = multimap().get(k0());
    multimap().remove(k0(), v0());
    assertContentsInOrder(list, v1(), v0());
  }

  @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 48

                  resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));

    List<V> list = multimap().get(k0());
    multimap().remove(k0(), v0());
    assertContentsInOrder(list, v1(), v0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  assertContentsInOrder(list, v1(), v0());
  }

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


            

Reported by PMD.

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

Line: 62

                    resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
      List<V> expectedValues = copyToList(values);

      multimap().get(k0()).remove(i);
      expectedValues.remove(i);

      assertGet(k0(), expectedValues);
    }
  }

            

Reported by PMD.

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

Line: 62

                    resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
      List<V> expectedValues = copyToList(values);

      multimap().get(k0()).remove(i);
      expectedValues.remove(i);

      assertGet(k0(), expectedValues);
    }
  }

            

Reported by PMD.

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

Line: 63

                    List<V> expectedValues = copyToList(values);

      multimap().get(k0()).remove(i);
      expectedValues.remove(i);

      assertGet(k0(), 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: 69

                  }
  }

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


            

Reported by PMD.

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

Line: 79

                    resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
      List<V> expectedValues = copyToList(values);

      List<V> asMapValue = (List<V>) multimap().asMap().get(k0());
      asMapValue.remove(i);
      expectedValues.remove(i);

      assertGet(k0(), expectedValues);
    }

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/MultimapKeySetTester.java
24 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 MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testKeySet() {
    for (Entry<K, V> entry : getSampleElements()) {
      assertTrue(multimap().keySet().contains(entry.getKey()));
    }
  }


            

Reported by PMD.

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

Line: 42

              public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testKeySet() {
    for (Entry<K, V> entry : getSampleElements()) {
      assertTrue(multimap().keySet().contains(entry.getKey()));
    }
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)

            

Reported by PMD.

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

Line: 42

              public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testKeySet() {
    for (Entry<K, V> entry : getSampleElements()) {
      assertTrue(multimap().keySet().contains(entry.getKey()));
    }
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)

            

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

                  }
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testKeySetContainsNullKeyPresent() {
    initMultimapWithNullKey();
    assertTrue(multimap().keySet().contains(null));
  }

            

Reported by PMD.

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

Line: 50

                @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testKeySetContainsNullKeyPresent() {
    initMultimapWithNullKey();
    assertTrue(multimap().keySet().contains(null));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().contains(null));

            

Reported by PMD.

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

Line: 50

                @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testKeySetContainsNullKeyPresent() {
    initMultimapWithNullKey();
    assertTrue(multimap().keySet().contains(null));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().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: 53

                  assertTrue(multimap().keySet().contains(null));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().contains(null));
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 55

              
  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().contains(null));
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetRemovePropagatesToMultimap() {
    int key0Count = multimap().get(k0()).size();

            

Reported by PMD.

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

Line: 55

              
  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testKeySetContainsNullKeyAbsent() {
    assertFalse(multimap().keySet().contains(null));
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetRemovePropagatesToMultimap() {
    int key0Count = multimap().get(k0()).size();

            

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

                  assertFalse(multimap().keySet().contains(null));
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetRemovePropagatesToMultimap() {
    int key0Count = multimap().get(k0()).size();
    assertEquals(key0Count > 0, multimap().keySet().remove(k0()));
    assertEquals(getNumElements() - key0Count, multimap().size());
    assertGet(k0());

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/ListSetTester.java
24 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: 41

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListSetTester<E> extends AbstractListTester<E> {
  @ListFeature.Require(SUPPORTS_SET)
  @CollectionSize.Require(absent = ZERO)
  public void testSet() {
    doTestSet(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: 47

                  doTestSet(e3());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @ListFeature.Require(SUPPORTS_SET)
  public void testSet_null() {
    doTestSet(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: 54

                  doTestSet(null);
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @ListFeature.Require(SUPPORTS_SET)
  public void testSet_replacingNull() {
    E[] elements = createSamplesArray();
    int i = aValidIndex();

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 60

                public void testSet_replacingNull() {
    E[] elements = createSamplesArray();
    int i = aValidIndex();
    elements[i] = null;
    collection = getSubjectGenerator().create(elements);

    doTestSet(e3());
  }


            

Reported by PMD.

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

Line: 61

                  E[] elements = createSamplesArray();
    int i = aValidIndex();
    elements[i] = null;
    collection = getSubjectGenerator().create(elements);

    doTestSet(e3());
  }

  private void doTestSet(E newValue) {

            

Reported by PMD.

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

Line: 68

              
  private void doTestSet(E newValue) {
    int index = aValidIndex();
    E initialValue = getList().get(index);
    assertEquals(
        "set(i, x) should return the old element at position i.",
        initialValue,
        getList().set(index, newValue));
    assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index));

            

Reported by PMD.

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

Line: 72

                  assertEquals(
        "set(i, x) should return the old element at position i.",
        initialValue,
        getList().set(index, newValue));
    assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index));
    assertEquals("set() should not change the size of a list.", getNumElements(), getList().size());
  }

  @ListFeature.Require(SUPPORTS_SET)

            

Reported by PMD.

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

Line: 73

                      "set(i, x) should return the old element at position i.",
        initialValue,
        getList().set(index, newValue));
    assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index));
    assertEquals("set() should not change the size of a list.", getNumElements(), getList().size());
  }

  @ListFeature.Require(SUPPORTS_SET)
  public void testSet_indexTooLow() {

            

Reported by PMD.

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

Line: 74

                      initialValue,
        getList().set(index, newValue));
    assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index));
    assertEquals("set() should not change the size of a list.", getNumElements(), getList().size());
  }

  @ListFeature.Require(SUPPORTS_SET)
  public void testSet_indexTooLow() {
    try {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 77

                  assertEquals("set() should not change the size of a list.", getNumElements(), getList().size());
  }

  @ListFeature.Require(SUPPORTS_SET)
  public void testSet_indexTooLow() {
    try {
      getList().set(-1, e3());
      fail("set(-1) should throw IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException expected) {

            

Reported by PMD.

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

Line: 40

                @Override
  protected Map<String, Collection<Integer>> makeEmptyMap() {
    Map<String, Integer> map = Maps.newHashMap();
    return Multimaps.forMap(map).asMap();
  }

  @Override
  protected Map<String, Collection<Integer>> makePopulatedMap() {
    Map<String, Integer> map = Maps.newHashMap();

            

Reported by PMD.

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

Line: 46

                @Override
  protected Map<String, Collection<Integer>> makePopulatedMap() {
    Map<String, Integer> map = Maps.newHashMap();
    map.put("foo", 1);
    map.put("bar", 2);
    map.put("cow", 3);
    return Multimaps.forMap(map).asMap();
  }


            

Reported by PMD.

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

Line: 47

                protected Map<String, Collection<Integer>> makePopulatedMap() {
    Map<String, Integer> map = Maps.newHashMap();
    map.put("foo", 1);
    map.put("bar", 2);
    map.put("cow", 3);
    return Multimaps.forMap(map).asMap();
  }

  @Override

            

Reported by PMD.

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

Line: 48

                  Map<String, Integer> map = Maps.newHashMap();
    map.put("foo", 1);
    map.put("bar", 2);
    map.put("cow", 3);
    return Multimaps.forMap(map).asMap();
  }

  @Override
  public void testEntrySetRemoveAllNullFromEmpty() {

            

Reported by PMD.

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

Line: 49

                  map.put("foo", 1);
    map.put("bar", 2);
    map.put("cow", 3);
    return Multimaps.forMap(map).asMap();
  }

  @Override
  public void testEntrySetRemoveAllNullFromEmpty() {
    try {

            

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

                  return Multimaps.forMap(map).asMap();
  }

  @Override
  public void testEntrySetRemoveAllNullFromEmpty() {
    try {
      super.testEntrySetRemoveAllNullFromEmpty();
    } catch (RuntimeException tolerated) {
      // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 56

                public void testEntrySetRemoveAllNullFromEmpty() {
    try {
      super.testEntrySetRemoveAllNullFromEmpty();
    } catch (RuntimeException tolerated) {
      // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
    }
  }

  @Override

            

Reported by PMD.

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

Line: 56

                public void testEntrySetRemoveAllNullFromEmpty() {
    try {
      super.testEntrySetRemoveAllNullFromEmpty();
    } catch (RuntimeException tolerated) {
      // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
    }
  }

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

                  }
  }

  @Override
  public void testEntrySetRetainAllNullFromEmpty() {
    try {
      super.testEntrySetRetainAllNullFromEmpty();
    } catch (RuntimeException tolerated) {
      // GWT's HashMap.entrySet().retainAll(null) doesn't throws NPE.

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 65

                public void testEntrySetRetainAllNullFromEmpty() {
    try {
      super.testEntrySetRetainAllNullFromEmpty();
    } catch (RuntimeException tolerated) {
      // GWT's HashMap.entrySet().retainAll(null) doesn't throws NPE.
    }
  }

  @Override

            

Reported by PMD.

guava/src/com/google/common/primitives/ImmutableDoubleArray.java
24 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.primitives;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.Beta;

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
  private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);

  /** Returns the empty array. */
  public static ImmutableDoubleArray of() {
    return EMPTY;

            

Reported by PMD.

Possible God Class (WMC=56, ATFD=14, TCC=20.499%)
Design

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
  private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);

  /** Returns the empty array. */
  public static ImmutableDoubleArray of() {
    return EMPTY;

            

Reported by PMD.

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

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
  private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);

  /** Returns the empty array. */
  public static ImmutableDoubleArray of() {
    return EMPTY;

            

Reported by PMD.

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

Line: 172

                  if (values instanceof Collection) {
      return copyOf((Collection<Double>) values);
    }
    return builder().addAll(values).build();
  }

  /** Returns an immutable array containing all the values from {@code stream}, in order. */
  public static ImmutableDoubleArray copyOf(DoubleStream stream) {
    // Note this uses very different growth behavior from copyOf(Iterable) and the builder.

            

Reported by PMD.

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

Line: 172

                  if (values instanceof Collection) {
      return copyOf((Collection<Double>) values);
    }
    return builder().addAll(values).build();
  }

  /** Returns an immutable array containing all the values from {@code stream}, in order. */
  public static ImmutableDoubleArray copyOf(DoubleStream stream) {
    // Note this uses very different growth behavior from copyOf(Iterable) and the builder.

            

Reported by PMD.

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

Line: 215

                 */
  @CanIgnoreReturnValue
  public static final class Builder {
    private double[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new double[initialCapacity];
    }

            

Reported by PMD.

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

Line: 216

                @CanIgnoreReturnValue
  public static final class Builder {
    private double[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new double[initialCapacity];
    }


            

Reported by PMD.

Avoid using redundant field initializer for 'count'
Performance

Line: 216

                @CanIgnoreReturnValue
  public static final class Builder {
    private double[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new double[initialCapacity];
    }


            

Reported by PMD.

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

Line: 276

                   */
    public Builder addAll(DoubleStream stream) {
      Spliterator.OfDouble spliterator = stream.spliterator();
      long size = spliterator.getExactSizeIfKnown();
      if (size > 0) { // known *and* nonempty
        ensureRoomFor(Ints.saturatedCast(size));
      }
      spliterator.forEachRemaining((DoubleConsumer) this::add);
      return this;

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/PrimitivesTest.java
24 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 30

               * @author Kevin Bourrillion
 */
public class PrimitivesTest extends TestCase {
  public void testIsWrapperType() {
    assertTrue(Primitives.isWrapperType(Void.class));
    assertFalse(Primitives.isWrapperType(void.class));
  }

  public void testWrap() {

            

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

               * @author Kevin Bourrillion
 */
public class PrimitivesTest extends TestCase {
  public void testIsWrapperType() {
    assertTrue(Primitives.isWrapperType(Void.class));
    assertFalse(Primitives.isWrapperType(void.class));
  }

  public void testWrap() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

               */
public class PrimitivesTest extends TestCase {
  public void testIsWrapperType() {
    assertTrue(Primitives.isWrapperType(Void.class));
    assertFalse(Primitives.isWrapperType(void.class));
  }

  public void testWrap() {
    assertSame(Integer.class, Primitives.wrap(int.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

              public class PrimitivesTest extends TestCase {
  public void testIsWrapperType() {
    assertTrue(Primitives.isWrapperType(Void.class));
    assertFalse(Primitives.isWrapperType(void.class));
  }

  public void testWrap() {
    assertSame(Integer.class, Primitives.wrap(int.class));
    assertSame(Integer.class, Primitives.wrap(Integer.class));

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 35

                  assertFalse(Primitives.isWrapperType(void.class));
  }

  public void testWrap() {
    assertSame(Integer.class, Primitives.wrap(int.class));
    assertSame(Integer.class, Primitives.wrap(Integer.class));
    assertSame(String.class, Primitives.wrap(String.class));
  }


            

Reported by PMD.

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

Line: 35

                  assertFalse(Primitives.isWrapperType(void.class));
  }

  public void testWrap() {
    assertSame(Integer.class, Primitives.wrap(int.class));
    assertSame(Integer.class, Primitives.wrap(Integer.class));
    assertSame(String.class, Primitives.wrap(String.class));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

                }

  public void testWrap() {
    assertSame(Integer.class, Primitives.wrap(int.class));
    assertSame(Integer.class, Primitives.wrap(Integer.class));
    assertSame(String.class, Primitives.wrap(String.class));
  }

  public void testUnwrap() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

              
  public void testWrap() {
    assertSame(Integer.class, Primitives.wrap(int.class));
    assertSame(Integer.class, Primitives.wrap(Integer.class));
    assertSame(String.class, Primitives.wrap(String.class));
  }

  public void testUnwrap() {
    assertSame(int.class, Primitives.unwrap(Integer.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 38

                public void testWrap() {
    assertSame(Integer.class, Primitives.wrap(int.class));
    assertSame(Integer.class, Primitives.wrap(Integer.class));
    assertSame(String.class, Primitives.wrap(String.class));
  }

  public void testUnwrap() {
    assertSame(int.class, Primitives.unwrap(Integer.class));
    assertSame(int.class, Primitives.unwrap(int.class));

            

Reported by PMD.

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

Line: 41

                  assertSame(String.class, Primitives.wrap(String.class));
  }

  public void testUnwrap() {
    assertSame(int.class, Primitives.unwrap(Integer.class));
    assertSame(int.class, Primitives.unwrap(int.class));
    assertSame(String.class, Primitives.unwrap(String.class));
  }


            

Reported by PMD.

guava/src/com/google/common/primitives/ImmutableIntArray.java
24 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.primitives;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.Beta;

            

Reported by PMD.

Possible God Class (WMC=55, ATFD=14, TCC=21.780%)
Design

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
  private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);

  /** Returns the empty array. */
  public static ImmutableIntArray of() {
    return EMPTY;

            

Reported by PMD.

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

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
  private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);

  /** Returns the empty array. */
  public static ImmutableIntArray of() {
    return EMPTY;

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
  private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);

  /** Returns the empty array. */
  public static ImmutableIntArray of() {
    return EMPTY;

            

Reported by PMD.

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

Line: 169

                  if (values instanceof Collection) {
      return copyOf((Collection<Integer>) values);
    }
    return builder().addAll(values).build();
  }

  /** Returns an immutable array containing all the values from {@code stream}, in order. */
  public static ImmutableIntArray copyOf(IntStream stream) {
    // Note this uses very different growth behavior from copyOf(Iterable) and the builder.

            

Reported by PMD.

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

Line: 169

                  if (values instanceof Collection) {
      return copyOf((Collection<Integer>) values);
    }
    return builder().addAll(values).build();
  }

  /** Returns an immutable array containing all the values from {@code stream}, in order. */
  public static ImmutableIntArray copyOf(IntStream stream) {
    // Note this uses very different growth behavior from copyOf(Iterable) and the builder.

            

Reported by PMD.

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

Line: 212

                 */
  @CanIgnoreReturnValue
  public static final class Builder {
    private int[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new int[initialCapacity];
    }

            

Reported by PMD.

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

Line: 213

                @CanIgnoreReturnValue
  public static final class Builder {
    private int[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new int[initialCapacity];
    }


            

Reported by PMD.

Avoid using redundant field initializer for 'count'
Performance

Line: 213

                @CanIgnoreReturnValue
  public static final class Builder {
    private int[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new int[initialCapacity];
    }


            

Reported by PMD.

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

Line: 273

                   */
    public Builder addAll(IntStream stream) {
      Spliterator.OfInt spliterator = stream.spliterator();
      long size = spliterator.getExactSizeIfKnown();
      if (size > 0) { // known *and* nonempty
        ensureRoomFor(Ints.saturatedCast(size));
      }
      spliterator.forEachRemaining((IntConsumer) this::add);
      return this;

            

Reported by PMD.

guava/src/com/google/common/primitives/ImmutableLongArray.java
24 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.primitives;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.Beta;

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
  private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);

  /** Returns the empty array. */
  public static ImmutableLongArray of() {
    return EMPTY;

            

Reported by PMD.

Possible God Class (WMC=55, ATFD=14, TCC=21.780%)
Design

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
  private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);

  /** Returns the empty array. */
  public static ImmutableLongArray of() {
    return EMPTY;

            

Reported by PMD.

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

Line: 92

              @GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
  private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);

  /** Returns the empty array. */
  public static ImmutableLongArray of() {
    return EMPTY;

            

Reported by PMD.

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

Line: 171

                  if (values instanceof Collection) {
      return copyOf((Collection<Long>) values);
    }
    return builder().addAll(values).build();
  }

  /** Returns an immutable array containing all the values from {@code stream}, in order. */
  public static ImmutableLongArray copyOf(LongStream stream) {
    // Note this uses very different growth behavior from copyOf(Iterable) and the builder.

            

Reported by PMD.

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

Line: 171

                  if (values instanceof Collection) {
      return copyOf((Collection<Long>) values);
    }
    return builder().addAll(values).build();
  }

  /** Returns an immutable array containing all the values from {@code stream}, in order. */
  public static ImmutableLongArray copyOf(LongStream stream) {
    // Note this uses very different growth behavior from copyOf(Iterable) and the builder.

            

Reported by PMD.

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

Line: 214

                 */
  @CanIgnoreReturnValue
  public static final class Builder {
    private long[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new long[initialCapacity];
    }

            

Reported by PMD.

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

Line: 215

                @CanIgnoreReturnValue
  public static final class Builder {
    private long[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new long[initialCapacity];
    }


            

Reported by PMD.

Avoid using redundant field initializer for 'count'
Performance

Line: 215

                @CanIgnoreReturnValue
  public static final class Builder {
    private long[] array;
    private int count = 0; // <= array.length

    Builder(int initialCapacity) {
      array = new long[initialCapacity];
    }


            

Reported by PMD.

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

Line: 275

                   */
    public Builder addAll(LongStream stream) {
      Spliterator.OfLong spliterator = stream.spliterator();
      long size = spliterator.getExactSizeIfKnown();
      if (size > 0) { // known *and* nonempty
        ensureRoomFor(Ints.saturatedCast(size));
      }
      spliterator.forEachRemaining((LongConsumer) this::add);
      return this;

            

Reported by PMD.