The following issues were found

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

Line: 36

                  return Arrays.asList(new Object[][] {{false}, {true}});
  }

  private final boolean allowsSelfLoops;
  private ImmutableGraph.Builder<Integer> graphBuilder;

  public StandardImmutableUndirectedGraphTest(boolean allowsSelfLoops) {
    this.allowsSelfLoops = allowsSelfLoops;
  }

            

Reported by PMD.

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

Line: 37

                }

  private final boolean allowsSelfLoops;
  private ImmutableGraph.Builder<Integer> graphBuilder;

  public StandardImmutableUndirectedGraphTest(boolean allowsSelfLoops) {
    this.allowsSelfLoops = allowsSelfLoops;
  }


            

Reported by PMD.

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

Line: 45

              
  @Override
  public Graph<Integer> createGraph() {
    graphBuilder = GraphBuilder.undirected().allowsSelfLoops(allowsSelfLoops).immutable();
    return graphBuilder.build();
  }

  @Override
  final void addNode(Integer n) {

            

Reported by PMD.

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

Line: 45

              
  @Override
  public Graph<Integer> createGraph() {
    graphBuilder = GraphBuilder.undirected().allowsSelfLoops(allowsSelfLoops).immutable();
    return graphBuilder.build();
  }

  @Override
  final void addNode(Integer n) {

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultisetSerializationTester.java
4 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 // but no-op
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetSerializationTester<E> extends AbstractMultisetTester<E> {
  @CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
  public void testEntrySetSerialization() {
    Set<Multiset.Entry<E>> expected = getMultiset().entrySet();
    assertEquals(expected, SerializableTester.reserialize(expected));
  }


            

Reported by PMD.

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

Line: 39

              public class MultisetSerializationTester<E> extends AbstractMultisetTester<E> {
  @CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
  public void testEntrySetSerialization() {
    Set<Multiset.Entry<E>> expected = getMultiset().entrySet();
    assertEquals(expected, SerializableTester.reserialize(expected));
  }

  @CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
  public void testElementSetSerialization() {

            

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

                  assertEquals(expected, SerializableTester.reserialize(expected));
  }

  @CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
  public void testElementSetSerialization() {
    Set<E> expected = getMultiset().elementSet();
    assertEquals(expected, SerializableTester.reserialize(expected));
  }
}

            

Reported by PMD.

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

Line: 45

              
  @CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
  public void testElementSetSerialization() {
    Set<E> expected = getMultiset().elementSet();
    assertEquals(expected, SerializableTester.reserialize(expected));
  }
}

            

Reported by PMD.

guava-testlib/src/com/google/common/testing/SloppyTearDown.java
4 issues
Logger calls should be surrounded by log level guards.
Design

Line: 43

                  try {
      sloppyTearDown();
    } catch (Throwable t) {
      logger.log(Level.INFO, "exception thrown during tearDown: " + t.getMessage(), t);
    }
  }

  public abstract void sloppyTearDown() throws Exception;
}

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 38

              public abstract class SloppyTearDown implements TearDown {
  private static final Logger logger = Logger.getLogger(SloppyTearDown.class.getName());

  @Override
  public final void tearDown() {
    try {
      sloppyTearDown();
    } catch (Throwable t) {
      logger.log(Level.INFO, "exception thrown during tearDown: " + t.getMessage(), t);

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 42

                public final void tearDown() {
    try {
      sloppyTearDown();
    } catch (Throwable t) {
      logger.log(Level.INFO, "exception thrown during tearDown: " + t.getMessage(), t);
    }
  }

  public abstract void sloppyTearDown() throws Exception;

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 47

                  }
  }

  public abstract void sloppyTearDown() throws Exception;
}

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/SortedSetMultimapGetTester.java
4 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

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedSetMultimapGetTester<K, V>
    extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
  public void testValueComparator() {
    assertEquals(multimap().valueComparator(), multimap().get(k0()).comparator());
  }
}

            

Reported by PMD.

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

Line: 33

              public class SortedSetMultimapGetTester<K, V>
    extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
  public void testValueComparator() {
    assertEquals(multimap().valueComparator(), multimap().get(k0()).comparator());
  }
}

            

Reported by PMD.

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

Line: 33

              public class SortedSetMultimapGetTester<K, V>
    extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
  public void testValueComparator() {
    assertEquals(multimap().valueComparator(), multimap().get(k0()).comparator());
  }
}

            

Reported by PMD.

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

Line: 33

              public class SortedSetMultimapGetTester<K, V>
    extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
  public void testValueComparator() {
    assertEquals(multimap().valueComparator(), multimap().get(k0()).comparator());
  }
}

            

Reported by PMD.

guava-tests/test/com/google/common/collect/ForwardingTableTest.java
4 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: 31

               */
public class ForwardingTableTest extends TestCase {

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

            

Reported by PMD.

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

Line: 32

