The following issues were found

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

Line: 41

                      });
  }

  private final boolean allowsSelfLoops;
  private final ElementOrder<Integer> incidentEdgeOrder;

  public StandardMutableDirectedGraphTest(
      boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
    this.allowsSelfLoops = allowsSelfLoops;

            

Reported by PMD.

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

Line: 42

                }

  private final boolean allowsSelfLoops;
  private final ElementOrder<Integer> incidentEdgeOrder;

  public StandardMutableDirectedGraphTest(
      boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
    this.allowsSelfLoops = allowsSelfLoops;
    this.incidentEdgeOrder = incidentEdgeOrder;

            

Reported by PMD.

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

Line: 52

              
  @Override
  public MutableGraph<Integer> createGraph() {
    return GraphBuilder.directed()
        .allowsSelfLoops(allowsSelfLoops)
        .incidentEdgeOrder(incidentEdgeOrder)
        .build();
  }


            

Reported by PMD.

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

Line: 52

              
  @Override
  public MutableGraph<Integer> createGraph() {
    return GraphBuilder.directed()
        .allowsSelfLoops(allowsSelfLoops)
        .incidentEdgeOrder(incidentEdgeOrder)
        .build();
  }


            

Reported by PMD.

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

Line: 52

              
  @Override
  public MutableGraph<Integer> createGraph() {
    return GraphBuilder.directed()
        .allowsSelfLoops(allowsSelfLoops)
        .incidentEdgeOrder(incidentEdgeOrder)
        .build();
  }


            

Reported by PMD.

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

Line: 41

               * @author Louis Wasserman
 */
public class ForwardingCollectionTest extends TestCase {
  static final class StandardImplForwardingCollection<T> extends ForwardingCollection<T> {
    private final Collection<T> backingCollection;

    StandardImplForwardingCollection(Collection<T> backingCollection) {
      this.backingCollection = backingCollection;
    }

            

Reported by PMD.

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

Line: 42

               */
public class ForwardingCollectionTest extends TestCase {
  static final class StandardImplForwardingCollection<T> extends ForwardingCollection<T> {
    private final Collection<T> backingCollection;

    StandardImplForwardingCollection(Collection<T> backingCollection) {
      this.backingCollection = backingCollection;
    }


            

Reported by PMD.

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

Line: 104

                  }
  }

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

    suite.addTestSuite(ForwardingCollectionTest.class);
    suite.addTest(
        CollectionTestSuiteBuilder.using(

            

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

                  return suite;
  }

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

            

Reported by PMD.

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

Line: 139

                }

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

            

Reported by PMD.

guava-tests/test/com/google/common/collect/MultimapsFilterEntriesAsMapTest.java
5 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 46

              
  private Multimap<String, Integer> createMultimap() {
    Multimap<String, Integer> unfiltered = HashMultimap.create();
    unfiltered.put("zero", 55556);
    unfiltered.put("one", 55556);
    unfiltered.put("badkey", 1);
    return Multimaps.filterEntries(unfiltered, PREDICATE);
  }


            

Reported by PMD.

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

Line: 47

                private Multimap<String, Integer> createMultimap() {
    Multimap<String, Integer> unfiltered = HashMultimap.create();
    unfiltered.put("zero", 55556);
    unfiltered.put("one", 55556);
    unfiltered.put("badkey", 1);
    return Multimaps.filterEntries(unfiltered, PREDICATE);
  }

  @Override

            

Reported by PMD.

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

Line: 48

                  Multimap<String, Integer> unfiltered = HashMultimap.create();
    unfiltered.put("zero", 55556);
    unfiltered.put("one", 55556);
    unfiltered.put("badkey", 1);
    return Multimaps.filterEntries(unfiltered, PREDICATE);
  }

  @Override
  protected Map<String, Collection<Integer>> makeEmptyMap() {

            

Reported by PMD.

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

Line: 55

                @Override
  protected Map<String, Collection<Integer>> makeEmptyMap() {
    Multimap<String, Integer> multimap = createMultimap();
    return multimap.asMap();
  }

  @Override
  protected Map<String, Collection<Integer>> makePopulatedMap() {
    Multimap<String, Integer> multimap = createMultimap();

            

Reported by PMD.

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

Line: 62

                protected Map<String, Collection<Integer>> makePopulatedMap() {
    Multimap<String, Integer> multimap = createMultimap();
    populate(multimap);
    return multimap.asMap();
  }
}

            

Reported by PMD.

guava-tests/benchmark/com/google/common/math/DoubleMathBenchmark.java
5 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 38

                private static final int[] factorials = new int[ARRAY_SIZE];
  private static final double[] doubles = new double[ARRAY_SIZE];

  @BeforeExperiment
  void setUp() {
    for (int i = 0; i < ARRAY_SIZE; i++) {
      positiveDoubles[i] = randomPositiveDouble();
      doubles[i] = randomDouble(Long.SIZE);
      factorials[i] = RANDOM_SOURCE.nextInt(100);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'tmp' (lines '69'-'73').
Error

Line: 69

              
  @Benchmark
  int isMathematicalInteger(int reps) {
    int tmp = 0;
    for (int i = 0; i < reps; i++) {
      int j = i & ARRAY_MASK;
      if (DoubleMath.isMathematicalInteger(doubles[j])) {
        tmp++;
      }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'tmp' (lines '73'-'73').
Error

Line: 73

                  for (int i = 0; i < reps; i++) {
      int j = i & ARRAY_MASK;
      if (DoubleMath.isMathematicalInteger(doubles[j])) {
        tmp++;
      }
    }
    return tmp;
  }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'tmp' (lines '81'-'85').
Error

Line: 81

              
  @Benchmark
  int isPowerOfTwo(int reps) {
    int tmp = 0;
    for (int i = 0; i < reps; i++) {
      int j = i & ARRAY_MASK;
      if (DoubleMath.isPowerOfTwo(doubles[j])) {
        tmp++;
      }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'tmp' (lines '85'-'85').
Error

Line: 85

                  for (int i = 0; i < reps; i++) {
      int j = i & ARRAY_MASK;
      if (DoubleMath.isPowerOfTwo(doubles[j])) {
        tmp++;
      }
    }
    return tmp;
  }
}

            

Reported by PMD.

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

Line: 41

                      });
  }

  private final boolean allowsSelfLoops;
  private final ElementOrder<Integer> incidentEdgeOrder;

  public StandardMutableUndirectedGraphTest(
      boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
    this.allowsSelfLoops = allowsSelfLoops;

            

Reported by PMD.

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

Line: 42

                }

  private final boolean allowsSelfLoops;
  private final ElementOrder<Integer> incidentEdgeOrder;

  public StandardMutableUndirectedGraphTest(
      boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
    this.allowsSelfLoops = allowsSelfLoops;
    this.incidentEdgeOrder = incidentEdgeOrder;

            

Reported by PMD.

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

Line: 52

              
  @Override
  public MutableGraph<Integer> createGraph() {
    return GraphBuilder.undirected()
        .allowsSelfLoops(allowsSelfLoops)
        .incidentEdgeOrder(incidentEdgeOrder)
        .build();
  }


            

Reported by PMD.

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

Line: 52

              
  @Override
  public MutableGraph<Integer> createGraph() {
    return GraphBuilder.undirected()
        .allowsSelfLoops(allowsSelfLoops)
        .incidentEdgeOrder(incidentEdgeOrder)
        .build();
  }


            

Reported by PMD.

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

Line: 52

              
  @Override
  public MutableGraph<Integer> createGraph() {
    return GraphBuilder.undirected()
        .allowsSelfLoops(allowsSelfLoops)
        .incidentEdgeOrder(incidentEdgeOrder)
        .build();
  }


            

Reported by PMD.

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

Line: 56

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(SetMultimapAsMapTester.class);
    testers.add(SetMultimapEqualsTester.class);
    testers.add(SetMultimapPutTester.class);
    testers.add(SetMultimapPutAllTester.class);
    testers.add(SetMultimapReplaceValuesTester.class);
    return testers;

            

Reported by PMD.

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

Line: 57

                protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(SetMultimapAsMapTester.class);
    testers.add(SetMultimapEqualsTester.class);
    testers.add(SetMultimapPutTester.class);
    testers.add(SetMultimapPutAllTester.class);
    testers.add(SetMultimapReplaceValuesTester.class);
    return testers;
  }

            

Reported by PMD.

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

Line: 58

                  List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(SetMultimapAsMapTester.class);
    testers.add(SetMultimapEqualsTester.class);
    testers.add(SetMultimapPutTester.class);
    testers.add(SetMultimapPutAllTester.class);
    testers.add(SetMultimapReplaceValuesTester.class);
    return testers;
  }


            

Reported by PMD.

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

Line: 59

                  testers.add(SetMultimapAsMapTester.class);
    testers.add(SetMultimapEqualsTester.class);
    testers.add(SetMultimapPutTester.class);
    testers.add(SetMultimapPutAllTester.class);
    testers.add(SetMultimapReplaceValuesTester.class);
    return testers;
  }

  @Override

            

Reported by PMD.

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

Line: 60

                  testers.add(SetMultimapEqualsTester.class);
    testers.add(SetMultimapPutTester.class);
    testers.add(SetMultimapPutAllTester.class);
    testers.add(SetMultimapReplaceValuesTester.class);
    return testers;
  }

  @Override
  TestSuite computeMultimapGetTestSuite(

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultisetContainsTester.java
5 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
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetContainsTester<E> extends AbstractMultisetTester<E> {
  @CollectionSize.Require(absent = ZERO)
  public void testContainsAllMultisetIgnoresFrequency() {
    assertTrue(getMultiset().containsAll(getSubjectGenerator().create(e0(), e0(), e0())));
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 34

              public class MultisetContainsTester<E> extends AbstractMultisetTester<E> {
  @CollectionSize.Require(absent = ZERO)
  public void testContainsAllMultisetIgnoresFrequency() {
    assertTrue(getMultiset().containsAll(getSubjectGenerator().create(e0(), e0(), e0())));
  }

  @CollectionSize.Require(absent = ZERO)
  public void testContainsAllListIgnoresFrequency() {
    assertTrue(getMultiset().containsAll(Arrays.asList(e0(), e0(), e0())));

            

Reported by PMD.

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

Line: 34

              public class MultisetContainsTester<E> extends AbstractMultisetTester<E> {
  @CollectionSize.Require(absent = ZERO)
  public void testContainsAllMultisetIgnoresFrequency() {
    assertTrue(getMultiset().containsAll(getSubjectGenerator().create(e0(), e0(), e0())));
  }

  @CollectionSize.Require(absent = ZERO)
  public void testContainsAllListIgnoresFrequency() {
    assertTrue(getMultiset().containsAll(Arrays.asList(e0(), e0(), e0())));

            

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

                  assertTrue(getMultiset().containsAll(getSubjectGenerator().create(e0(), e0(), e0())));
  }

  @CollectionSize.Require(absent = ZERO)
  public void testContainsAllListIgnoresFrequency() {
    assertTrue(getMultiset().containsAll(Arrays.asList(e0(), e0(), e0())));
  }
}

            

Reported by PMD.

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

Line: 39

              
  @CollectionSize.Require(absent = ZERO)
  public void testContainsAllListIgnoresFrequency() {
    assertTrue(getMultiset().containsAll(Arrays.asList(e0(), e0(), e0())));
  }
}

            

Reported by PMD.

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

              public class ListToArrayTester<E> extends AbstractListTester<E> {
  // CollectionToArrayTester tests everything except ordering.

  public void testToArray_noArg() {
    Object[] actual = getList().toArray();
    assertArrayEquals("toArray() order should match list", createOrderedArray(), actual);
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 38

                // CollectionToArrayTester tests everything except ordering.

  public void testToArray_noArg() {
    Object[] actual = getList().toArray();
    assertArrayEquals("toArray() order should match list", createOrderedArray(), actual);
  }

  @CollectionSize.Require(absent = ZERO)
  public void testToArray_tooSmall() {

            

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

                  assertArrayEquals("toArray() order should match list", createOrderedArray(), actual);
  }

  @CollectionSize.Require(absent = ZERO)
  public void testToArray_tooSmall() {
    Object[] actual = getList().toArray(new Object[0]);
    assertArrayEquals("toArray(tooSmall) order should match list", createOrderedArray(), actual);
  }


            

Reported by PMD.

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

Line: 48

                  assertArrayEquals("toArray(tooSmall) order should match list", createOrderedArray(), actual);
  }

  public void testToArray_largeEnough() {
    Object[] actual = getList().toArray(new Object[getNumElements()]);
    assertArrayEquals("toArray(largeEnough) order should match list", createOrderedArray(), actual);
  }

  private static void assertArrayEquals(String message, Object[] expected, Object[] actual) {

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 53

                  assertArrayEquals("toArray(largeEnough) order should match list", createOrderedArray(), actual);
  }

  private static void assertArrayEquals(String message, Object[] expected, Object[] actual) {
    assertEquals(message, Arrays.asList(expected), Arrays.asList(actual));
  }
}

            

Reported by PMD.

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

Line: 54

                protected void expectContents(Collection<E> expectedCollection) {
    List<E> expectedList = Helpers.copyToList(expectedCollection);
    // Avoid expectEquals() here to delay reason manufacture until necessary.
    if (getList().size() != expectedList.size()) {
      fail("size mismatch: " + reportContext(expectedList));
    }
    for (int i = 0; i < expectedList.size(); i++) {
      E expected = expectedList.get(i);
      E actual = getList().get(i);

            

Reported by PMD.

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

Line: 54

                protected void expectContents(Collection<E> expectedCollection) {
    List<E> expectedList = Helpers.copyToList(expectedCollection);
    // Avoid expectEquals() here to delay reason manufacture until necessary.
    if (getList().size() != expectedList.size()) {
      fail("size mismatch: " + reportContext(expectedList));
    }
    for (int i = 0; i < expectedList.size(); i++) {
      E expected = expectedList.get(i);
      E actual = getList().get(i);

            

Reported by PMD.

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

Line: 59

                  }
    for (int i = 0; i < expectedList.size(); i++) {
      E expected = expectedList.get(i);
      E actual = getList().get(i);
      if (expected != actual && (expected == null || !expected.equals(actual))) {
        fail("mismatch at index " + i + ": " + reportContext(expectedList));
      }
    }
  }

            

Reported by PMD.

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

Line: 60

                  for (int i = 0; i < expectedList.size(); i++) {
      E expected = expectedList.get(i);
      E actual = getList().get(i);
      if (expected != actual && (expected == null || !expected.equals(actual))) {
        fail("mismatch at index " + i + ": " + reportContext(expectedList));
      }
    }
  }


            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 60

                  for (int i = 0; i < expectedList.size(); i++) {
      E expected = expectedList.get(i);
      E actual = getList().get(i);
      if (expected != actual && (expected == null || !expected.equals(actual))) {
        fail("mismatch at index " + i + ": " + reportContext(expectedList));
      }
    }
  }


            

Reported by PMD.

guava-tests/test/com/google/common/graph/PackageSanityTests.java
5 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: 61

                  setDefault(EndpointPair.class, EndpointPair.ordered("A", "B"));
  }

  @Override
  public void testNulls() throws Exception {
    try {
      super.testNulls();
    } catch (AssertionFailedError e) {
      assertWithMessage("Method did not throw null pointer OR element not in graph exception.")

            

Reported by PMD.

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

Line: 66

                  try {
      super.testNulls();
    } catch (AssertionFailedError e) {
      assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
          .that(e)
          .hasCauseThat()
          .hasMessageThat()
          .contains(ERROR_ELEMENT_NOT_IN_GRAPH);
    }

            

Reported by PMD.

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

Line: 66

                  try {
      super.testNulls();
    } catch (AssertionFailedError e) {
      assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
          .that(e)
          .hasCauseThat()
          .hasMessageThat()
          .contains(ERROR_ELEMENT_NOT_IN_GRAPH);
    }

            

Reported by PMD.

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

Line: 66

                  try {
      super.testNulls();
    } catch (AssertionFailedError e) {
      assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
          .that(e)
          .hasCauseThat()
          .hasMessageThat()
          .contains(ERROR_ELEMENT_NOT_IN_GRAPH);
    }

            

Reported by PMD.

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

Line: 66

                  try {
      super.testNulls();
    } catch (AssertionFailedError e) {
      assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
          .that(e)
          .hasCauseThat()
          .hasMessageThat()
          .contains(ERROR_ELEMENT_NOT_IN_GRAPH);
    }

            

Reported by PMD.