The following issues were found

android/guava-testlib/src/com/google/common/collect/testing/testers/ListRemoveTester.java
9 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 37

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListRemoveTester<E> extends AbstractListTester<E> {
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = {ZERO, ONE})
  public void testRemove_duplicate() {
    ArrayWithDuplicate<E> arrayAndDuplicate = createArrayWithDuplicateElement();
    collection = getSubjectGenerator().create(arrayAndDuplicate.elements);
    E duplicate = arrayAndDuplicate.duplicate;

            

Reported by PMD.

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

Line: 39

              public class ListRemoveTester<E> extends AbstractListTester<E> {
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = {ZERO, ONE})
  public void testRemove_duplicate() {
    ArrayWithDuplicate<E> arrayAndDuplicate = createArrayWithDuplicateElement();
    collection = getSubjectGenerator().create(arrayAndDuplicate.elements);
    E duplicate = arrayAndDuplicate.duplicate;

    int firstIndex = getList().indexOf(duplicate);

            

Reported by PMD.

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

Line: 41

                @CollectionSize.Require(absent = {ZERO, ONE})
  public void testRemove_duplicate() {
    ArrayWithDuplicate<E> arrayAndDuplicate = createArrayWithDuplicateElement();
    collection = getSubjectGenerator().create(arrayAndDuplicate.elements);
    E duplicate = arrayAndDuplicate.duplicate;

    int firstIndex = getList().indexOf(duplicate);
    int initialSize = getList().size();
    assertTrue("remove(present) should return true", getList().remove(duplicate));

            

Reported by PMD.

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

Line: 44

                  collection = getSubjectGenerator().create(arrayAndDuplicate.elements);
    E duplicate = arrayAndDuplicate.duplicate;

    int firstIndex = getList().indexOf(duplicate);
    int initialSize = getList().size();
    assertTrue("remove(present) should return true", getList().remove(duplicate));
    assertTrue(
        "After remove(duplicate), a list should still contain the duplicate element",
        getList().contains(duplicate));

            

Reported by PMD.

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

Line: 45

                  E duplicate = arrayAndDuplicate.duplicate;

    int firstIndex = getList().indexOf(duplicate);
    int initialSize = getList().size();
    assertTrue("remove(present) should return true", getList().remove(duplicate));
    assertTrue(
        "After remove(duplicate), a list should still contain the duplicate element",
        getList().contains(duplicate));
    assertFalse(

            

Reported by PMD.

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

Line: 46

              
    int firstIndex = getList().indexOf(duplicate);
    int initialSize = getList().size();
    assertTrue("remove(present) should return true", getList().remove(duplicate));
    assertTrue(
        "After remove(duplicate), a list should still contain the duplicate element",
        getList().contains(duplicate));
    assertFalse(
        "remove(duplicate) should remove the first instance of the "

            

Reported by PMD.

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

Line: 49

                  assertTrue("remove(present) should return true", getList().remove(duplicate));
    assertTrue(
        "After remove(duplicate), a list should still contain the duplicate element",
        getList().contains(duplicate));
    assertFalse(
        "remove(duplicate) should remove the first instance of the "
            + "duplicate element in the list",
        firstIndex == getList().indexOf(duplicate));
    assertEquals(

            

Reported by PMD.

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

Line: 53

                  assertFalse(
        "remove(duplicate) should remove the first instance of the "
            + "duplicate element in the list",
        firstIndex == getList().indexOf(duplicate));
    assertEquals(
        "remove(present) should decrease the size of a list by one.",
        initialSize - 1,
        getList().size());
  }

            

Reported by PMD.

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

Line: 57

                  assertEquals(
        "remove(present) should decrease the size of a list by one.",
        initialSize - 1,
        getList().size());
  }
}

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/ListListIteratorTester.java
9 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: 51

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListListIteratorTester<E> extends AbstractListTester<E> {
  @CollectionFeature.Require(absent = SUPPORTS_REMOVE)
  @ListFeature.Require(absent = {SUPPORTS_SET, SUPPORTS_ADD_WITH_INDEX})
  public void testListIterator_unmodifiable() {
    runListIteratorTest(UNMODIFIABLE);
  }


            

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

                 * For now, we don't cope with testing this when the list supports only some
   * modification operations.
   */
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  @ListFeature.Require({SUPPORTS_SET, SUPPORTS_ADD_WITH_INDEX})
  public void testListIterator_fullyModifiable() {
    runListIteratorTest(MODIFIABLE);
  }


            

Reported by PMD.

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

Line: 77

                    @Override
      protected ListIterator<E> newTargetIterator() {
        resetCollection();
        return getList().listIterator();
      }

      @Override
      protected void verify(List<E> elements) {
        expectContents(elements);

            

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

                  }.test();
  }

  public void testListIterator_tooLow() {
    try {
      getList().listIterator(-1);
      fail();
    } catch (IndexOutOfBoundsException expected) {
    }

            

Reported by PMD.

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

Line: 89

              
  public void testListIterator_tooLow() {
    try {
      getList().listIterator(-1);
      fail();
    } catch (IndexOutOfBoundsException 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: 95

                  }
  }

  public void testListIterator_tooHigh() {
    try {
      getList().listIterator(getNumElements() + 1);
      fail();
    } catch (IndexOutOfBoundsException expected) {
    }

            

Reported by PMD.

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

Line: 97

              
  public void testListIterator_tooHigh() {
    try {
      getList().listIterator(getNumElements() + 1);
      fail();
    } catch (IndexOutOfBoundsException 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: 103

                  }
  }

  public void testListIterator_atSize() {
    getList().listIterator(getNumElements());
    // TODO: run the iterator through ListIteratorTester
  }

  /**

            

Reported by PMD.

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

Line: 104

                }

  public void testListIterator_atSize() {
    getList().listIterator(getNumElements());
    // TODO: run the iterator through ListIteratorTester
  }

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

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java
9 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: 47

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionAddTester<E> extends AbstractCollectionTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  public void testAdd_supportedNotPresent() {
    assertTrue("add(notPresent) should return true", collection.add(e3()));
    expectAdded(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: 53

                  expectAdded(e3());
  }

  @CollectionFeature.Require(absent = SUPPORTS_ADD)
  public void testAdd_unsupportedNotPresent() {
    try {
      collection.add(e3());
      fail("add(notPresent) should throw");
    } catch (UnsupportedOperationException expected) {

            

Reported by PMD.

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

Line: 64

                  expectMissing(e3());
  }

  @CollectionFeature.Require(absent = SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)
  public void testAdd_unsupportedPresent() {
    try {
      assertFalse("add(present) should return false or throw", collection.add(e0()));
    } catch (UnsupportedOperationException tolerated) {

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 69

                public void testAdd_unsupportedPresent() {
    try {
      assertFalse("add(present) should return false or throw", collection.add(e0()));
    } catch (UnsupportedOperationException tolerated) {
    }
    expectUnchanged();
  }

  @CollectionFeature.Require(

            

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

                  expectUnchanged();
  }

  @CollectionFeature.Require(
      value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES},
      absent = RESTRICTS_ELEMENTS)
  public void testAdd_nullSupported() {
    assertTrue("add(null) should return true", collection.add(null));
    expectAdded((E) 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: 82

                  expectAdded((E) null);
  }

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

            

Reported by PMD.

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

Line: 87

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


            

Reported by PMD.

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

Line: 87

                  try {
      collection.add(null);
      fail("add(null) should throw");
    } catch (NullPointerException expected) {
    }
    expectUnchanged();
    expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(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: 93

                  expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(null)");
  }

  @CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
  @CollectionSize.Require(absent = ZERO)
  public void testAddConcurrentWithIteration() {
    try {
      Iterator<E> iterator = collection.iterator();
      assertTrue(collection.add(e3()));

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/ForwardingObjectTest.java
9 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: 30

               */
public class ForwardingObjectTest extends TestCase {

  public void testEqualsReflexive() {
    final Object delegate = new Object();
    ForwardingObject forward =
        new ForwardingObject() {
          @Override
          protected Object delegate() {

            

Reported by PMD.

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

Line: 30

               */
public class ForwardingObjectTest extends TestCase {

  public void testEqualsReflexive() {
    final Object delegate = new Object();
    ForwardingObject forward =
        new ForwardingObject() {
          @Override
          protected Object delegate() {

            

Reported by PMD.

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

Line: 42

                  new EqualsTester().addEqualityGroup(forward).testEquals();
  }

  public void testEqualsSymmetric() {
    final Set<String> delegate = Sets.newHashSet("foo");
    ForwardingObject forward =
        new ForwardingObject() {
          @Override
          protected Object delegate() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                          return delegate;
          }
        };
    assertEquals(forward.equals(delegate), delegate.equals(forward));
  }
}

            

Reported by PMD.

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

Line: 51

                          return delegate;
          }
        };
    assertEquals(forward.equals(delegate), delegate.equals(forward));
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'forward' (lines '32'-'40').
Error

Line: 32

              
  public void testEqualsReflexive() {
    final Object delegate = new Object();
    ForwardingObject forward =
        new ForwardingObject() {
          @Override
          protected Object delegate() {
            return delegate;
          }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'forward' (lines '32'-'40').
Error

Line: 32

              
  public void testEqualsReflexive() {
    final Object delegate = new Object();
    ForwardingObject forward =
        new ForwardingObject() {
          @Override
          protected Object delegate() {
            return delegate;
          }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'forward' (lines '44'-'52').
Error

Line: 44

              
  public void testEqualsSymmetric() {
    final Set<String> delegate = Sets.newHashSet("foo");
    ForwardingObject forward =
        new ForwardingObject() {
          @Override
          protected Object delegate() {
            return delegate;
          }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'forward' (lines '44'-'52').
Error

Line: 44

              
  public void testEqualsSymmetric() {
    final Set<String> delegate = Sets.newHashSet("foo");
    ForwardingObject forward =
        new ForwardingObject() {
          @Override
          protected Object delegate() {
            return delegate;
          }

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/ImmutableCollectionTest.java
9 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: 27

               * @author Louis Wasserman
 */
public class ImmutableCollectionTest extends TestCase {
  public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));

            

Reported by PMD.

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

Line: 27

               * @author Louis Wasserman
 */
public class ImmutableCollectionTest extends TestCase {
  public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

               */
public class ImmutableCollectionTest extends TestCase {
  public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

              public class ImmutableCollectionTest extends TestCase {
  public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));
    assertEquals(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                  assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE,

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                  assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE,
        ImmutableCollection.Builder.expandedCapacity(Integer.MAX_VALUE - 1, Integer.MAX_VALUE));


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

                      Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE,
        ImmutableCollection.Builder.expandedCapacity(Integer.MAX_VALUE - 1, Integer.MAX_VALUE));

    assertEquals(13, ImmutableCollection.Builder.expandedCapacity(8, 9));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 39

                      Integer.MAX_VALUE,
        ImmutableCollection.Builder.expandedCapacity(Integer.MAX_VALUE - 1, Integer.MAX_VALUE));

    assertEquals(13, ImmutableCollection.Builder.expandedCapacity(8, 9));
  }
}

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/MapMakerTest.java
9 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 34

              @GwtCompatible(emulated = true)
public class MapMakerTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullParameters() throws Exception {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicInstanceMethods(new MapMaker());
  }


            

Reported by PMD.

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

Line: 35

              public class MapMakerTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullParameters() throws Exception {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicInstanceMethods(new MapMaker());
  }

  @GwtIncompatible // threads

            

Reported by PMD.

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

Line: 42

              
  @GwtIncompatible // threads
  static final class DelayingIdentityLoader<T> implements Function<T, T> {
    private final CountDownLatch delayLatch;

    DelayingIdentityLoader(CountDownLatch delayLatch) {
      this.delayLatch = delayLatch;
    }


            

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

              
  /** Tests for the builder. */
  public static class MakerTest extends TestCase {
    public void testInitialCapacity_negative() {
      MapMaker maker = new MapMaker();
      try {
        maker.initialCapacity(-1);
        fail();
      } catch (IllegalArgumentException expected) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 66

                    MapMaker maker = new MapMaker();
      try {
        maker.initialCapacity(-1);
        fail();
      } catch (IllegalArgumentException expected) {
      }
    }

    // TODO(cpovirk): enable when ready

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 66

                    MapMaker maker = new MapMaker();
      try {
        maker.initialCapacity(-1);
        fail();
      } catch (IllegalArgumentException expected) {
      }
    }

    // TODO(cpovirk): enable when ready

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 77

                    try {
        // even to the same value is not allowed
        maker.initialCapacity(16);
        fail();
      } catch (IllegalArgumentException expected) {
      }
    }

    public void testReturnsPlainConcurrentHashMapWhenPossible() {

            

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

                    }
    }

    public void testReturnsPlainConcurrentHashMapWhenPossible() {
      Map<?, ?> map = new MapMaker().initialCapacity(5).makeMap();
      assertTrue(map instanceof ConcurrentHashMap);
    }
  }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 84

              
    public void testReturnsPlainConcurrentHashMapWhenPossible() {
      Map<?, ?> map = new MapMaker().initialCapacity(5).makeMap();
      assertTrue(map instanceof ConcurrentHashMap);
    }
  }
}

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/ListGenerators.java
9 issues
No abstract method which means that the keyword is most likely used to prevent instantiation. Use a private or protected constructor instead.
Design

Line: 133

                  }
  }

  private abstract static class TestUnhashableListGenerator
      extends TestUnhashableCollectionGenerator<List<UnhashableObject>>
      implements TestListGenerator<UnhashableObject> {}

  public static class UnhashableElementsImmutableListGenerator extends TestUnhashableListGenerator {
    @Override

            

Reported by PMD.

Class cannot be instantiated and does not provide any static methods or fields
Error

Line: 40

               * @author Hayward Chan
 */
@GwtCompatible
public final class ListGenerators {

  private ListGenerators() {}

  public static class ImmutableListOfGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 65

                public static class BuilderAddAllListGenerator extends TestStringListGenerator {
    @Override
    protected List<String> create(String[] elements) {
      return ImmutableList.<String>builder().addAll(asList(elements)).build();
    }
  }

  public static class BuilderReversedListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 65

                public static class BuilderAddAllListGenerator extends TestStringListGenerator {
    @Override
    protected List<String> create(String[] elements) {
      return ImmutableList.<String>builder().addAll(asList(elements)).build();
    }
  }

  public static class BuilderReversedListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 65

                public static class BuilderAddAllListGenerator extends TestStringListGenerator {
    @Override
    protected List<String> create(String[] elements) {
      return ImmutableList.<String>builder().addAll(asList(elements)).build();
    }
  }

  public static class BuilderReversedListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 74

                  protected List<String> create(String[] elements) {
      List<String> list = asList(elements);
      Collections.reverse(list);
      return ImmutableList.copyOf(list).reverse();
    }
  }

  public static class ImmutableListHeadSubListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 85

                    String[] all = new String[elements.length + suffix.length];
      System.arraycopy(elements, 0, all, 0, elements.length);
      System.arraycopy(suffix, 0, all, elements.length, suffix.length);
      return ImmutableList.copyOf(all).subList(0, elements.length);
    }
  }

  public static class ImmutableListTailSubListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 96

                    String[] all = new String[elements.length + prefix.length];
      System.arraycopy(prefix, 0, all, 0, 2);
      System.arraycopy(elements, 0, all, 2, elements.length);
      return ImmutableList.copyOf(all).subList(2, elements.length + 2);
    }
  }

  public static class ImmutableListMiddleSubListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 111

                    System.arraycopy(elements, 0, all, 2, elements.length);
      System.arraycopy(suffix, 0, all, 2 + elements.length, 2);

      return ImmutableList.copyOf(all).subList(2, elements.length + 2);
    }
  }

  public static class CharactersOfStringGenerator extends TestCharacterListGenerator {
    @Override

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/BiMapInverseTester.java
9 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: 45

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapInverseTester<K, V> extends AbstractBiMapTester<K, V> {

  public void testInverseSame() {
    assertSame(getMap(), getMap().inverse().inverse());
  }

  @CollectionFeature.Require(SERIALIZABLE)
  public void testInverseSerialization() {

            

Reported by PMD.

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

Line: 46

              public class BiMapInverseTester<K, V> extends AbstractBiMapTester<K, V> {

  public void testInverseSame() {
    assertSame(getMap(), getMap().inverse().inverse());
  }

  @CollectionFeature.Require(SERIALIZABLE)
  public void testInverseSerialization() {
    BiMapPair<K, V> pair = new BiMapPair<>(getMap());

            

Reported by PMD.

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

Line: 46

              public class BiMapInverseTester<K, V> extends AbstractBiMapTester<K, V> {

  public void testInverseSame() {
    assertSame(getMap(), getMap().inverse().inverse());
  }

  @CollectionFeature.Require(SERIALIZABLE)
  public void testInverseSerialization() {
    BiMapPair<K, V> pair = new BiMapPair<>(getMap());

            

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

                  assertSame(getMap(), getMap().inverse().inverse());
  }

  @CollectionFeature.Require(SERIALIZABLE)
  public void testInverseSerialization() {
    BiMapPair<K, V> pair = new BiMapPair<>(getMap());
    BiMapPair<K, V> copy = SerializableTester.reserialize(pair);
    assertEquals(pair.forward, copy.forward);
    assertEquals(pair.backward, copy.backward);

            

Reported by PMD.

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

Line: 50

                }

  @CollectionFeature.Require(SERIALIZABLE)
  public void testInverseSerialization() {
    BiMapPair<K, V> pair = new BiMapPair<>(getMap());
    BiMapPair<K, V> copy = SerializableTester.reserialize(pair);
    assertEquals(pair.forward, copy.forward);
    assertEquals(pair.backward, copy.backward);
    assertSame(copy.backward, copy.forward.inverse());

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 55

                  BiMapPair<K, V> copy = SerializableTester.reserialize(pair);
    assertEquals(pair.forward, copy.forward);
    assertEquals(pair.backward, copy.backward);
    assertSame(copy.backward, copy.forward.inverse());
    assertSame(copy.forward, copy.backward.inverse());
  }

  private static class BiMapPair<K, V> implements Serializable {
    final BiMap<K, V> forward;

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 56

                  assertEquals(pair.forward, copy.forward);
    assertEquals(pair.backward, copy.backward);
    assertSame(copy.backward, copy.forward.inverse());
    assertSame(copy.forward, copy.backward.inverse());
  }

  private static class BiMapPair<K, V> implements Serializable {
    final BiMap<K, V> forward;
    final BiMap<V, K> backward;

            

Reported by PMD.

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

Line: 60

                }

  private static class BiMapPair<K, V> implements Serializable {
    final BiMap<K, V> forward;
    final BiMap<V, K> backward;

    BiMapPair(BiMap<K, V> original) {
      this.forward = original;
      this.backward = original.inverse();

            

Reported by PMD.

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

Line: 61

              
  private static class BiMapPair<K, V> implements Serializable {
    final BiMap<K, V> forward;
    final BiMap<V, K> backward;

    BiMapPair(BiMap<K, V> original) {
      this.forward = original;
      this.backward = original.inverse();
    }

            

Reported by PMD.

android/guava-tests/test/com/google/common/graph/StandardMutableDirectedNetworkTest.java
9 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 44

                      });
  }

  private final boolean allowsSelfLoops;
  private final boolean allowsParallelEdges;
  private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  public StandardMutableDirectedNetworkTest(

            

Reported by PMD.

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

Line: 45

                }

  private final boolean allowsSelfLoops;
  private final boolean allowsParallelEdges;
  private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  public StandardMutableDirectedNetworkTest(
      boolean allowsSelfLoops,

            

Reported by PMD.

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

Line: 46

              
  private final boolean allowsSelfLoops;
  private final boolean allowsParallelEdges;
  private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  public StandardMutableDirectedNetworkTest(
      boolean allowsSelfLoops,
      boolean allowsParallelEdges,

            

Reported by PMD.

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

Line: 47

                private final boolean allowsSelfLoops;
  private final boolean allowsParallelEdges;
  private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  public StandardMutableDirectedNetworkTest(
      boolean allowsSelfLoops,
      boolean allowsParallelEdges,
      ElementOrder<Integer> nodeOrder,

            

Reported by PMD.

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

Line: 62

              
  @Override
  MutableNetwork<Integer, String> createGraph() {
    return NetworkBuilder.directed()
        .allowsSelfLoops(allowsSelfLoops)
        .allowsParallelEdges(allowsParallelEdges)
        .nodeOrder(nodeOrder)
        .edgeOrder(edgeOrder)
        .build();

            

Reported by PMD.

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

Line: 62

              
  @Override
  MutableNetwork<Integer, String> createGraph() {
    return NetworkBuilder.directed()
        .allowsSelfLoops(allowsSelfLoops)
        .allowsParallelEdges(allowsParallelEdges)
        .nodeOrder(nodeOrder)
        .edgeOrder(edgeOrder)
        .build();

            

Reported by PMD.

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

Line: 62

              
  @Override
  MutableNetwork<Integer, String> createGraph() {
    return NetworkBuilder.directed()
        .allowsSelfLoops(allowsSelfLoops)
        .allowsParallelEdges(allowsParallelEdges)
        .nodeOrder(nodeOrder)
        .edgeOrder(edgeOrder)
        .build();

            

Reported by PMD.

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

Line: 62

              
  @Override
  MutableNetwork<Integer, String> createGraph() {
    return NetworkBuilder.directed()
        .allowsSelfLoops(allowsSelfLoops)
        .allowsParallelEdges(allowsParallelEdges)
        .nodeOrder(nodeOrder)
        .edgeOrder(edgeOrder)
        .build();

            

Reported by PMD.

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

Line: 62

              
  @Override
  MutableNetwork<Integer, String> createGraph() {
    return NetworkBuilder.directed()
        .allowsSelfLoops(allowsSelfLoops)
        .allowsParallelEdges(allowsParallelEdges)
        .nodeOrder(nodeOrder)
        .edgeOrder(edgeOrder)
        .build();

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/UnmodifiableIteratorTest.java
9 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

              @GwtCompatible
public class UnmodifiableIteratorTest extends TestCase {

  public void testRemove() {
    final String[] array = {"a", "b", "c"};

    Iterator<String> iterator =
        new UnmodifiableIterator<String>() {
          int i;

            

Reported by PMD.

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

Line: 32

              @GwtCompatible
public class UnmodifiableIteratorTest extends TestCase {

  public void testRemove() {
    final String[] array = {"a", "b", "c"};

    Iterator<String> iterator =
        new UnmodifiableIterator<String>() {
          int i;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                        }
        };

    assertTrue(iterator.hasNext());
    assertEquals("a", iterator.next());
    try {
      iterator.remove();
      fail();
    } catch (UnsupportedOperationException expected) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 54

                      };

    assertTrue(iterator.hasNext());
    assertEquals("a", iterator.next());
    try {
      iterator.remove();
      fail();
    } catch (UnsupportedOperationException expected) {
    }

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 57

                  assertEquals("a", iterator.next());
    try {
      iterator.remove();
      fail();
    } catch (UnsupportedOperationException expected) {
    }
  }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 57

                  assertEquals("a", iterator.next());
    try {
      iterator.remove();
      fail();
    } catch (UnsupportedOperationException expected) {
    }
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'iterator' (lines '35'-'60').
Error

Line: 35

                public void testRemove() {
    final String[] array = {"a", "b", "c"};

    Iterator<String> iterator =
        new UnmodifiableIterator<String>() {
          int i;

          @Override
          public boolean hasNext() {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'iterator' (lines '35'-'60').
Error

Line: 35

                public void testRemove() {
    final String[] array = {"a", "b", "c"};

    Iterator<String> iterator =
        new UnmodifiableIterator<String>() {
          int i;

          @Override
          public boolean hasNext() {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'iterator' (lines '35'-'60').
Error

Line: 35

                public void testRemove() {
    final String[] array = {"a", "b", "c"};

    Iterator<String> iterator =
        new UnmodifiableIterator<String>() {
          int i;

          @Override
          public boolean hasNext() {

            

Reported by PMD.