The following issues were found

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

Line: 46

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapRemoveEntryTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemoveAbsent() {
    assertFalse(multimap().remove(k0(), v1()));
    expectUnchanged();
  }

            

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

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapRemoveEntryTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemoveAbsent() {
    assertFalse(multimap().remove(k0(), v1()));
    expectUnchanged();
  }


            

Reported by PMD.

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

Line: 49

              public class MultimapRemoveEntryTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemoveAbsent() {
    assertFalse(multimap().remove(k0(), v1()));
    expectUnchanged();
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  expectUnchanged();
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemovePresent() {
    assertTrue(multimap().remove(k0(), v0()));

    assertFalse(multimap().containsEntry(k0(), v0()));

            

Reported by PMD.

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

Line: 55

              
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemovePresent() {
    assertTrue(multimap().remove(k0(), v0()));

    assertFalse(multimap().containsEntry(k0(), v0()));
    expectMissing(e0());
    assertEquals(getNumElements() - 1, multimap().size());

            

Reported by PMD.

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

Line: 56

                @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemovePresent() {
    assertTrue(multimap().remove(k0(), v0()));

    assertFalse(multimap().containsEntry(k0(), v0()));
    expectMissing(e0());
    assertEquals(getNumElements() - 1, multimap().size());
    assertGet(k0(), ImmutableList.<V>of());

            

Reported by PMD.

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

Line: 58

                public void testRemovePresent() {
    assertTrue(multimap().remove(k0(), v0()));

    assertFalse(multimap().containsEntry(k0(), v0()));
    expectMissing(e0());
    assertEquals(getNumElements() - 1, multimap().size());
    assertGet(k0(), ImmutableList.<V>of());
  }


            

Reported by PMD.

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

Line: 60

              
    assertFalse(multimap().containsEntry(k0(), v0()));
    expectMissing(e0());
    assertEquals(getNumElements() - 1, multimap().size());
    assertGet(k0(), ImmutableList.<V>of());
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require({SUPPORTS_REMOVE, 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: 64

                  assertGet(k0(), ImmutableList.<V>of());
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_KEYS})
  public void testRemoveNullKeyPresent() {
    initMultimapWithNullKey();

    assertTrue(multimap().remove(null, getValueForNullKey()));

            

Reported by PMD.

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

Line: 66

              
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_KEYS})
  public void testRemoveNullKeyPresent() {
    initMultimapWithNullKey();

    assertTrue(multimap().remove(null, getValueForNullKey()));

    expectMissing(Helpers.mapEntry((K) null, getValueForNullKey()));

            

Reported by PMD.

android/guava/src/com/google/common/math/BigIntegerMath.java
57 issues
Avoid reassigning parameters such as 'k'
Design

Line: 475

                 *
   * @throws IllegalArgumentException if {@code n < 0}, {@code k < 0}, or {@code k > n}
   */
  public static BigInteger binomial(int n, int k) {
    checkNonNegative("n", n);
    checkNonNegative("k", k);
    checkArgument(k <= n, "k (%s) > n (%s)", k, n);
    if (k > (n >> 1)) {
      k = n - k;

            

Reported by PMD.

The class 'BigIntegerMath' has a Standard Cyclomatic Complexity of 4 (Highest = 11).
Design

Line: 52

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class BigIntegerMath {
  /**
   * Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
   * {@code BigInteger.valueOf(2).pow(log2(x, CEILING))}.
   *
   * @throws IllegalArgumentException if {@code x <= 0}

            

Reported by PMD.

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

Line: 52

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class BigIntegerMath {
  /**
   * Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
   * {@code BigInteger.valueOf(2).pow(log2(x, CEILING))}.
   *
   * @throws IllegalArgumentException if {@code x <= 0}

            

Reported by PMD.

Possible God Class (WMC=73, ATFD=22, TCC=0.000%)
Design

Line: 52

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class BigIntegerMath {
  /**
   * Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
   * {@code BigInteger.valueOf(2).pow(log2(x, CEILING))}.
   *
   * @throws IllegalArgumentException if {@code x <= 0}

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 62

                 */
  @Beta
  public static BigInteger ceilingPowerOfTwo(BigInteger x) {
    return BigInteger.ZERO.setBit(log2(x, CEILING));
  }

  /**
   * Returns the largest power of two less than or equal to {@code x}. This is equivalent to {@code
   * BigInteger.valueOf(2).pow(log2(x, FLOOR))}.

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 74

                 */
  @Beta
  public static BigInteger floorPowerOfTwo(BigInteger x) {
    return BigInteger.ZERO.setBit(log2(x, FLOOR));
  }

  /** Returns {@code true} if {@code x} represents a power of two. */
  public static boolean isPowerOfTwo(BigInteger x) {
    checkNotNull(x);

            

Reported by PMD.

The method 'log2(BigInteger, RoundingMode)' has a cyclomatic complexity of 14.
Design

Line: 92

                 */
  @SuppressWarnings("fallthrough")
  // TODO(kevinb): remove after this warning is disabled globally
  public static int log2(BigInteger x, RoundingMode mode) {
    checkPositive("x", checkNotNull(x));
    int logFloor = x.bitLength() - 1;
    switch (mode) {
      case UNNECESSARY:
        checkRoundingUnnecessary(isPowerOfTwo(x)); // fall through

            

Reported by PMD.

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

Line: 123

                      // To determine which side of logFloor.5 the logarithm is,
        // we compare x^2 to 2^(2 * logFloor + 1).
        BigInteger x2 = x.pow(2);
        int logX2Floor = x2.bitLength() - 1;
        return (logX2Floor < 2 * logFloor + 1) ? logFloor : logFloor + 1;

      default:
        throw new AssertionError();
    }

            

Reported by PMD.

The method 'log10' has a Standard Cyclomatic Complexity of 11.
Design

Line: 151

                 */
  @GwtIncompatible // TODO
  @SuppressWarnings("fallthrough")
  public static int log10(BigInteger x, RoundingMode mode) {
    checkPositive("x", x);
    if (fitsInLong(x)) {
      return LongMath.log10(x.longValue(), mode);
    }


            

Reported by PMD.

The method 'log10(BigInteger, RoundingMode)' has a cyclomatic complexity of 16.
Design

Line: 151

                 */
  @GwtIncompatible // TODO
  @SuppressWarnings("fallthrough")
  public static int log10(BigInteger x, RoundingMode mode) {
    checkPositive("x", x);
    if (fitsInLong(x)) {
      return LongMath.log10(x.longValue(), mode);
    }


            

Reported by PMD.

android/guava-tests/test/com/google/common/io/MultiReaderTest.java
57 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: 29

              /** @author ricebin */
public class MultiReaderTest extends TestCase {

  public void testOnlyOneOpen() throws Exception {
    String testString = "abcdefgh";
    final CharSource source = newCharSource(testString);
    final int[] counter = new int[1];
    CharSource reader =
        new CharSource() {

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 37

                      new CharSource() {
          @Override
          public Reader openStream() throws IOException {
            if (counter[0]++ != 0) {
              throw new IllegalStateException("More than one source open");
            }
            return new FilterReader(source.openStream()) {
              @Override
              public void close() throws IOException {

            

Reported by PMD.

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

Line: 49

                          };
          }
        };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {

            

Reported by PMD.

Ensure that resources like this Reader object are closed after use
Error

Line: 49

                          };
          }
        };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {

            

Reported by PMD.

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

Line: 51

                      };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);

            

Reported by PMD.

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

Line: 51

                      };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                      };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);

            

Reported by PMD.

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

Line: 54

                  assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);
    Reader joinedReader = CharSource.concat(list).openStream();

    assertTrue(joinedReader.ready());

            

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

                  assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);
    Reader joinedReader = CharSource.concat(list).openStream();

    assertTrue(joinedReader.ready());

            

Reported by PMD.

Ensure that resources like this Reader object are closed after use
Error

Line: 57

                public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);
    Reader joinedReader = CharSource.concat(list).openStream();

    assertTrue(joinedReader.ready());
    assertEquals('a', joinedReader.read());
    assertEquals('a', joinedReader.read());
    assertEquals(-1, joinedReader.read());

            

Reported by PMD.

guava/src/com/google/common/collect/Lists.java
57 issues
Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 984

                  for (Object o : list) {
      hashCode = 31 * hashCode + (o == null ? 0 : o.hashCode());

      hashCode = ~~hashCode;
      // needed to deal with GWT integer overflow
    }
    return hashCode;
  }


            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;

            

Reported by PMD.

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

Line: 69

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Lists {
  private Lists() {}

  // ArrayList

  /**

            

Reported by PMD.

Possible God Class (WMC=65, ATFD=7, TCC=0.000%)
Design

Line: 69

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Lists {
  private Lists() {}

  // ArrayList

  /**

            

Reported by PMD.

Avoid really long classes.
Design

Line: 69

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Lists {
  private Lists() {}

  // ArrayList

  /**

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 84

                 * directly, taking advantage of the new <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>.
   */
  @GwtCompatible(serializable = true)
  public static <E extends @Nullable Object> ArrayList<E> newArrayList() {
    return new ArrayList<>();
  }

  /**
   * Creates a <i>mutable</i> {@code ArrayList} instance containing the given elements.

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 104

                 */
  @SafeVarargs
  @GwtCompatible(serializable = true)
  public static <E extends @Nullable Object> ArrayList<E> newArrayList(E... elements) {
    checkNotNull(elements); // for GWT
    // Avoid integer overflow when a large array is passed in
    int capacity = computeArrayListCapacity(elements.length);
    ArrayList<E> list = new ArrayList<>(capacity);
    Collections.addAll(list, elements);

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 127

                 * syntax</a>.
   */
  @GwtCompatible(serializable = true)
  public static <E extends @Nullable Object> ArrayList<E> newArrayList(
      Iterable<? extends E> elements) {
    checkNotNull(elements); // for GWT
    // Let ArrayList's sizing logic work, if possible
    return (elements instanceof Collection)
        ? new ArrayList<>((Collection<? extends E>) elements)

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 144

                 * ImmutableList#copyOf(Iterator)} instead.
   */
  @GwtCompatible(serializable = true)
  public static <E extends @Nullable Object> ArrayList<E> newArrayList(
      Iterator<? extends E> elements) {
    ArrayList<E> list = newArrayList();
    Iterators.addAll(list, elements);
    return list;
  }

            

Reported by PMD.

guava/src/com/google/common/math/BigIntegerMath.java
57 issues
Avoid reassigning parameters such as 'k'
Design

Line: 475

                 *
   * @throws IllegalArgumentException if {@code n < 0}, {@code k < 0}, or {@code k > n}
   */
  public static BigInteger binomial(int n, int k) {
    checkNonNegative("n", n);
    checkNonNegative("k", k);
    checkArgument(k <= n, "k (%s) > n (%s)", k, n);
    if (k > (n >> 1)) {
      k = n - k;

            

Reported by PMD.

Possible God Class (WMC=73, ATFD=22, TCC=0.000%)
Design

Line: 52

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class BigIntegerMath {
  /**
   * Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
   * {@code BigInteger.valueOf(2).pow(log2(x, CEILING))}.
   *
   * @throws IllegalArgumentException if {@code x <= 0}

            

Reported by PMD.

The class 'BigIntegerMath' has a Standard Cyclomatic Complexity of 4 (Highest = 11).
Design

Line: 52

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class BigIntegerMath {
  /**
   * Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
   * {@code BigInteger.valueOf(2).pow(log2(x, CEILING))}.
   *
   * @throws IllegalArgumentException if {@code x <= 0}

            

Reported by PMD.

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

Line: 52

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class BigIntegerMath {
  /**
   * Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
   * {@code BigInteger.valueOf(2).pow(log2(x, CEILING))}.
   *
   * @throws IllegalArgumentException if {@code x <= 0}

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 62

                 */
  @Beta
  public static BigInteger ceilingPowerOfTwo(BigInteger x) {
    return BigInteger.ZERO.setBit(log2(x, CEILING));
  }

  /**
   * Returns the largest power of two less than or equal to {@code x}. This is equivalent to {@code
   * BigInteger.valueOf(2).pow(log2(x, FLOOR))}.

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 74

                 */
  @Beta
  public static BigInteger floorPowerOfTwo(BigInteger x) {
    return BigInteger.ZERO.setBit(log2(x, FLOOR));
  }

  /** Returns {@code true} if {@code x} represents a power of two. */
  public static boolean isPowerOfTwo(BigInteger x) {
    checkNotNull(x);

            

Reported by PMD.

The method 'log2(BigInteger, RoundingMode)' has a cyclomatic complexity of 14.
Design

Line: 92

                 */
  @SuppressWarnings("fallthrough")
  // TODO(kevinb): remove after this warning is disabled globally
  public static int log2(BigInteger x, RoundingMode mode) {
    checkPositive("x", checkNotNull(x));
    int logFloor = x.bitLength() - 1;
    switch (mode) {
      case UNNECESSARY:
        checkRoundingUnnecessary(isPowerOfTwo(x)); // fall through

            

Reported by PMD.

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

Line: 123

                      // To determine which side of logFloor.5 the logarithm is,
        // we compare x^2 to 2^(2 * logFloor + 1).
        BigInteger x2 = x.pow(2);
        int logX2Floor = x2.bitLength() - 1;
        return (logX2Floor < 2 * logFloor + 1) ? logFloor : logFloor + 1;

      default:
        throw new AssertionError();
    }

            

Reported by PMD.

The method 'log10(BigInteger, RoundingMode)' has a cyclomatic complexity of 16.
Design

Line: 151

                 */
  @GwtIncompatible // TODO
  @SuppressWarnings("fallthrough")
  public static int log10(BigInteger x, RoundingMode mode) {
    checkPositive("x", x);
    if (fitsInLong(x)) {
      return LongMath.log10(x.longValue(), mode);
    }


            

Reported by PMD.

The method 'log10' has a Standard Cyclomatic Complexity of 11.
Design

Line: 151

                 */
  @GwtIncompatible // TODO
  @SuppressWarnings("fallthrough")
  public static int log10(BigInteger x, RoundingMode mode) {
    checkPositive("x", x);
    if (fitsInLong(x)) {
      return LongMath.log10(x.longValue(), mode);
    }


            

Reported by PMD.

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

Line: 46

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapRemoveEntryTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemoveAbsent() {
    assertFalse(multimap().remove(k0(), v1()));
    expectUnchanged();
  }

            

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

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapRemoveEntryTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemoveAbsent() {
    assertFalse(multimap().remove(k0(), v1()));
    expectUnchanged();
  }


            

Reported by PMD.

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

Line: 49

              public class MultimapRemoveEntryTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemoveAbsent() {
    assertFalse(multimap().remove(k0(), v1()));
    expectUnchanged();
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  expectUnchanged();
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemovePresent() {
    assertTrue(multimap().remove(k0(), v0()));

    assertFalse(multimap().containsEntry(k0(), v0()));

            

Reported by PMD.

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

Line: 55

              
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemovePresent() {
    assertTrue(multimap().remove(k0(), v0()));

    assertFalse(multimap().containsEntry(k0(), v0()));
    expectMissing(e0());
    assertEquals(getNumElements() - 1, multimap().size());

            

Reported by PMD.

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

Line: 56

                @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testRemovePresent() {
    assertTrue(multimap().remove(k0(), v0()));

    assertFalse(multimap().containsEntry(k0(), v0()));
    expectMissing(e0());
    assertEquals(getNumElements() - 1, multimap().size());
    assertGet(k0(), ImmutableList.<V>of());

            

Reported by PMD.

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

Line: 58

                public void testRemovePresent() {
    assertTrue(multimap().remove(k0(), v0()));

    assertFalse(multimap().containsEntry(k0(), v0()));
    expectMissing(e0());
    assertEquals(getNumElements() - 1, multimap().size());
    assertGet(k0(), ImmutableList.<V>of());
  }


            

Reported by PMD.

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

Line: 60

              
    assertFalse(multimap().containsEntry(k0(), v0()));
    expectMissing(e0());
    assertEquals(getNumElements() - 1, multimap().size());
    assertGet(k0(), ImmutableList.<V>of());
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require({SUPPORTS_REMOVE, 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: 64

                  assertGet(k0(), ImmutableList.<V>of());
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_KEYS})
  public void testRemoveNullKeyPresent() {
    initMultimapWithNullKey();

    assertTrue(multimap().remove(null, getValueForNullKey()));

            

Reported by PMD.

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

Line: 66

              
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_KEYS})
  public void testRemoveNullKeyPresent() {
    initMultimapWithNullKey();

    assertTrue(multimap().remove(null, getValueForNullKey()));

    expectMissing(Helpers.mapEntry((K) null, getValueForNullKey()));

            

Reported by PMD.

guava-tests/test/com/google/common/io/MultiReaderTest.java
57 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: 29

              /** @author ricebin */
public class MultiReaderTest extends TestCase {

  public void testOnlyOneOpen() throws Exception {
    String testString = "abcdefgh";
    final CharSource source = newCharSource(testString);
    final int[] counter = new int[1];
    CharSource reader =
        new CharSource() {

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 37

                      new CharSource() {
          @Override
          public Reader openStream() throws IOException {
            if (counter[0]++ != 0) {
              throw new IllegalStateException("More than one source open");
            }
            return new FilterReader(source.openStream()) {
              @Override
              public void close() throws IOException {

            

Reported by PMD.

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

Line: 49

                          };
          }
        };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {

            

Reported by PMD.

Ensure that resources like this Reader object are closed after use
Error

Line: 49

                          };
          }
        };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {

            

Reported by PMD.

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

Line: 51

                      };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);

            

Reported by PMD.

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

Line: 51

                      };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                      };
    Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
    String result = CharStreams.toString(joinedReader);
    assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);

            

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

                  assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);
    Reader joinedReader = CharSource.concat(list).openStream();

    assertTrue(joinedReader.ready());

            

Reported by PMD.

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

Line: 54

                  assertEquals(testString.length() * 3, result.length());
  }

  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);
    Reader joinedReader = CharSource.concat(list).openStream();

    assertTrue(joinedReader.ready());

            

Reported by PMD.

Ensure that resources like this Reader object are closed after use
Error

Line: 57

                public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);
    Reader joinedReader = CharSource.concat(list).openStream();

    assertTrue(joinedReader.ready());
    assertEquals('a', joinedReader.read());
    assertEquals('a', joinedReader.read());
    assertEquals(-1, joinedReader.read());

            

Reported by PMD.

android/guava-tests/test/com/google/common/hash/FunnelsTest.java
57 issues
This class has too many methods, consider refactoring it.
Design

Line: 38

               *
 * @author Dimitris Andreou
 */
public class FunnelsTest extends TestCase {
  public void testForBytes() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.byteArrayFunnel().funnel(new byte[] {4, 3, 2, 1}, primitiveSink);
    verify(primitiveSink).putBytes(new byte[] {4, 3, 2, 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: 39

               * @author Dimitris Andreou
 */
public class FunnelsTest extends TestCase {
  public void testForBytes() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.byteArrayFunnel().funnel(new byte[] {4, 3, 2, 1}, primitiveSink);
    verify(primitiveSink).putBytes(new byte[] {4, 3, 2, 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: 45

                  verify(primitiveSink).putBytes(new byte[] {4, 3, 2, 1});
  }

  public void testForBytes_null() {
    assertNullsThrowException(Funnels.byteArrayFunnel());
  }

  public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);

            

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

                  assertNullsThrowException(Funnels.byteArrayFunnel());
  }

  public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.unencodedCharsFunnel().funnel("test", primitiveSink);
    verify(primitiveSink).putUnencodedChars("test");
  }


            

Reported by PMD.

The String literal 'test' appears 4 times in this file; the first occurrence is on line 51
Error

Line: 51

              
  public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.unencodedCharsFunnel().funnel("test", primitiveSink);
    verify(primitiveSink).putUnencodedChars("test");
  }

  public void testForStrings_null() {
    assertNullsThrowException(Funnels.unencodedCharsFunnel());

            

Reported by PMD.

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

Line: 51

              
  public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.unencodedCharsFunnel().funnel("test", primitiveSink);
    verify(primitiveSink).putUnencodedChars("test");
  }

  public void testForStrings_null() {
    assertNullsThrowException(Funnels.unencodedCharsFunnel());

            

Reported by PMD.

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

Line: 52

                public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.unencodedCharsFunnel().funnel("test", primitiveSink);
    verify(primitiveSink).putUnencodedChars("test");
  }

  public void testForStrings_null() {
    assertNullsThrowException(Funnels.unencodedCharsFunnel());
  }

            

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

                  verify(primitiveSink).putUnencodedChars("test");
  }

  public void testForStrings_null() {
    assertNullsThrowException(Funnels.unencodedCharsFunnel());
  }

  public void testForStringsCharset() {
    for (Charset charset : Charset.availableCharsets().values()) {

            

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

                  assertNullsThrowException(Funnels.unencodedCharsFunnel());
  }

  public void testForStringsCharset() {
    for (Charset charset : Charset.availableCharsets().values()) {
      PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
      Funnels.stringFunnel(charset).funnel("test", primitiveSink);
      verify(primitiveSink).putString("test", charset);
    }

            

Reported by PMD.

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

Line: 60

                }

  public void testForStringsCharset() {
    for (Charset charset : Charset.availableCharsets().values()) {
      PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
      Funnels.stringFunnel(charset).funnel("test", primitiveSink);
      verify(primitiveSink).putString("test", charset);
    }
  }

            

Reported by PMD.

guava-tests/test/com/google/common/hash/FunnelsTest.java
57 issues
This class has too many methods, consider refactoring it.
Design

Line: 38

               *
 * @author Dimitris Andreou
 */
public class FunnelsTest extends TestCase {
  public void testForBytes() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.byteArrayFunnel().funnel(new byte[] {4, 3, 2, 1}, primitiveSink);
    verify(primitiveSink).putBytes(new byte[] {4, 3, 2, 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: 39

               * @author Dimitris Andreou
 */
public class FunnelsTest extends TestCase {
  public void testForBytes() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.byteArrayFunnel().funnel(new byte[] {4, 3, 2, 1}, primitiveSink);
    verify(primitiveSink).putBytes(new byte[] {4, 3, 2, 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: 45

                  verify(primitiveSink).putBytes(new byte[] {4, 3, 2, 1});
  }

  public void testForBytes_null() {
    assertNullsThrowException(Funnels.byteArrayFunnel());
  }

  public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);

            

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

                  assertNullsThrowException(Funnels.byteArrayFunnel());
  }

  public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.unencodedCharsFunnel().funnel("test", primitiveSink);
    verify(primitiveSink).putUnencodedChars("test");
  }


            

Reported by PMD.

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

Line: 51

              
  public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.unencodedCharsFunnel().funnel("test", primitiveSink);
    verify(primitiveSink).putUnencodedChars("test");
  }

  public void testForStrings_null() {
    assertNullsThrowException(Funnels.unencodedCharsFunnel());

            

Reported by PMD.

The String literal 'test' appears 4 times in this file; the first occurrence is on line 51
Error

Line: 51

              
  public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.unencodedCharsFunnel().funnel("test", primitiveSink);
    verify(primitiveSink).putUnencodedChars("test");
  }

  public void testForStrings_null() {
    assertNullsThrowException(Funnels.unencodedCharsFunnel());

            

Reported by PMD.

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

Line: 52

                public void testForStrings() {
    PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
    Funnels.unencodedCharsFunnel().funnel("test", primitiveSink);
    verify(primitiveSink).putUnencodedChars("test");
  }

  public void testForStrings_null() {
    assertNullsThrowException(Funnels.unencodedCharsFunnel());
  }

            

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

                  verify(primitiveSink).putUnencodedChars("test");
  }

  public void testForStrings_null() {
    assertNullsThrowException(Funnels.unencodedCharsFunnel());
  }

  public void testForStringsCharset() {
    for (Charset charset : Charset.availableCharsets().values()) {

            

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

                  assertNullsThrowException(Funnels.unencodedCharsFunnel());
  }

  public void testForStringsCharset() {
    for (Charset charset : Charset.availableCharsets().values()) {
      PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
      Funnels.stringFunnel(charset).funnel("test", primitiveSink);
      verify(primitiveSink).putString("test", charset);
    }

            

Reported by PMD.

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

Line: 60

                }

  public void testForStringsCharset() {
    for (Charset charset : Charset.availableCharsets().values()) {
      PrimitiveSink primitiveSink = mock(PrimitiveSink.class);
      Funnels.stringFunnel(charset).funnel("test", primitiveSink);
      verify(primitiveSink).putString("test", charset);
    }
  }

            

Reported by PMD.

android/guava/src/com/google/common/collect/Lists.java
57 issues
Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 970

                  for (Object o : list) {
      hashCode = 31 * hashCode + (o == null ? 0 : o.hashCode());

      hashCode = ~~hashCode;
      // needed to deal with GWT integer overflow
    }
    return hashCode;
  }


            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;

            

Reported by PMD.

Possible God Class (WMC=65, ATFD=7, TCC=0.000%)
Design

Line: 68

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Lists {
  private Lists() {}

  // ArrayList

  /**

            

Reported by PMD.

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

Line: 68

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Lists {
  private Lists() {}

  // ArrayList

  /**

            

Reported by PMD.

Avoid really long classes.
Design

Line: 68

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Lists {
  private Lists() {}

  // ArrayList

  /**

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 83

                 * directly, taking advantage of the new <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>.
   */
  @GwtCompatible(serializable = true)
  public static <E extends @Nullable Object> ArrayList<E> newArrayList() {
    return new ArrayList<>();
  }

  /**
   * Creates a <i>mutable</i> {@code ArrayList} instance containing the given elements.

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 103

                 */
  @SafeVarargs
  @GwtCompatible(serializable = true)
  public static <E extends @Nullable Object> ArrayList<E> newArrayList(E... elements) {
    checkNotNull(elements); // for GWT
    // Avoid integer overflow when a large array is passed in
    int capacity = computeArrayListCapacity(elements.length);
    ArrayList<E> list = new ArrayList<>(capacity);
    Collections.addAll(list, elements);

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 126

                 * syntax</a>.
   */
  @GwtCompatible(serializable = true)
  public static <E extends @Nullable Object> ArrayList<E> newArrayList(
      Iterable<? extends E> elements) {
    checkNotNull(elements); // for GWT
    // Let ArrayList's sizing logic work, if possible
    return (elements instanceof Collection)
        ? new ArrayList<>((Collection<? extends E>) elements)

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 143

                 * ImmutableList#copyOf(Iterator)} instead.
   */
  @GwtCompatible(serializable = true)
  public static <E extends @Nullable Object> ArrayList<E> newArrayList(
      Iterator<? extends E> elements) {
    ArrayList<E> list = newArrayList();
    Iterators.addAll(list, elements);
    return list;
  }

            

Reported by PMD.