The following issues were found

android/guava-tests/test/com/google/common/escape/ArrayBasedEscaperMapTest.java
21 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 David Beaumont */
@GwtCompatible
public class ArrayBasedEscaperMapTest extends TestCase {
  public void testNullMap() {
    try {
      ArrayBasedEscaperMap.create(null);
      fail("expected exception did not occur");
    } catch (NullPointerException e) {
      // pass

            

Reported by PMD.

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

Line: 30

                public void testNullMap() {
    try {
      ArrayBasedEscaperMap.create(null);
      fail("expected exception did not occur");
    } catch (NullPointerException e) {
      // pass
    }
  }


            

Reported by PMD.

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

Line: 31

                  try {
      ArrayBasedEscaperMap.create(null);
      fail("expected exception did not occur");
    } catch (NullPointerException e) {
      // pass
    }
  }

  public void testEmptyMap() {

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 31

                  try {
      ArrayBasedEscaperMap.create(null);
      fail("expected exception did not occur");
    } catch (NullPointerException e) {
      // pass
    }
  }

  public void testEmptyMap() {

            

Reported by PMD.

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

Line: 31

                  try {
      ArrayBasedEscaperMap.create(null);
      fail("expected exception did not occur");
    } catch (NullPointerException e) {
      // pass
    }
  }

  public void testEmptyMap() {

            

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

                  }
  }

  public void testEmptyMap() {
    Map<Character, String> map = ImmutableMap.of();
    ArrayBasedEscaperMap fem = ArrayBasedEscaperMap.create(map);
    // Non-null array of zero length.
    assertEquals(0, fem.getReplacementArray().length);
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                  Map<Character, String> map = ImmutableMap.of();
    ArrayBasedEscaperMap fem = ArrayBasedEscaperMap.create(map);
    // Non-null array of zero length.
    assertEquals(0, fem.getReplacementArray().length);
  }

