The following issues were found

android/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java
14 issues
This class name ends with Test but contains no test cases
Error

Line: 41

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class CharArrayAsListTest extends TestCase {

  private static List<Character> asList(Character[] values) {
    char[] temp = new char[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).

            

Reported by PMD.

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

Line: 51

                  return Chars.asList(temp);
  }

  @GwtIncompatible // suite
  public static Test suite() {
    List<ListTestSuiteBuilder<Character>> builders =
        ImmutableList.of(
            ListTestSuiteBuilder.using(new CharsAsListGenerator()).named("Chars.asList"),
            ListTestSuiteBuilder.using(new CharsAsListHeadSubListGenerator())

            

Reported by PMD.

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

Line: 66

                  TestSuite suite = new TestSuite();
    for (ListTestSuiteBuilder<Character> builder : builders) {
      suite.addTest(
          builder
              .withFeatures(
                  CollectionSize.ONE,
                  CollectionSize.SEVERAL,
                  CollectionFeature.RESTRICTS_ELEMENTS,
                  ListFeature.SUPPORTS_SET)

            

Reported by PMD.

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

Line: 92

                  protected List<Character> create(Character[] elements) {
      Character[] suffix = {Character.MIN_VALUE, Character.MAX_VALUE};
      Character[] all = concat(elements, suffix);
      return asList(all).subList(0, elements.length);
    }
  }

  public static final class CharsAsListTailSubListGenerator extends TestCharListGenerator {
    @Override

            

Reported by PMD.

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

Line: 101

                  protected List<Character> create(Character[] elements) {
      Character[] prefix = {(char) 86, (char) 99};
      Character[] all = concat(prefix, elements);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  public static final class CharsAsListMiddleSubListGenerator extends TestCharListGenerator {
    @Override

            

Reported by PMD.

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

Line: 111

                    Character[] prefix = {Character.MIN_VALUE, Character.MAX_VALUE};
      Character[] suffix = {(char) 86, (char) 99};
      Character[] all = concat(concat(prefix, elements), suffix);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  private static Character[] concat(Character[] left, Character[] right) {
    Character[] result = new Character[left.length + right.length];

            

Reported by PMD.

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

Line: 43

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

  private static List<Character> asList(Character[] values) {
    char[] temp = new char[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Chars.asList(temp);

            

Reported by PMD.

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

Line: 115

                  }
  }

  private static Character[] concat(Character[] left, Character[] right) {
    Character[] result = new Character[left.length + right.length];
    System.arraycopy(left, 0, result, 0, left.length);
    System.arraycopy(right, 0, result, left.length, right.length);
    return result;
  }

            

Reported by PMD.

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

Line: 142

                   * Creates a new collection containing the given elements; implement this method instead of
     * {@link #create(Object...)}.
     */
    protected abstract List<Character> create(Character[] elements);

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

            

Reported by PMD.

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

Line: 44

              public class CharArrayAsListTest extends TestCase {

  private static List<Character> asList(Character[] values) {
    char[] temp = new char[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Chars.asList(temp);
  }

            

Reported by PMD.

android/guava/src/com/google/common/math/PairedStatsAccumulator.java
14 issues
This class has too many methods, consider refactoring it.
Design

Line: 36

              @Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class PairedStatsAccumulator {

  // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();

            

Reported by PMD.

Field xStats has the same name as a method
Error

Line: 40

              
  // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {

            

Reported by PMD.

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

Line: 40

              
  // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {

            

Reported by PMD.

Field yStats has the same name as a method
Error

Line: 41

                // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {
    // We extend the recursive expression for the one-variable case at Art of Computer Programming

            

Reported by PMD.

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

Line: 41

                // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {
    // We extend the recursive expression for the one-variable case at Art of Computer Programming

            

Reported by PMD.

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

Line: 42

                // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {
    // We extend the recursive expression for the one-variable case at Art of Computer Programming
    // vol. 2, Knuth, 4.2.2, (16) to the two-variable case. We have two value series x_i and y_i.

            

Reported by PMD.

Avoid using redundant field initializer for 'sumOfProductsOfDeltas'
Performance

Line: 42

                // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {
    // We extend the recursive expression for the one-variable case at Art of Computer Programming
    // vol. 2, Knuth, 4.2.2, (16) to the two-variable case. We have two value series x_i and y_i.

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 59

                  //               = (x_n - X_n) (y_n - Y_{n-1})
    xStats.add(x);
    if (isFinite(x) && isFinite(y)) {
      if (xStats.count() > 1) {
        sumOfProductsOfDeltas += (x - xStats.mean()) * (y - yStats.mean());
      }
    } else {
      sumOfProductsOfDeltas = NaN;
    }

            

Reported by PMD.

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

Line: 86

                    // in NaN naturally.
      sumOfProductsOfDeltas +=
          values.sumOfProductsOfDeltas()
              + (values.xStats().mean() - xStats.mean())
                  * (values.yStats().mean() - yStats.mean())
                  * values.count();
    }
    yStats.addAll(values.yStats());
  }

            

Reported by PMD.

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

Line: 87

                    sumOfProductsOfDeltas +=
          values.sumOfProductsOfDeltas()
              + (values.xStats().mean() - xStats.mean())
                  * (values.yStats().mean() - yStats.mean())
                  * values.count();
    }
    yStats.addAll(values.yStats());
  }


            

Reported by PMD.

android/guava/src/com/google/common/math/ToDoubleRounder.java
14 issues
The class 'ToDoubleRounder' has a Standard Cyclomatic Complexity of 8 (Highest = 34).
Design

Line: 29

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ToDoubleRounder<X extends Number & Comparable<X>> {
  /**
   * Returns x rounded to either the greatest double less than or equal to the precise value of x,
   * or the least double greater than or equal to the precise value of x.
   */
  abstract double roundToDoubleArbitrarily(X x);

            

Reported by PMD.

The class 'ToDoubleRounder' has a Modified Cyclomatic Complexity of 6 (Highest = 23).
Design

Line: 29

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ToDoubleRounder<X extends Number & Comparable<X>> {
  /**
   * Returns x rounded to either the greatest double less than or equal to the precise value of x,
   * or the least double greater than or equal to the precise value of x.
   */
  abstract double roundToDoubleArbitrarily(X x);

            

Reported by PMD.

The method 'roundToDouble' has a Standard Cyclomatic Complexity of 34.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

The method 'roundToDouble(X, RoundingMode)' has a NCSS line count of 78.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

The method 'roundToDouble(X, RoundingMode)' has a cyclomatic complexity of 42.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

The method 'roundToDouble(X, RoundingMode)' has an NPath complexity of 1089, current threshold is 200
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

Avoid really long methods.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

The method 'roundToDouble' has a Modified Cyclomatic Complexity of 23.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

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

Line: 128

              
          X deltaToFloor = minus(x, roundFloor);
          X deltaToCeiling = minus(roundCeiling, x);
          int diff = deltaToFloor.compareTo(deltaToCeiling);
          if (diff < 0) { // closer to floor
            return roundFloorAsDouble;
          } else if (diff > 0) { // closer to ceiling
            return roundCeilingAsDouble;
          }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'cmpXToRoundArbitrarily' (lines '72'-'152').
Error

Line: 72

                    }
    }
    X roundArbitrarilyAsX = toX(roundArbitrarily, RoundingMode.UNNECESSARY);
    int cmpXToRoundArbitrarily = x.compareTo(roundArbitrarilyAsX);
    switch (mode) {
      case UNNECESSARY:
        checkRoundingUnnecessary(cmpXToRoundArbitrarily == 0);
        return roundArbitrarily;
      case FLOOR:

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/CollectionContainsAllTester.java
14 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: 44

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionContainsAllTester<E> extends AbstractCollectionTester<E> {
  public void testContainsAll_empty() {
    assertTrue(
        "containsAll(empty) should return true", collection.containsAll(MinimalCollection.of()));
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 49

                      "containsAll(empty) should return true", collection.containsAll(MinimalCollection.of()));
  }

  @CollectionSize.Require(absent = ZERO)
  public void testContainsAll_subset() {
    assertTrue(
        "containsAll(subset) should return true",
        collection.containsAll(MinimalCollection.of(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: 56

                      collection.containsAll(MinimalCollection.of(e0())));
  }

  public void testContainsAll_sameElements() {
    assertTrue(
        "containsAll(sameElements) should return true",
        collection.containsAll(MinimalCollection.of(createSamplesArray())));
  }


            

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

                      collection.containsAll(MinimalCollection.of(createSamplesArray())));
  }

  @SuppressWarnings("ModifyingCollectionWithItself")
  public void testContainsAll_self() {
    assertTrue("containsAll(this) should return true", collection.containsAll(collection));
  }

  public void testContainsAll_partialOverlap() {

            

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

                  assertTrue("containsAll(this) should return true", collection.containsAll(collection));
  }

  public void testContainsAll_partialOverlap() {
    assertFalse(
        "containsAll(partialOverlap) should return false",
        collection.containsAll(MinimalCollection.of(e0(), e3())));
  }


            

Reported by PMD.

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

Line: 73

                      collection.containsAll(MinimalCollection.of(e0(), e3())));
  }

  public void testContainsAll_disjoint() {
    assertFalse(
        "containsAll(disjoint) should return false",
        collection.containsAll(MinimalCollection.of(e3())));
  }


            

Reported by PMD.

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

Line: 79

                      collection.containsAll(MinimalCollection.of(e3())));
  }

  @CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES)
  public void testContainsAll_nullNotAllowed() {
    try {
      assertFalse(collection.containsAll(MinimalCollection.of((E) null)));
    } catch (NullPointerException tolerated) {
    }

            

Reported by PMD.

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

Line: 83

                public void testContainsAll_nullNotAllowed() {
    try {
      assertFalse(collection.containsAll(MinimalCollection.of((E) null)));
    } catch (NullPointerException tolerated) {
    }
  }

  @CollectionFeature.Require(ALLOWS_NULL_QUERIES)
  public void testContainsAll_nullAllowed() {

            

Reported by PMD.

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

Line: 83

                public void testContainsAll_nullNotAllowed() {
    try {
      assertFalse(collection.containsAll(MinimalCollection.of((E) null)));
    } catch (NullPointerException tolerated) {
    }
  }

  @CollectionFeature.Require(ALLOWS_NULL_QUERIES)
  public void testContainsAll_nullAllowed() {

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 83

                public void testContainsAll_nullNotAllowed() {
    try {
      assertFalse(collection.containsAll(MinimalCollection.of((E) null)));
    } catch (NullPointerException tolerated) {
    }
  }

  @CollectionFeature.Require(ALLOWS_NULL_QUERIES)
  public void testContainsAll_nullAllowed() {

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/MapContainsValueTester.java
14 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: 40

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapContainsValueTester<K, V> extends AbstractMapTester<K, V> {
  @CollectionSize.Require(absent = ZERO)
  public void testContains_yes() {
    assertTrue("containsValue(present) should return true", getMap().containsValue(v0()));
  }

  public void testContains_no() {

            

Reported by PMD.

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

Line: 42

              public class MapContainsValueTester<K, V> extends AbstractMapTester<K, V> {
  @CollectionSize.Require(absent = ZERO)
  public void testContains_yes() {
    assertTrue("containsValue(present) should return true", getMap().containsValue(v0()));
  }

  public void testContains_no() {
    assertFalse("containsValue(notPresent) should return false", getMap().containsValue(v3()));
  }

            

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

                  assertTrue("containsValue(present) should return true", getMap().containsValue(v0()));
  }

  public void testContains_no() {
    assertFalse("containsValue(notPresent) should return false", getMap().containsValue(v3()));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
  public void testContains_nullNotContainedButAllowed() {

            

Reported by PMD.

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

Line: 46

                }

  public void testContains_no() {
    assertFalse("containsValue(notPresent) should return false", getMap().containsValue(v3()));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
  public void testContains_nullNotContainedButAllowed() {
    assertFalse("containsValue(null) should return false", getMap().containsValue(null));

            

Reported by PMD.

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

Line: 49

                  assertFalse("containsValue(notPresent) should return false", getMap().containsValue(v3()));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
  public void testContains_nullNotContainedButAllowed() {
    assertFalse("containsValue(null) should return false", getMap().containsValue(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_VALUE_QUERIES)

            

Reported by PMD.

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

Line: 51

              
  @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
  public void testContains_nullNotContainedButAllowed() {
    assertFalse("containsValue(null) should return false", getMap().containsValue(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_VALUE_QUERIES)
  public void testContains_nullNotContainedAndUnsupported() {
    expectNullValueMissingWhenNullValuesUnsupported(

            

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

                  assertFalse("containsValue(null) should return false", getMap().containsValue(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_VALUE_QUERIES)
  public void testContains_nullNotContainedAndUnsupported() {
    expectNullValueMissingWhenNullValuesUnsupported(
        "containsValue(null) should return false or throw");
  }


            

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

                      "containsValue(null) should return false or throw");
  }

  @MapFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testContains_nonNullWhenNullContained() {
    initMapWithNullValue();
    assertFalse("containsValue(notPresent) should return false", getMap().containsValue(v3()));
  }

            

Reported by PMD.

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

Line: 64

                @CollectionSize.Require(absent = ZERO)
  public void testContains_nonNullWhenNullContained() {
    initMapWithNullValue();
    assertFalse("containsValue(notPresent) should return false", getMap().containsValue(v3()));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testContains_nullContained() {

            

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

                  assertFalse("containsValue(notPresent) should return false", getMap().containsValue(v3()));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testContains_nullContained() {
    initMapWithNullValue();
    assertTrue("containsValue(null) should return true", getMap().containsValue(null));
  }

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java
14 issues
This class name ends with Test but contains no test cases
Error

Line: 42

               */
@GwtCompatible(emulated = true)
@SuppressWarnings("cast") // redundant casts are intentional and harmless
public class IntArrayAsListTest extends TestCase {

  private static List<Integer> asList(Integer[] values) {
    int[] temp = new int[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).

            

Reported by PMD.

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

Line: 52

                  return Ints.asList(temp);
  }

  @GwtIncompatible // suite
  public static Test suite() {
    List<ListTestSuiteBuilder<Integer>> builders =
        ImmutableList.of(
            ListTestSuiteBuilder.using(new IntsAsListGenerator()).named("Ints.asList"),
            ListTestSuiteBuilder.using(new IntsAsListHeadSubListGenerator())

            

Reported by PMD.

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

Line: 67

                  TestSuite suite = new TestSuite();
    for (ListTestSuiteBuilder<Integer> builder : builders) {
      suite.addTest(
          builder
              .withFeatures(
                  CollectionSize.ONE,
                  CollectionSize.SEVERAL,
                  CollectionFeature.RESTRICTS_ELEMENTS,
                  ListFeature.SUPPORTS_SET)

            

Reported by PMD.

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

Line: 93

                  protected List<Integer> create(Integer[] elements) {
      Integer[] suffix = {Integer.MIN_VALUE, Integer.MAX_VALUE};
      Integer[] all = concat(elements, suffix);
      return asList(all).subList(0, elements.length);
    }
  }

  public static final class IntsAsListTailSubListGenerator extends TestIntegerListGenerator {
    @Override

            

Reported by PMD.

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

Line: 102

                  protected List<Integer> create(Integer[] elements) {
      Integer[] prefix = {(int) 86, (int) 99};
      Integer[] all = concat(prefix, elements);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  public static final class IntsAsListMiddleSubListGenerator extends TestIntegerListGenerator {
    @Override

            

Reported by PMD.

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

Line: 112

                    Integer[] prefix = {Integer.MIN_VALUE, Integer.MAX_VALUE};
      Integer[] suffix = {(int) 86, (int) 99};
      Integer[] all = concat(concat(prefix, elements), suffix);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  private static Integer[] concat(Integer[] left, Integer[] right) {
    Integer[] result = new Integer[left.length + right.length];

            

Reported by PMD.

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

Line: 44

              @SuppressWarnings("cast") // redundant casts are intentional and harmless
public class IntArrayAsListTest extends TestCase {

  private static List<Integer> asList(Integer[] values) {
    int[] temp = new int[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Ints.asList(temp);

            

Reported by PMD.

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

Line: 116

                  }
  }

  private static Integer[] concat(Integer[] left, Integer[] right) {
    Integer[] result = new Integer[left.length + right.length];
    System.arraycopy(left, 0, result, 0, left.length);
    System.arraycopy(right, 0, result, left.length, right.length);
    return result;
  }

            

Reported by PMD.

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

Line: 143

                   * Creates a new collection containing the given elements; implement this method instead of
     * {@link #create(Object...)}.
     */
    protected abstract List<Integer> create(Integer[] elements);

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

            

Reported by PMD.

Found 'DD'-anomaly for variable 'temp' (lines '45'-'47').
Error

Line: 45

              public class IntArrayAsListTest extends TestCase {

  private static List<Integer> asList(Integer[] values) {
    int[] temp = new int[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Ints.asList(temp);
  }

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java
14 issues
This class name ends with Test but contains no test cases
Error

Line: 41

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class DoubleArrayAsListTest extends TestCase {

  private static List<Double> asList(Double[] values) {
    double[] temp = new double[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).

            

Reported by PMD.

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

Line: 51

                  return Doubles.asList(temp);
  }

  @GwtIncompatible // suite
  public static Test suite() {
    List<ListTestSuiteBuilder<Double>> builders =
        ImmutableList.of(
            ListTestSuiteBuilder.using(new DoublesAsListGenerator()).named("Doubles.asList"),
            ListTestSuiteBuilder.using(new DoublsAsListHeadSubListGenerator())

            

Reported by PMD.

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

Line: 66

                  TestSuite suite = new TestSuite();
    for (ListTestSuiteBuilder<Double> builder : builders) {
      suite.addTest(
          builder
              .withFeatures(
                  CollectionSize.ONE,
                  CollectionSize.SEVERAL,
                  CollectionFeature.RESTRICTS_ELEMENTS,
                  ListFeature.SUPPORTS_SET)

            

Reported by PMD.

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

Line: 92

                  protected List<Double> create(Double[] elements) {
      Double[] suffix = {Double.MIN_VALUE, Double.MAX_VALUE};
      Double[] all = concat(elements, suffix);
      return asList(all).subList(0, elements.length);
    }
  }

  public static final class DoublesAsListTailSubListGenerator extends TestDoubleListGenerator {
    @Override

            

Reported by PMD.

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

Line: 101

                  protected List<Double> create(Double[] elements) {
      Double[] prefix = {(double) 86, (double) 99};
      Double[] all = concat(prefix, elements);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  public static final class DoublesAsListMiddleSubListGenerator extends TestDoubleListGenerator {
    @Override

            

Reported by PMD.

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

Line: 111

                    Double[] prefix = {Double.MIN_VALUE, Double.MAX_VALUE};
      Double[] suffix = {(double) 86, (double) 99};
      Double[] all = concat(concat(prefix, elements), suffix);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  private static Double[] concat(Double[] left, Double[] right) {
    Double[] result = new Double[left.length + right.length];

            

Reported by PMD.

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

Line: 43

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

  private static List<Double> asList(Double[] values) {
    double[] temp = new double[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Doubles.asList(temp);

            

Reported by PMD.

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

Line: 115

                  }
  }

  private static Double[] concat(Double[] left, Double[] right) {
    Double[] result = new Double[left.length + right.length];
    System.arraycopy(left, 0, result, 0, left.length);
    System.arraycopy(right, 0, result, left.length, right.length);
    return result;
  }

            

Reported by PMD.

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

Line: 142

                   * Creates a new collection containing the given elements; implement this method instead of
     * {@link #create(Object...)}.
     */
    protected abstract List<Double> create(Double[] elements);

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

            

Reported by PMD.

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

Line: 44

              public class DoubleArrayAsListTest extends TestCase {

  private static List<Double> asList(Double[] values) {
    double[] temp = new double[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Doubles.asList(temp);
  }

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java
14 issues
This class name ends with Test but contains no test cases
Error

Line: 41

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class CharArrayAsListTest extends TestCase {

  private static List<Character> asList(Character[] values) {
    char[] temp = new char[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).

            

Reported by PMD.

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

Line: 51

                  return Chars.asList(temp);
  }

  @GwtIncompatible // suite
  public static Test suite() {
    List<ListTestSuiteBuilder<Character>> builders =
        ImmutableList.of(
            ListTestSuiteBuilder.using(new CharsAsListGenerator()).named("Chars.asList"),
            ListTestSuiteBuilder.using(new CharsAsListHeadSubListGenerator())

            

Reported by PMD.

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

Line: 66

                  TestSuite suite = new TestSuite();
    for (ListTestSuiteBuilder<Character> builder : builders) {
      suite.addTest(
          builder
              .withFeatures(
                  CollectionSize.ONE,
                  CollectionSize.SEVERAL,
                  CollectionFeature.RESTRICTS_ELEMENTS,
                  ListFeature.SUPPORTS_SET)

            

Reported by PMD.

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

Line: 92

                  protected List<Character> create(Character[] elements) {
      Character[] suffix = {Character.MIN_VALUE, Character.MAX_VALUE};
      Character[] all = concat(elements, suffix);
      return asList(all).subList(0, elements.length);
    }
  }

  public static final class CharsAsListTailSubListGenerator extends TestCharListGenerator {
    @Override

            

Reported by PMD.

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

Line: 101

                  protected List<Character> create(Character[] elements) {
      Character[] prefix = {(char) 86, (char) 99};
      Character[] all = concat(prefix, elements);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  public static final class CharsAsListMiddleSubListGenerator extends TestCharListGenerator {
    @Override

            

Reported by PMD.

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

Line: 111

                    Character[] prefix = {Character.MIN_VALUE, Character.MAX_VALUE};
      Character[] suffix = {(char) 86, (char) 99};
      Character[] all = concat(concat(prefix, elements), suffix);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  private static Character[] concat(Character[] left, Character[] right) {
    Character[] result = new Character[left.length + right.length];

            

Reported by PMD.

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

Line: 43

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

  private static List<Character> asList(Character[] values) {
    char[] temp = new char[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Chars.asList(temp);

            

Reported by PMD.

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

Line: 115

                  }
  }

  private static Character[] concat(Character[] left, Character[] right) {
    Character[] result = new Character[left.length + right.length];
    System.arraycopy(left, 0, result, 0, left.length);
    System.arraycopy(right, 0, result, left.length, right.length);
    return result;
  }

            

Reported by PMD.

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

Line: 142

                   * Creates a new collection containing the given elements; implement this method instead of
     * {@link #create(Object...)}.
     */
    protected abstract List<Character> create(Character[] elements);

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

            

Reported by PMD.

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

Line: 44

              public class CharArrayAsListTest extends TestCase {

  private static List<Character> asList(Character[] values) {
    char[] temp = new char[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Chars.asList(temp);
  }

            

Reported by PMD.

guava-tests/test/com/google/common/collect/CountTest.java
14 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

               */
@GwtCompatible
public class CountTest extends TestCase {
  public void testGet() {
    assertEquals(20, new Count(20).get());
  }

  public void testGetAndAdd() {
    Count holder = new Count(20);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

              @GwtCompatible
public class CountTest extends TestCase {
  public void testGet() {
    assertEquals(20, new Count(20).get());
  }

  public void testGetAndAdd() {
    Count holder = new Count(20);
    assertEquals(20, holder.get());

            

Reported by PMD.

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

Line: 31

                  assertEquals(20, new Count(20).get());
  }

  public void testGetAndAdd() {
    Count holder = new Count(20);
    assertEquals(20, holder.get());
    holder.add(1);
    assertEquals(21, holder.get());
  }

            

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

                  assertEquals(20, new Count(20).get());
  }

  public void testGetAndAdd() {
    Count holder = new Count(20);
    assertEquals(20, holder.get());
    holder.add(1);
    assertEquals(21, holder.get());
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

              
  public void testGetAndAdd() {
    Count holder = new Count(20);
    assertEquals(20, holder.get());
    holder.add(1);
    assertEquals(21, holder.get());
  }

  public void testAddAndGet() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

                  Count holder = new Count(20);
    assertEquals(20, holder.get());
    holder.add(1);
    assertEquals(21, holder.get());
  }

  public void testAddAndGet() {
    Count holder = new Count(20);
    assertEquals(21, holder.addAndGet(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: 38

                  assertEquals(21, holder.get());
  }

  public void testAddAndGet() {
    Count holder = new Count(20);
    assertEquals(21, holder.addAndGet(1));
  }

  public void testGetAndSet() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

              
  public void testAddAndGet() {
    Count holder = new Count(20);
    assertEquals(21, holder.addAndGet(1));
  }

  public void testGetAndSet() {
    Count holder = new Count(10);
    assertEquals(10, holder.getAndSet(20));

            

Reported by PMD.

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

Line: 43

                  assertEquals(21, holder.addAndGet(1));
  }

  public void testGetAndSet() {
    Count holder = new Count(10);
    assertEquals(10, holder.getAndSet(20));
    assertEquals(20, holder.get());
  }


            

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(21, holder.addAndGet(1));
  }

  public void testGetAndSet() {
    Count holder = new Count(10);
    assertEquals(10, holder.getAndSet(20));
    assertEquals(20, holder.get());
  }


            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/MapContainsKeyTester.java
14 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: 39

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapContainsKeyTester<K, V> extends AbstractMapTester<K, V> {
  @CollectionSize.Require(absent = ZERO)
  public void testContains_yes() {
    assertTrue("containsKey(present) should return true", getMap().containsKey(k0()));
  }

  public void testContains_no() {

            

Reported by PMD.

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

Line: 41

              public class MapContainsKeyTester<K, V> extends AbstractMapTester<K, V> {
  @CollectionSize.Require(absent = ZERO)
  public void testContains_yes() {
    assertTrue("containsKey(present) should return true", getMap().containsKey(k0()));
  }

  public void testContains_no() {
    assertFalse("containsKey(notPresent) should return false", getMap().containsKey(k3()));
  }

            

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

                  assertTrue("containsKey(present) should return true", getMap().containsKey(k0()));
  }

  public void testContains_no() {
    assertFalse("containsKey(notPresent) should return false", getMap().containsKey(k3()));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testContains_nullNotContainedButAllowed() {

            

Reported by PMD.

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

Line: 45

                }

  public void testContains_no() {
    assertFalse("containsKey(notPresent) should return false", getMap().containsKey(k3()));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testContains_nullNotContainedButAllowed() {
    assertFalse("containsKey(null) should return false", getMap().containsKey(null));

            

Reported by PMD.

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

Line: 48

                  assertFalse("containsKey(notPresent) should return false", getMap().containsKey(k3()));
  }

  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testContains_nullNotContainedButAllowed() {
    assertFalse("containsKey(null) should return false", getMap().containsKey(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_KEY_QUERIES)

            

Reported by PMD.

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

Line: 50

              
  @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
  public void testContains_nullNotContainedButAllowed() {
    assertFalse("containsKey(null) should return false", getMap().containsKey(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_KEY_QUERIES)
  public void testContains_nullNotContainedAndUnsupported() {
    expectNullKeyMissingWhenNullKeysUnsupported("containsKey(null) should return false or throw");

            

Reported by PMD.

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

Line: 53

                  assertFalse("containsKey(null) should return false", getMap().containsKey(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_KEY_QUERIES)
  public void testContains_nullNotContainedAndUnsupported() {
    expectNullKeyMissingWhenNullKeysUnsupported("containsKey(null) should return false or throw");
  }

  @MapFeature.Require(ALLOWS_NULL_KEYS)

            

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

                  expectNullKeyMissingWhenNullKeysUnsupported("containsKey(null) should return false or throw");
  }

  @MapFeature.Require(ALLOWS_NULL_KEYS)
  @CollectionSize.Require(absent = ZERO)
  public void testContains_nonNullWhenNullContained() {
    initMapWithNullKey();
    assertFalse("containsKey(notPresent) should return false", getMap().containsKey(k3()));
  }

            

Reported by PMD.

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

Line: 62

                @CollectionSize.Require(absent = ZERO)
  public void testContains_nonNullWhenNullContained() {
    initMapWithNullKey();
    assertFalse("containsKey(notPresent) should return false", getMap().containsKey(k3()));
  }

  @MapFeature.Require(ALLOWS_NULL_KEYS)
  @CollectionSize.Require(absent = ZERO)
  public void testContains_nullContained() {

            

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

                  assertFalse("containsKey(notPresent) should return false", getMap().containsKey(k3()));
  }

  @MapFeature.Require(ALLOWS_NULL_KEYS)
  @CollectionSize.Require(absent = ZERO)
  public void testContains_nullContained() {
    initMapWithNullKey();
    assertTrue("containsKey(null) should return true", getMap().containsKey(null));
  }

            

Reported by PMD.