              public class ForwardingTableTest extends TestCase {

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

            

Reported by PMD.

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

Line: 44

                          });
  }

  public void testEquals() {
    Table<Integer, Integer, String> table1 = ImmutableTable.of(1, 1, "one");
    Table<Integer, Integer, String> table2 = ImmutableTable.of(2, 2, "two");
    new EqualsTester()
        .addEqualityGroup(table1, wrap(table1), wrap(table1))
        .addEqualityGroup(table2, wrap(table2))

            

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

                          });
  }

  public void testEquals() {
    Table<Integer, Integer, String> table1 = ImmutableTable.of(1, 1, "one");
    Table<Integer, Integer, String> table2 = ImmutableTable.of(2, 2, "two");
    new EqualsTester()
        .addEqualityGroup(table1, wrap(table1), wrap(table1))
        .addEqualityGroup(table2, wrap(table2))

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/TestEnumMultisetGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 49

                  return create(array);
  }

  protected abstract Multiset<AnEnum> create(AnEnum[] elements);

  @Override
  public AnEnum[] createArray(int length) {
    return new AnEnum[length];
  }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '41'-'44').
Error

Line: 41

              
  @Override
  public Multiset<AnEnum> create(Object... elements) {
    AnEnum[] array = new AnEnum[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (AnEnum) e;
    }
    return create(array);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '42'-'47').
Error

Line: 42

                @Override
  public Multiset<AnEnum> create(Object... elements) {
    AnEnum[] array = new AnEnum[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (AnEnum) e;
    }
    return create(array);
  }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '44'-'44').
Error

Line: 44

                  AnEnum[] array = new AnEnum[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (AnEnum) e;
    }
    return create(array);
  }

  protected abstract Multiset<AnEnum> create(AnEnum[] elements);

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/TestStringBiMapGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 60

                  return create(array);
  }

  protected abstract BiMap<String, String> create(Entry<String, String>[] entries);

  @Override
  @SuppressWarnings("unchecked")
  public final Entry<String, String>[] createArray(int length) {
    return new Entry[length];

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '50'-'55').
Error

Line: 50

                @Override
  public final BiMap<String, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '51'-'58').
Error

Line: 51

                public final BiMap<String, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '55'-'55').
Error

Line: 55

                  for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;
    }
    return create(array);
  }

  protected abstract BiMap<String, String> create(Entry<String, String>[] entries);

            

Reported by PMD.

guava-tests/test/com/google/common/collect/ForwardingSortedSetMultimapTest.java
4 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: 31

               */
public class ForwardingSortedSetMultimapTest extends TestCase {

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

            

Reported by PMD.

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

Line: 32

              public class ForwardingSortedSetMultimapTest extends TestCase {

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

            

Reported by PMD.

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

Line: 44

                          });
  }

  public void testEquals() {
    SortedSetMultimap<Integer, String> map1 = TreeMultimap.create(ImmutableMultimap.of(1, "one"));
    SortedSetMultimap<Integer, String> map2 = TreeMultimap.create(ImmutableMultimap.of(2, "two"));
    new EqualsTester()
        .addEqualityGroup(map1, wrap(map1), wrap(map1))
        .addEqualityGroup(map2, wrap(map2))

            

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

                          });
  }

  public void testEquals() {
    SortedSetMultimap<Integer, String> map1 = TreeMultimap.create(ImmutableMultimap.of(1, "one"));
    SortedSetMultimap<Integer, String> map2 = TreeMultimap.create(ImmutableMultimap.of(2, "two"));
    new EqualsTester()
        .addEqualityGroup(map1, wrap(map1), wrap(map1))
        .addEqualityGroup(map2, wrap(map2))

            

Reported by PMD.

guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java
4 issues
JUnit 4 indicates test suites via annotations, not the suite method.
Design

Line: 49

               * under JDK7
 */
public class OpenJdk6MapTests extends TestsForMapsInJavaUtil {
  public static Test suite() {
    return new OpenJdk6MapTests().allTests();
  }

  @Override
  protected Collection<Method> suppressForTreeMapNatural() {

            

Reported by PMD.

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

Line: 86

                @Override
  protected Collection<Method> suppressForConcurrentSkipListMap() {
    List<Method> methods = newArrayList();
    methods.addAll(super.suppressForConcurrentSkipListMap());
    methods.add(getContainsEntryWithIncomparableKeyMethod());
    methods.add(getContainsEntryWithIncomparableValueMethod());
    return methods;
  }


            

Reported by PMD.

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

Line: 87

                protected Collection<Method> suppressForConcurrentSkipListMap() {
    List<Method> methods = newArrayList();
    methods.addAll(super.suppressForConcurrentSkipListMap());
    methods.add(getContainsEntryWithIncomparableKeyMethod());
    methods.add(getContainsEntryWithIncomparableValueMethod());
    return methods;
  }

  @Override

            

Reported by PMD.

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

Line: 88

                  List<Method> methods = newArrayList();
    methods.addAll(super.suppressForConcurrentSkipListMap());
    methods.add(getContainsEntryWithIncomparableKeyMethod());
    methods.add(getContainsEntryWithIncomparableValueMethod());
    return methods;
  }

  @Override
  protected Collection<Method> suppressForHashtable() {

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/TestStringListMultimapGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 74

                  return create(array);
  }

  protected abstract ListMultimap<String, String> create(Entry<String, String>[] entries);

  @Override
  @SuppressWarnings("unchecked")
  public final Entry<String, String>[] createArray(int length) {
    return new Entry[length];

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '64'-'69').
Error

Line: 64

                @Override
  public final ListMultimap<String, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '65'-'72').
Error

Line: 65

                public final ListMultimap<String, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;
    }

            

Reported by PMD.

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

Line: 69

                  for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;
    }
    return create(array);
  }

  protected abstract ListMultimap<String, String> create(Entry<String, String>[] entries);

            

Reported by PMD.