  public void testMapLength() {
    Map<Character, String> map =
        ImmutableMap.of(

            

Reported by PMD.

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

Line: 40

                  Map<Character, String> map = ImmutableMap.of();
    ArrayBasedEscaperMap fem = ArrayBasedEscaperMap.create(map);
    // Non-null array of zero length.
    assertEquals(0, fem.getReplacementArray().length);
  }

  public void testMapLength() {
    Map<Character, String> map =
        ImmutableMap.of(

            

Reported by PMD.

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

Line: 40

                  Map<Character, String> map = ImmutableMap.of();
    ArrayBasedEscaperMap fem = ArrayBasedEscaperMap.create(map);
    // Non-null array of zero length.
    assertEquals(0, fem.getReplacementArray().length);
  }

  public void testMapLength() {
    Map<Character, String> map =
        ImmutableMap.of(

            

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(0, fem.getReplacementArray().length);
  }

  public void testMapLength() {
    Map<Character, String> map =
        ImmutableMap.of(
            'a', "first",
            'z', "last");
    ArrayBasedEscaperMap fem = ArrayBasedEscaperMap.create(map);

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/DefaultsTest.java
21 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 Jige Yu
 */
public class DefaultsTest extends TestCase {
  public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());

            

Reported by PMD.

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

Line: 27

               * @author Jige Yu
 */
public class DefaultsTest extends TestCase {
  public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());

            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 28

               */
public class DefaultsTest extends TestCase {
  public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());
    assertEquals(0, Defaults.defaultValue(long.class).longValue());

            

Reported by PMD.

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

Line: 28

               */
public class DefaultsTest extends TestCase {
  public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());
    assertEquals(0, Defaults.defaultValue(long.class).longValue());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

               */
public class DefaultsTest extends TestCase {
  public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());
    assertEquals(0, Defaults.defaultValue(long.class).longValue());

            

Reported by PMD.

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

Line: 29

              public class DefaultsTest extends TestCase {
  public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());
    assertEquals(0, Defaults.defaultValue(long.class).longValue());
    assertEquals(0.0f, Defaults.defaultValue(float.class).floatValue());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

              public class DefaultsTest extends TestCase {
  public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());
    assertEquals(0, Defaults.defaultValue(long.class).longValue());
    assertEquals(0.0f, Defaults.defaultValue(float.class).floatValue());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());
    assertEquals(0, Defaults.defaultValue(long.class).longValue());
    assertEquals(0.0f, Defaults.defaultValue(float.class).floatValue());
    assertEquals(0.0d, Defaults.defaultValue(double.class).doubleValue());

            

Reported by PMD.

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

Line: 30

                public void testGetDefaultValue() {
    assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());
    assertEquals(0, Defaults.defaultValue(long.class).longValue());
    assertEquals(0.0f, Defaults.defaultValue(float.class).floatValue());
    assertEquals(0.0d, Defaults.defaultValue(double.class).doubleValue());

            

Reported by PMD.

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

Line: 31

                  assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
    assertEquals('\0', Defaults.defaultValue(char.class).charValue());
    assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
    assertEquals(0, Defaults.defaultValue(short.class).shortValue());
    assertEquals(0, Defaults.defaultValue(int.class).intValue());
    assertEquals(0, Defaults.defaultValue(long.class).longValue());
    assertEquals(0.0f, Defaults.defaultValue(float.class).floatValue());
    assertEquals(0.0d, Defaults.defaultValue(double.class).doubleValue());
    assertNull(Defaults.defaultValue(void.class));

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java
21 issues
This class has too many methods, consider refactoring it.
Design

Line: 48

               * @author Kevin Bourrillion
 */
@GwtIncompatible
public class TestsForSetsInJavaUtil {
  public static Test suite() {
    return new TestsForSetsInJavaUtil().allTests();
  }

  public Test allTests() {

            

Reported by PMD.

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

Line: 49

               */
@GwtIncompatible
public class TestsForSetsInJavaUtil {
  public static Test suite() {
    return new TestsForSetsInJavaUtil().allTests();
  }

  public Test allTests() {
    TestSuite suite = new TestSuite("java.util Sets");

            

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

                  return Collections.emptySet();
  }

  public Test testsForEmptySet() {
    return SetTestSuiteBuilder.using(
            new TestStringSetGenerator() {
              @Override
              public Set<String> create(String[] elements) {
                return Collections.emptySet();

            

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

                      .createTestSuite();
  }

  public Test testsForSingletonSet() {
    return SetTestSuiteBuilder.using(
            new TestStringSetGenerator() {
              @Override
              public Set<String> create(String[] elements) {
                return Collections.singleton(elements[0]);

            

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

                      .createTestSuite();
  }

  public Test testsForHashSet() {
    return SetTestSuiteBuilder.using(
            new TestStringSetGenerator() {
              @Override
              public Set<String> create(String[] elements) {
                return new HashSet<>(MinimalCollection.of(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: 180

                      .createTestSuite();
  }

  public Test testsForLinkedHashSet() {
    return SetTestSuiteBuilder.using(
            new TestStringSetGenerator() {
              @Override
              public Set<String> create(String[] elements) {
                return new LinkedHashSet<>(MinimalCollection.of(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: 200

                      .createTestSuite();
  }

  public Test testsForEnumSet() {
    return SetTestSuiteBuilder.using(
            new TestEnumSetGenerator() {
              @Override
              public Set<AnEnum> create(AnEnum[] elements) {
                return (elements.length == 0)

            

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

                      .createTestSuite();
  }

  public Test testsForTreeSetNatural() {
    return NavigableSetTestSuiteBuilder.using(
            new TestStringSortedSetGenerator() {
              @Override
              public SortedSet<String> create(String[] elements) {
                return new TreeSet<>(MinimalCollection.of(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: 240

                      .createTestSuite();
  }

  public Test testsForTreeSetWithComparator() {
    return NavigableSetTestSuiteBuilder.using(
            new TestStringSortedSetGenerator() {
              @Override
              public SortedSet<String> create(String[] elements) {
                SortedSet<String> set = new TreeSet<>(arbitraryNullFriendlyComparator());

            

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

                      .createTestSuite();
  }

  public Test testsForCopyOnWriteArraySet() {
    return SetTestSuiteBuilder.using(
            new TestStringSetGenerator() {
              @Override
              public Set<String> create(String[] elements) {
                return new CopyOnWriteArraySet<>(MinimalCollection.of(elements));

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/TestsForMapsInJavaUtil.java
21 issues
This class has too many methods, consider refactoring it.
Design

Line: 51

               * @author Kevin Bourrillion
 */
@GwtIncompatible
public class TestsForMapsInJavaUtil {

  public static Test suite() {
    return new TestsForMapsInJavaUtil().allTests();
  }


            

Reported by PMD.

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

Line: 53

              @GwtIncompatible
public class TestsForMapsInJavaUtil {

  public static Test suite() {
    return new TestsForMapsInJavaUtil().allTests();
  }

  public Test allTests() {
    TestSuite suite = new TestSuite("java.util Maps");

            

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

                      MapEntrySetTester.getSetValueWithNullValuesPresentMethod());
  }

  public Test testsForCheckedMap() {
    return MapTestSuiteBuilder.using(
            new TestStringMapGenerator() {
              @Override
              protected Map<String, String> create(Entry<String, String>[] entries) {
                Map<String, String> map = populate(new HashMap<String, String>(), entries);

            

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

                      .createTestSuite();
  }

  public Test testsForCheckedSortedMap() {
    return SortedMapTestSuiteBuilder.using(
            new TestStringSortedMapGenerator() {
              @Override
              protected SortedMap<String, String> create(Entry<String, String>[] entries) {
                SortedMap<String, String> map = populate(new TreeMap<String, String>(), entries);

            

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

                      .createTestSuite();
  }

  public Test testsForEmptyMap() {
    return MapTestSuiteBuilder.using(
            new TestStringMapGenerator() {
              @Override
              protected Map<String, String> create(Entry<String, String>[] entries) {
                return Collections.emptyMap();

            

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

                      .createTestSuite();
  }

  public Test testsForSingletonMap() {
    return MapTestSuiteBuilder.using(
            new TestStringMapGenerator() {
              @Override
              protected Map<String, String> create(Entry<String, String>[] entries) {
                return Collections.singletonMap(entries[0].getKey(), entries[0].getValue());

            

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

                      .createTestSuite();
  }

  public Test testsForHashMap() {
    return MapTestSuiteBuilder.using(
            new TestStringMapGenerator() {
              @Override
              protected Map<String, String> create(Entry<String, String>[] entries) {
                return toHashMap(entries);

            

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

                      .createTestSuite();
  }

  public Test testsForHashtable() {
    return MapTestSuiteBuilder.using(
            new TestStringMapGenerator() {
              @Override
              protected Map<String, String> create(Entry<String, String>[] entries) {
                return populate(new Hashtable<String, String>(), entries);

            

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

                      .createTestSuite();
  }

  public Test testsForLinkedHashMap() {
    return MapTestSuiteBuilder.using(
            new TestStringMapGenerator() {
              @Override
              protected Map<String, String> create(Entry<String, String>[] entries) {
                return populate(new LinkedHashMap<String, String>(), entries);

            

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

                      .createTestSuite();
  }

  public Test testsForTreeMapNatural() {
    return NavigableMapTestSuiteBuilder.using(
            new TestStringSortedMapGenerator() {
              @Override
              protected SortedMap<String, String> create(Entry<String, String>[] entries) {
                /*

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/SetEqualsTester.java
21 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: 38

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetEqualsTester<E> extends AbstractSetTester<E> {
  public void testEquals_otherSetWithSameElements() {
    assertTrue(
        "A Set should equal any other Set containing the same elements.",
        getSet().equals(MinimalSet.from(getSampleElements())));
  }


            

Reported by PMD.

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

Line: 41

                public void testEquals_otherSetWithSameElements() {
    assertTrue(
        "A Set should equal any other Set containing the same elements.",
        getSet().equals(MinimalSet.from(getSampleElements())));
  }

  @CollectionSize.Require(absent = CollectionSize.ZERO)
  public void testEquals_otherSetWithDifferentElements() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);

            

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

                      getSet().equals(MinimalSet.from(getSampleElements())));
  }

  @CollectionSize.Require(absent = CollectionSize.ZERO)
  public void testEquals_otherSetWithDifferentElements() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(getSubjectGenerator().samples().e3());

    assertFalse(

            

Reported by PMD.

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

Line: 47

                @CollectionSize.Require(absent = CollectionSize.ZERO)
  public void testEquals_otherSetWithDifferentElements() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(getSubjectGenerator().samples().e3());

    assertFalse(
        "A Set should not equal another Set containing different elements.",
        getSet().equals(MinimalSet.from(elements)));
  }

            

Reported by PMD.

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

Line: 47

                @CollectionSize.Require(absent = CollectionSize.ZERO)
  public void testEquals_otherSetWithDifferentElements() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(getSubjectGenerator().samples().e3());

    assertFalse(
        "A Set should not equal another Set containing different elements.",
        getSet().equals(MinimalSet.from(elements)));
  }

            

Reported by PMD.

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

Line: 47

                @CollectionSize.Require(absent = CollectionSize.ZERO)
  public void testEquals_otherSetWithDifferentElements() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(getSubjectGenerator().samples().e3());

    assertFalse(
        "A Set should not equal another Set containing different elements.",
        getSet().equals(MinimalSet.from(elements)));
  }

            

Reported by PMD.

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

Line: 51

              
    assertFalse(
        "A Set should not equal another Set containing different elements.",
        getSet().equals(MinimalSet.from(elements)));
  }

  @CollectionSize.Require(absent = CollectionSize.ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testEquals_containingNull() {

            

Reported by PMD.

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

Line: 54

                      getSet().equals(MinimalSet.from(elements)));
  }

  @CollectionSize.Require(absent = CollectionSize.ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testEquals_containingNull() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(null);


            

Reported by PMD.

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

Line: 58

                @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testEquals_containingNull() {
    Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(null);

    collection = getSubjectGenerator().create(elements.toArray());
    assertTrue(
        "A Set should equal any other Set containing the same elements,"
            + " even if some elements are null.",

            

Reported by PMD.

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

Line: 60

                  Collection<E> elements = getSampleElements(getNumElements() - 1);
    elements.add(null);

    collection = getSubjectGenerator().create(elements.toArray());
    assertTrue(
        "A Set should equal any other Set containing the same elements,"
            + " even if some elements are null.",
        getSet().equals(MinimalSet.from(elements)));
  }

            

Reported by PMD.

guava/src/com/google/common/hash/BloomFilter.java
21 issues
Avoid reassigning parameters such as 'expectedInsertions'
Design

Line: 417

              
  @VisibleForTesting
  static <T extends @Nullable Object> BloomFilter<T> create(
      Funnel<? super T> funnel, long expectedInsertions, double fpp, Strategy strategy) {
    checkNotNull(funnel);
    checkArgument(
        expectedInsertions >= 0, "Expected insertions (%s) must be >= 0", expectedInsertions);
    checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
    checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);

            

Reported by PMD.

Avoid reassigning parameters such as 'p'
Design

Line: 529

                 * @param p false positive rate (must be 0 < p < 1)
   */
  @VisibleForTesting
  static long optimalNumOfBits(long n, double p) {
    if (p == 0) {
      p = Double.MIN_VALUE;
    }
    return (long) (-n * Math.log(p) / (Math.log(2) * Math.log(2)));
  }

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 69

               */
@Beta
@ElementTypesAreNonnullByDefault
public final class BloomFilter<T extends @Nullable Object> implements Predicate<T>, Serializable {
  /**
   * A strategy to translate T instances, to {@code numHashFunctions} bit indexes.
   *
   * <p>Implementations should be collections of pure functions (i.e. stateless).
   */

            

Reported by PMD.

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

Line: 69

               */
@Beta
@ElementTypesAreNonnullByDefault
public final class BloomFilter<T extends @Nullable Object> implements Predicate<T>, Serializable {
  /**
   * A strategy to translate T instances, to {@code numHashFunctions} bit indexes.
   *
   * <p>Implementations should be collections of pure functions (i.e. stateless).
   */

            

Reported by PMD.

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

Line: 109

                }

  /** The bit set of the BloomFilter (not necessarily power of 2!) */
  private final LockFreeBitArray bits;

  /** Number of hashes per element */
  private final int numHashFunctions;

  /** The funnel to translate Ts to bytes */

            

Reported by PMD.

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

Line: 112

                private final LockFreeBitArray bits;

  /** Number of hashes per element */
  private final int numHashFunctions;

  /** The funnel to translate Ts to bytes */
  private final Funnel<? super T> funnel;

  /** The strategy we employ to map an element T to {@code numHashFunctions} bit indexes. */

            

Reported by PMD.

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

Line: 115

                private final int numHashFunctions;

  /** The funnel to translate Ts to bytes */
  private final Funnel<? super T> funnel;

  /** The strategy we employ to map an element T to {@code numHashFunctions} bit indexes. */
  private final Strategy strategy;

  /** Creates a BloomFilter. */

            

Reported by PMD.

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

Line: 118

                private final Funnel<? super T> funnel;

  /** The strategy we employ to map an element T to {@code numHashFunctions} bit indexes. */
  private final Strategy strategy;

  /** Creates a BloomFilter. */
  private BloomFilter(
      LockFreeBitArray bits, int numHashFunctions, Funnel<? super T> funnel, Strategy strategy) {
    checkArgument(numHashFunctions > 0, "numHashFunctions (%s) must be > 0", numHashFunctions);

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 236

                 */
  public boolean isCompatible(BloomFilter<T> that) {
    checkNotNull(that);
    return this != that
        && this.numHashFunctions == that.numHashFunctions
        && this.bitSize() == that.bitSize()
        && this.strategy.equals(that.strategy)
        && this.funnel.equals(that.funnel);
  }

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 254

                 */
  public void putAll(BloomFilter<T> that) {
    checkNotNull(that);
    checkArgument(this != that, "Cannot combine a BloomFilter with itself.");
    checkArgument(
        this.numHashFunctions == that.numHashFunctions,
        "BloomFilters must have the same number of hash functions (%s != %s)",
        this.numHashFunctions,
        that.numHashFunctions);

            

Reported by PMD.

guava/src/com/google/common/cache/CacheStats.java
21 issues
This class has too many methods, consider refactoring it.
Design

Line: 61

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class CacheStats {
  private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;


            

Reported by PMD.

Field hitCount has the same name as a method
Error

Line: 62

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public final class CacheStats {
  private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration

            

Reported by PMD.

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

Line: 62

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public final class CacheStats {
  private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration

            

Reported by PMD.

Field missCount has the same name as a method
Error

Line: 63

              @ElementTypesAreNonnullByDefault
public final class CacheStats {
  private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration
  private final long totalLoadTime;

            

Reported by PMD.

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

Line: 63

              @ElementTypesAreNonnullByDefault
public final class CacheStats {
  private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration
  private final long totalLoadTime;

            

Reported by PMD.

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

Line: 64

              public final class CacheStats {
  private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration
  private final long totalLoadTime;


            

Reported by PMD.

Field loadSuccessCount has the same name as a method
Error

Line: 64

              public final class CacheStats {
  private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration
  private final long totalLoadTime;


            

Reported by PMD.

Field loadExceptionCount has the same name as a method
Error

Line: 65

                private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration
  private final long totalLoadTime;

  private final long evictionCount;

            

Reported by PMD.

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

Line: 65

                private final long hitCount;
  private final long missCount;
  private final long loadSuccessCount;
  private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration
  private final long totalLoadTime;

  private final long evictionCount;

            

Reported by PMD.

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

Line: 68

                private final long loadExceptionCount;

  @SuppressWarnings("GoodTime") // should be a java.time.Duration
  private final long totalLoadTime;

  private final long evictionCount;

  /**
   * Constructs a new {@code CacheStats} instance.

            

Reported by PMD.

guava/src/com/google/common/collect/ForwardingMultimap.java
21 issues
This class has too many methods, consider refactoring it.
Design

Line: 43

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends ForwardingObject implements Multimap<K, V> {

  /** Constructor for use by subclasses. */
  protected ForwardingMultimap() {}

  @Override

            

Reported by PMD.

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

Line: 53

              
  @Override
  public Map<K, Collection<V>> asMap() {
    return delegate().asMap();
  }

  @Override
  public void clear() {
    delegate().clear();

            

Reported by PMD.

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

Line: 58

              
  @Override
  public void clear() {
    delegate().clear();
  }

  @Override
  public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
    return delegate().containsEntry(key, value);

            

Reported by PMD.

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

Line: 63

              
  @Override
  public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
    return delegate().containsEntry(key, value);
  }

  @Override
  public boolean containsKey(@CheckForNull Object key) {
    return delegate().containsKey(key);

            

Reported by PMD.

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

Line: 68

              
  @Override
  public boolean containsKey(@CheckForNull Object key) {
    return delegate().containsKey(key);
  }

  @Override
  public boolean containsValue(@CheckForNull Object value) {
    return delegate().containsValue(value);

            

Reported by PMD.

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

Line: 73

              
  @Override
  public boolean containsValue(@CheckForNull Object value) {
    return delegate().containsValue(value);
  }

  @Override
  public Collection<Entry<K, V>> entries() {
    return delegate().entries();

            

Reported by PMD.

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

Line: 78

              
  @Override
  public Collection<Entry<K, V>> entries() {
    return delegate().entries();
  }

  @Override
  public Collection<V> get(@ParametricNullness K key) {
    return delegate().get(key);

            

Reported by PMD.

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

Line: 83

              
  @Override
  public Collection<V> get(@ParametricNullness K key) {
    return delegate().get(key);
  }

  @Override
  public boolean isEmpty() {
    return delegate().isEmpty();

            

Reported by PMD.

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

Line: 88

              
  @Override
  public boolean isEmpty() {
    return delegate().isEmpty();
  }

  @Override
  public Multiset<K> keys() {
    return delegate().keys();

            

Reported by PMD.

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

Line: 93

              
  @Override
  public Multiset<K> keys() {
    return delegate().keys();
  }

  @Override
  public Set<K> keySet() {
    return delegate().keySet();

            

Reported by PMD.

guava/src/com/google/common/collect/ForwardingMap.java
21 issues
This class has too many methods, consider refactoring it.
Design

Line: 61

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingMap<K extends @Nullable Object, V extends @Nullable Object>
    extends ForwardingObject implements Map<K, V> {
  // TODO(lowasser): identify places where thread safety is actually lost

  /** Constructor for use by subclasses. */
  protected ForwardingMap() {}


            

Reported by PMD.

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

Line: 72

              
  @Override
  public int size() {
    return delegate().size();
  }

  @Override
  public boolean isEmpty() {
    return delegate().isEmpty();

            

Reported by PMD.

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

Line: 77

              
  @Override
  public boolean isEmpty() {
    return delegate().isEmpty();
  }

  @CanIgnoreReturnValue
  @Override
  @CheckForNull

            

Reported by PMD.

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

Line: 84

                @Override
  @CheckForNull
  public V remove(@CheckForNull Object key) {
    return delegate().remove(key);
  }

  @Override
  public void clear() {
    delegate().clear();

            

Reported by PMD.

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

Line: 89

              
  @Override
  public void clear() {
    delegate().clear();
  }

  @Override
  public boolean containsKey(@CheckForNull Object key) {
    return delegate().containsKey(key);

            

Reported by PMD.

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

Line: 94

              
  @Override
  public boolean containsKey(@CheckForNull Object key) {
    return delegate().containsKey(key);
  }

  @Override
  public boolean containsValue(@CheckForNull Object value) {
    return delegate().containsValue(value);

            

Reported by PMD.

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

Line: 99

              
  @Override
  public boolean containsValue(@CheckForNull Object value) {
    return delegate().containsValue(value);
  }

  @Override
  @CheckForNull
  public V get(@CheckForNull Object key) {

            

Reported by PMD.

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

Line: 105

                @Override
  @CheckForNull
  public V get(@CheckForNull Object key) {
    return delegate().get(key);
  }

  @CanIgnoreReturnValue
  @Override
  @CheckForNull

            

Reported by PMD.

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

Line: 112

                @Override
  @CheckForNull
  public V put(@ParametricNullness K key, @ParametricNullness V value) {
    return delegate().put(key, value);
  }

  @Override
  public void putAll(Map<? extends K, ? extends V> map) {
    delegate().putAll(map);

            

Reported by PMD.

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

Line: 117

              
  @Override
  public void putAll(Map<? extends K, ? extends V> map) {
    delegate().putAll(map);
  }

  @Override
  public Set<K> keySet() {
    return delegate().keySet();

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
21 issues
Avoid throwing raw exception types.
Design

Line: 194

              
    @Override
    public Integer get() {
      throw new RuntimeException("Oops");
    }
  }
}

            

Reported by PMD.

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

Line: 39

                protected static final int SLOW_FUNC_VALID_INPUT_DATA = 3;
  private static final String RESULT_DATA = "SUCCESS";

  private SettableFuture<String> outputFuture;
  // Signals that the function is waiting to complete
  private CountDownLatch funcIsWaitingLatch;
  // Signals the function so it will complete
  private CountDownLatch funcCompletionLatch;


            

Reported by PMD.

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

Line: 41

              
  private SettableFuture<String> outputFuture;
  // Signals that the function is waiting to complete
  private CountDownLatch funcIsWaitingLatch;
  // Signals the function so it will complete
  private CountDownLatch funcCompletionLatch;

  @Override
  protected ListenableFuture<String> buildChainingFuture(ListenableFuture<Integer> inputFuture) {

            

Reported by PMD.

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

Line: 43

                // Signals that the function is waiting to complete
  private CountDownLatch funcIsWaitingLatch;
  // Signals the function so it will complete
  private CountDownLatch funcCompletionLatch;

  @Override
  protected ListenableFuture<String> buildChainingFuture(ListenableFuture<Integer> inputFuture) {
    outputFuture = SettableFuture.create();
    funcIsWaitingLatch = new CountDownLatch(1);

            

Reported by PMD.

Switch statements should have a default label
Design

Line: 61

                private class ChainingFunction implements AsyncFunction<Integer, String> {
    @Override
    public ListenableFuture<String> apply(Integer input) throws Exception {
      switch (input) {
        case VALID_INPUT_DATA:
          outputFuture.set(RESULT_DATA);
          break;
        case SLOW_OUTPUT_VALID_INPUT_DATA:
          break; // do nothing to the result

            

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

                  }
  }

  public void testFutureGetThrowsFunctionException() throws Exception {
    inputFuture.set(EXCEPTION_DATA);
    listener.assertException(EXCEPTION);
  }

  public void testFutureGetThrowsCancellationIfInputCancelled() throws Exception {

            

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

                  listener.assertException(EXCEPTION);
  }

  public void testFutureGetThrowsCancellationIfInputCancelled() throws Exception {
    inputFuture.cancel(true); // argument is ignored
    try {
      resultFuture.get();
      fail("Result future must throw CancellationException" + " if input future is cancelled.");
    } catch (CancellationException 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: 92

                  }
  }

  public void testFutureGetThrowsCancellationIfOutputCancelled() throws Exception {
    inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA);
    outputFuture.cancel(true); // argument is ignored
    try {
      resultFuture.get();
      fail(

            

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

                  }
  }

  public void testAsyncToString() throws Exception {
    inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA);
    assertThat(resultFuture.toString()).contains(outputFuture.toString());
  }

  public void testFutureCancelBeforeInputCompletion() throws Exception {

            

Reported by PMD.

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

Line: 106

              
  public void testAsyncToString() throws Exception {
    inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA);
    assertThat(resultFuture.toString()).contains(outputFuture.toString());
  }

  public void testFutureCancelBeforeInputCompletion() throws Exception {
    assertTrue(resultFuture.cancel(true));
    assertTrue(resultFuture.isCancelled());

            

Reported by PMD.