The following issues were found

guava-tests/test/com/google/common/graph/StandardImmutableDirectedNetworkTest.java
10 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;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;

            

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;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;


            

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;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;

  public StandardImmutableDirectedNetworkTest(

            

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;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;

  public StandardImmutableDirectedNetworkTest(
      boolean allowsSelfLoops,

            

Reported by PMD.

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

Line: 49

                private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;

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

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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.

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.

JUnit assertions should include a message
Design

Line: 57

                  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.

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.

guava-tests/test/com/google/common/io/ByteSinkTester.java
9 issues
Avoid instantiating new objects inside loops
Performance

Line: 69

                    String name, ByteSinkFactory factory, String desc, byte[] bytes) {
    TestSuite suite = new TestSuite(name + " [" + desc + "]");
    for (final Method method : testMethods) {
      suite.addTest(new ByteSinkTester(factory, bytes, name, desc, method));
    }
    return suite;
  }

  private ByteSink sink;

            

Reported by PMD.

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

Line: 74

                  return suite;
  }

  private ByteSink sink;

  ByteSinkTester(
      ByteSinkFactory factory, byte[] data, String suiteName, String caseDesc, Method method) {
    super(factory, data, suiteName, caseDesc, method);
  }

            

Reported by PMD.

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

Line: 81

                  super(factory, data, suiteName, caseDesc, method);
  }

  @Override
  protected void setUp() throws Exception {
    sink = factory.createSink();
  }

  public void testOpenStream() throws IOException {

            

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

                  sink = factory.createSink();
  }

  public void testOpenStream() throws IOException {
    OutputStream out = sink.openStream();
    try {
      ByteStreams.copy(new ByteArrayInputStream(data), out);
    } finally {
      out.close();

            

Reported by PMD.

Consider using a try-with-resources statement instead of explicitly closing the resource
Design

Line: 88

              
  public void testOpenStream() throws IOException {
    OutputStream out = sink.openStream();
    try {
      ByteStreams.copy(new ByteArrayInputStream(data), out);
    } finally {
      out.close();
    }


            

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

                  assertContainsExpectedBytes();
  }

  public void testOpenBufferedStream() throws IOException {
    OutputStream out = sink.openBufferedStream();
    try {
      ByteStreams.copy(new ByteArrayInputStream(data), out);
    } finally {
      out.close();

            

Reported by PMD.

Consider using a try-with-resources statement instead of explicitly closing the resource
Design

Line: 99

              
  public void testOpenBufferedStream() throws IOException {
    OutputStream out = sink.openBufferedStream();
    try {
      ByteStreams.copy(new ByteArrayInputStream(data), out);
    } finally {
      out.close();
    }


            

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

                  assertContainsExpectedBytes();
  }

  public void testWrite() throws IOException {
    sink.write(data);

    assertContainsExpectedBytes();
  }


            

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

                  assertContainsExpectedBytes();
  }

  public void testWriteFrom_inputStream() throws IOException {
    sink.writeFrom(new ByteArrayInputStream(data));

    assertContainsExpectedBytes();
  }


            

Reported by PMD.

guava-tests/test/com/google/common/graph/StandardMutableUndirectedNetworkTest.java
9 issues
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 StandardMutableUndirectedNetworkTest(

            

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 StandardMutableUndirectedNetworkTest(
      boolean allowsSelfLoops,

            

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 StandardMutableUndirectedNetworkTest(
      boolean allowsSelfLoops,
      boolean allowsParallelEdges,

            

Reported by PMD.

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

Line: 48

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

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

            

Reported by PMD.

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

Line: 63

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

            

Reported by PMD.

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

Line: 63

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

            

Reported by PMD.

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

Line: 63

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

            

Reported by PMD.

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

Line: 63

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

            

Reported by PMD.

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

Line: 63

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

            

Reported by PMD.

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.

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

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.

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

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.

JUnit assertions should include a message
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.

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.

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

Line: 34

               */
public class LazyStackTraceBenchmark {
  @Param({"20", "200", "2000"})
  int stackDepth;

  @Param({"-1", "3", "15"})
  int breakAt;

  int recursionCount;

            

Reported by PMD.

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

Line: 37

                int stackDepth;

  @Param({"-1", "3", "15"})
  int breakAt;

  int recursionCount;

  private static final Object duh = new Object();


            

Reported by PMD.

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

Line: 39

                @Param({"-1", "3", "15"})
  int breakAt;

  int recursionCount;

  private static final Object duh = new Object();

  @Param Mode mode;


            

Reported by PMD.

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

Line: 43

              
  private static final Object duh = new Object();

  @Param Mode mode;

  enum Mode {
    LAZY_STACK_TRACE {
      @Override
      List<StackTraceElement> getStackTrace(Throwable t) {

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 63

                    boolean dummy = false;
      for (int i = 0; i < reps; i++) {
        int f = 0;
        Throwable t = new Throwable();
        for (StackTraceElement ste : getStackTrace(t)) {
          dummy |= ste == duh;
          if (f++ == breakAt) {
            break;
          }

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 65

                      int f = 0;
        Throwable t = new Throwable();
        for (StackTraceElement ste : getStackTrace(t)) {
          dummy |= ste == duh;
          if (f++ == breakAt) {
            break;
          }
        }
      }

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 66

                      Throwable t = new Throwable();
        for (StackTraceElement ste : getStackTrace(t)) {
          dummy |= ste == duh;
          if (f++ == breakAt) {
            break;
          }
        }
      }
      return dummy;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'f' (lines '62'-'62').
Error

Line: 62

                  boolean timeIt(int reps, int breakAt) {
      boolean dummy = false;
      for (int i = 0; i < reps; i++) {
        int f = 0;
        Throwable t = new Throwable();
        for (StackTraceElement ste : getStackTrace(t)) {
          dummy |= ste == duh;
          if (f++ == breakAt) {
            break;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'f' (lines '62'-'72').
Error

Line: 62

                  boolean timeIt(int reps, int breakAt) {
      boolean dummy = false;
      for (int i = 0; i < reps; i++) {
        int f = 0;
        Throwable t = new Throwable();
        for (StackTraceElement ste : getStackTrace(t)) {
          dummy |= ste == duh;
          if (f++ == breakAt) {
            break;

            

Reported by PMD.