The following issues were found

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

Line: 37

              @GwtCompatible(emulated = true)
@SuppressWarnings("unchecked") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
final class RegularContiguousSet<C extends Comparable> extends ContiguousSet<C> {
  private final Range<C> range;

  RegularContiguousSet(Range<C> range, DiscreteDomain<C> domain) {
    super(domain);
    this.range = range;

            

Reported by PMD.

Field range has the same name as a method
Error

Line: 38

              @SuppressWarnings("unchecked") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
final class RegularContiguousSet<C extends Comparable> extends ContiguousSet<C> {
  private final Range<C> range;

  RegularContiguousSet(Range<C> range, DiscreteDomain<C> domain) {
    super(domain);
    this.range = range;
  }

            

Reported by PMD.

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

Line: 38

              @SuppressWarnings("unchecked") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
final class RegularContiguousSet<C extends Comparable> extends ContiguousSet<C> {
  private final Range<C> range;

  RegularContiguousSet(Range<C> range, DiscreteDomain<C> domain) {
    super(domain);
    this.range = range;
  }

            

Reported by PMD.

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

Line: 120

                @Override
  public C first() {
    // requireNonNull is safe because we checked the range is not empty in ContiguousSet.create.
    return requireNonNull(range.lowerBound.leastValueAbove(domain));
  }

  @Override
  public C last() {
    // requireNonNull is safe because we checked the range is not empty in ContiguousSet.create.

            

Reported by PMD.

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

Line: 126

                @Override
  public C last() {
    // requireNonNull is safe because we checked the range is not empty in ContiguousSet.create.
    return requireNonNull(range.upperBound.greatestValueBelow(domain));
  }

  @Override
  ImmutableList<C> createAsList() {
    if (domain.supportsFastOffset) {

            

Reported by PMD.

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

Line: 184

                  if (other.isEmpty()) {
      return other;
    } else {
      C lowerEndpoint = Ordering.natural().max(this.first(), other.first());
      C upperEndpoint = Ordering.natural().min(this.last(), other.last());
      return (lowerEndpoint.compareTo(upperEndpoint) <= 0)
          ? ContiguousSet.create(Range.closed(lowerEndpoint, upperEndpoint), domain)
          : new EmptyContiguousSet<C>(domain);
    }

            

Reported by PMD.

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

Line: 185

                    return other;
    } else {
      C lowerEndpoint = Ordering.natural().max(this.first(), other.first());
      C upperEndpoint = Ordering.natural().min(this.last(), other.last());
      return (lowerEndpoint.compareTo(upperEndpoint) <= 0)
          ? ContiguousSet.create(Range.closed(lowerEndpoint, upperEndpoint), domain)
          : new EmptyContiguousSet<C>(domain);
    }
  }

            

Reported by PMD.

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

Line: 186

                  } else {
      C lowerEndpoint = Ordering.natural().max(this.first(), other.first());
      C upperEndpoint = Ordering.natural().min(this.last(), other.last());
      return (lowerEndpoint.compareTo(upperEndpoint) <= 0)
          ? ContiguousSet.create(Range.closed(lowerEndpoint, upperEndpoint), domain)
          : new EmptyContiguousSet<C>(domain);
    }
  }


            

Reported by PMD.

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

Line: 200

                @Override
  public Range<C> range(BoundType lowerBoundType, BoundType upperBoundType) {
    return Range.create(
        range.lowerBound.withLowerBoundType(lowerBoundType, domain),
        range.upperBound.withUpperBoundType(upperBoundType, domain));
  }

  @Override
  public boolean equals(@CheckForNull Object object) {

            

Reported by PMD.

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

Line: 201

                public Range<C> range(BoundType lowerBoundType, BoundType upperBoundType) {
    return Range.create(
        range.lowerBound.withLowerBoundType(lowerBoundType, domain),
        range.upperBound.withUpperBoundType(upperBoundType, domain));
  }

  @Override
  public boolean equals(@CheckForNull Object object) {
    if (object == this) {

            

Reported by PMD.

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

              public class ListMultimapPutTester<K, V> extends AbstractListMultimapTester<K, V> {
  // MultimapPutTester tests non-duplicate values, but ignores ordering

  @MapFeature.Require(SUPPORTS_PUT)
  public void testPutAddsValueAtEnd() {
    for (K key : sampleKeys()) {
      for (V value : sampleValues()) {
        resetContainer();


            

Reported by PMD.

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

Line: 41

                // MultimapPutTester tests non-duplicate values, but ignores ordering

  @MapFeature.Require(SUPPORTS_PUT)
  public void testPutAddsValueAtEnd() {
    for (K key : sampleKeys()) {
      for (V value : sampleValues()) {
        resetContainer();

        List<V> values = multimap().get(key);

            

Reported by PMD.

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

Line: 46

                    for (V value : sampleValues()) {
        resetContainer();

        List<V> values = multimap().get(key);
        List<V> expectedValues = Helpers.copyToList(values);

        assertTrue(multimap().put(key, value));
        expectedValues.add(value);


            

Reported by PMD.

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

Line: 49

                      List<V> values = multimap().get(key);
        List<V> expectedValues = Helpers.copyToList(values);

        assertTrue(multimap().put(key, value));
        expectedValues.add(value);

        assertGet(key, expectedValues);
        assertEquals(value, values.get(values.size() - 1));
      }

            

Reported by PMD.

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

Line: 50

                      List<V> expectedValues = Helpers.copyToList(values);

        assertTrue(multimap().put(key, value));
        expectedValues.add(value);

        assertGet(key, expectedValues);
        assertEquals(value, values.get(values.size() - 1));
      }
    }

            

Reported by PMD.

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

Line: 53

                      expectedValues.add(value);

        assertGet(key, expectedValues);
        assertEquals(value, values.get(values.size() - 1));
      }
    }
  }

  @MapFeature.Require(SUPPORTS_PUT)

            

Reported by PMD.

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

Line: 53

                      expectedValues.add(value);

        assertGet(key, expectedValues);
        assertEquals(value, values.get(values.size() - 1));
      }
    }
  }

  @MapFeature.Require(SUPPORTS_PUT)

            

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

                  }
  }

  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(absent = ZERO)
  public void testPutDuplicateValue() {
    List<Entry<K, V>> entries = copyToList(multimap().entries());

    for (Entry<K, V> entry : entries) {

            

Reported by PMD.

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

Line: 60

              
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(absent = ZERO)
  public void testPutDuplicateValue() {
    List<Entry<K, V>> entries = copyToList(multimap().entries());

    for (Entry<K, V> entry : entries) {
      resetContainer();


            

Reported by PMD.

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

Line: 61

                @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(absent = ZERO)
  public void testPutDuplicateValue() {
    List<Entry<K, V>> entries = copyToList(multimap().entries());

    for (Entry<K, V> entry : entries) {
      resetContainer();

      K k = entry.getKey();

            

Reported by PMD.

android/guava/src/com/google/common/base/Utf8.java
15 issues
The class 'Utf8' has a Modified Cyclomatic Complexity of 4 (Highest = 12).
Design

Line: 42

              @Beta
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Utf8 {
  /**
   * Returns the number of bytes in the UTF-8-encoded form of {@code sequence}. For a string, this
   * method is equivalent to {@code string.getBytes(UTF_8).length}, but is more efficient in both
   * time and space.
   *

            

Reported by PMD.

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

Line: 42

              @Beta
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Utf8 {
  /**
   * Returns the number of bytes in the UTF-8-encoded form of {@code sequence}. For a string, this
   * method is equivalent to {@code string.getBytes(UTF_8).length}, but is more efficient in both
   * time and space.
   *

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 65

                  // This loop optimizes for chars less than 0x800.
    for (; i < utf16Length; i++) {
      char c = sequence.charAt(i);
      if (c < 0x800) {
        utf8Length += ((0x7f - c) >>> 31); // branch free!
      } else {
        utf8Length += encodedLengthGeneral(sequence, i);
        break;
      }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 86

                  int utf8Length = 0;
    for (int i = start; i < utf16Length; i++) {
      char c = sequence.charAt(i);
      if (c < 0x800) {
        utf8Length += (0x7f - c) >>> 31; // branch free!
      } else {
        utf8Length += 2;
        // jdk7+: if (Character.isSurrogate(c)) {
        if (MIN_SURROGATE <= c && c <= MAX_SURROGATE) {

            

Reported by PMD.

Avoid reassigning the loop control variable 'i'
Design

Line: 96

                        if (Character.codePointAt(sequence, i) == c) {
            throw new IllegalArgumentException(unpairedSurrogateMsg(i));
          }
          i++;
        }
      }
    }
    return utf8Length;
  }

            

Reported by PMD.

The method 'isWellFormedSlowPath(byte, int, int)' has a cyclomatic complexity of 21.
Design

Line: 138

                  return true;
  }

  private static boolean isWellFormedSlowPath(byte[] bytes, int off, int end) {
    int index = off;
    while (true) {
      int byte1;

      // Optimize for interior runs of ASCII bytes.

            

Reported by PMD.

The method 'isWellFormedSlowPath' has a Modified Cyclomatic Complexity of 12.
Design

Line: 138

                  return true;
  }

  private static boolean isWellFormedSlowPath(byte[] bytes, int off, int end) {
    int index = off;
    while (true) {
      int byte1;

      // Optimize for interior runs of ASCII bytes.

            

Reported by PMD.

The method 'isWellFormedSlowPath' has a Standard Cyclomatic Complexity of 12.
Design

Line: 138

                  return true;
  }

  private static boolean isWellFormedSlowPath(byte[] bytes, int off, int end) {
    int index = off;
    while (true) {
      int byte1;

      // Optimize for interior runs of ASCII bytes.

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 157

                      }
        // Simultaneously check for illegal trailing-byte in leading position
        // and overlong 2-byte form.
        if (byte1 < (byte) 0xC2 || bytes[index++] > (byte) 0xBF) {
          return false;
        }
      } else if (byte1 < (byte) 0xF0) {
        // Three-byte form.
        if (index + 1 >= end) {

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 166

                        return false;
        }
        int byte2 = bytes[index++];
        if (byte2 > (byte) 0xBF
            // Overlong? 5 most significant bits must not all be zero.
            || (byte1 == (byte) 0xE0 && byte2 < (byte) 0xA0)
            // Check for illegal surrogate codepoints.
            || (byte1 == (byte) 0xED && (byte) 0xA0 <= byte2)
            // Third byte trailing-byte test.

            

Reported by PMD.

android/guava/src/com/google/common/collect/ForwardingSortedSet.java
15 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 71

                @Override
  @CheckForNull
  public Comparator<? super E> comparator() {
    return delegate().comparator();
  }

  @Override
  @ParametricNullness
  public E first() {

            

Reported by PMD.

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

Line: 77

                @Override
  @ParametricNullness
  public E first() {
    return delegate().first();
  }

  @Override
  public SortedSet<E> headSet(@ParametricNullness E toElement) {
    return delegate().headSet(toElement);

            

Reported by PMD.

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

Line: 82

              
  @Override
  public SortedSet<E> headSet(@ParametricNullness E toElement) {
    return delegate().headSet(toElement);
  }

  @Override
  @ParametricNullness
  public E last() {

            

Reported by PMD.

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

Line: 88

                @Override
  @ParametricNullness
  public E last() {
    return delegate().last();
  }

  @Override
  public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
    return delegate().subSet(fromElement, toElement);

            

Reported by PMD.

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

Line: 93

              
  @Override
  public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
    return delegate().subSet(fromElement, toElement);
  }

  @Override
  public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
    return delegate().tailSet(fromElement);

            

Reported by PMD.

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

Line: 98

              
  @Override
  public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
    return delegate().tailSet(fromElement);
  }

  /**
   * A sensible definition of {@link #contains} in terms of the {@code first()} method of {@link
   * #tailSet}. If you override {@link #tailSet}, you may wish to override {@link #contains} to

            

Reported by PMD.

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

Line: 115

                    // any ClassCastExceptions and NullPointerExceptions are caught
      @SuppressWarnings({"unchecked", "nullness"})
      SortedSet<@Nullable Object> self = (SortedSet<@Nullable Object>) this;
      Object ceiling = self.tailSet(object).first();
      return unsafeCompare(comparator(), ceiling, object) == 0;
    } catch (ClassCastException | NoSuchElementException | NullPointerException e) {
      return false;
    }
  }

            

Reported by PMD.

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

Line: 115

                    // any ClassCastExceptions and NullPointerExceptions are caught
      @SuppressWarnings({"unchecked", "nullness"})
      SortedSet<@Nullable Object> self = (SortedSet<@Nullable Object>) this;
      Object ceiling = self.tailSet(object).first();
      return unsafeCompare(comparator(), ceiling, object) == 0;
    } catch (ClassCastException | NoSuchElementException | NullPointerException e) {
      return false;
    }
  }

            

Reported by PMD.

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

Line: 117

                    SortedSet<@Nullable Object> self = (SortedSet<@Nullable Object>) this;
      Object ceiling = self.tailSet(object).first();
      return unsafeCompare(comparator(), ceiling, object) == 0;
    } catch (ClassCastException | NoSuchElementException | NullPointerException e) {
      return false;
    }
  }

  /**

            

Reported by PMD.

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

Line: 117

                    SortedSet<@Nullable Object> self = (SortedSet<@Nullable Object>) this;
      Object ceiling = self.tailSet(object).first();
      return unsafeCompare(comparator(), ceiling, object) == 0;
    } catch (ClassCastException | NoSuchElementException | NullPointerException e) {
      return false;
    }
  }

  /**

            

Reported by PMD.

android/guava/src/com/google/common/collect/RegularImmutableTable.java
15 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 36

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
  RegularImmutableTable() {}

  abstract Cell<R, C, V> getCell(int iterationIndex);

  @Override

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 47

                }

  @WeakOuter
  private final class CellSet extends IndexedImmutableSet<Cell<R, C, V>> {
    @Override
    public int size() {
      return RegularImmutableTable.this.size();
    }


            

Reported by PMD.

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

Line: 50

                private final class CellSet extends IndexedImmutableSet<Cell<R, C, V>> {
    @Override
    public int size() {
      return RegularImmutableTable.this.size();
    }

    @Override
    Cell<R, C, V> get(int index) {
      return getCell(index);

            

Reported by PMD.

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

Line: 50

                private final class CellSet extends IndexedImmutableSet<Cell<R, C, V>> {
    @Override
    public int size() {
      return RegularImmutableTable.this.size();
    }

    @Override
    Cell<R, C, V> get(int index) {
      return getCell(index);

            

Reported by PMD.

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

Line: 62

                  public boolean contains(@CheckForNull Object object) {
      if (object instanceof Cell) {
        Cell<?, ?, ?> cell = (Cell<?, ?, ?>) object;
        Object value = RegularImmutableTable.this.get(cell.getRowKey(), cell.getColumnKey());
        return value != null && value.equals(cell.getValue());
      }
      return false;
    }


            

Reported by PMD.

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

Line: 62

                  public boolean contains(@CheckForNull Object object) {
      if (object instanceof Cell) {
        Cell<?, ?, ?> cell = (Cell<?, ?, ?>) object;
        Object value = RegularImmutableTable.this.get(cell.getRowKey(), cell.getColumnKey());
        return value != null && value.equals(cell.getValue());
      }
      return false;
    }


            

Reported by PMD.

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

Line: 62

                  public boolean contains(@CheckForNull Object object) {
      if (object instanceof Cell) {
        Cell<?, ?, ?> cell = (Cell<?, ?, ?>) object;
        Object value = RegularImmutableTable.this.get(cell.getRowKey(), cell.getColumnKey());
        return value != null && value.equals(cell.getValue());
      }
      return false;
    }


            

Reported by PMD.

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

Line: 62

                  public boolean contains(@CheckForNull Object object) {
      if (object instanceof Cell) {
        Cell<?, ?, ?> cell = (Cell<?, ?, ?>) object;
        Object value = RegularImmutableTable.this.get(cell.getRowKey(), cell.getColumnKey());
        return value != null && value.equals(cell.getValue());
      }
      return false;
    }


            

Reported by PMD.

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

Line: 63

                    if (object instanceof Cell) {
        Cell<?, ?, ?> cell = (Cell<?, ?, ?>) object;
        Object value = RegularImmutableTable.this.get(cell.getRowKey(), cell.getColumnKey());
        return value != null && value.equals(cell.getValue());
      }
      return false;
    }

    @Override

            

Reported by PMD.

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

Line: 63

                    if (object instanceof Cell) {
        Cell<?, ?, ?> cell = (Cell<?, ?, ?>) object;
        Object value = RegularImmutableTable.this.get(cell.getRowKey(), cell.getColumnKey());
        return value != null && value.equals(cell.getValue());
      }
      return false;
    }

    @Override

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
15 issues
Avoid reassigning parameters such as 'mapFeatures'
Design

Line: 220

                }

  public static Set<Feature<?>> computeCommonDerivedCollectionFeatures(
      Set<Feature<?>> mapFeatures) {
    mapFeatures = new HashSet<>(mapFeatures);
    Set<Feature<?>> derivedFeatures = new HashSet<>();
    mapFeatures.remove(CollectionFeature.SERIALIZABLE);
    if (mapFeatures.remove(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS)) {
      derivedFeatures.add(CollectionFeature.SERIALIZABLE);

            

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.testing;

import static com.google.common.collect.testing.DerivedCollectionGenerators.keySetGenerator;

import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.DerivedCollectionGenerators.MapEntrySetGenerator;

            

Reported by PMD.

High amount of different objects as members denotes a high coupling
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect.testing;

import static com.google.common.collect.testing.DerivedCollectionGenerators.keySetGenerator;

import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.DerivedCollectionGenerators.MapEntrySetGenerator;

            

Reported by PMD.

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

Line: 119

              
    List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);

    if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
      derivedSuites.add(
          MapTestSuiteBuilder.using(
                  new ReserializedMapGenerator<K, V>(parentBuilder.getSubjectGenerator()))
              .withFeatures(computeReserializedMapFeatures(parentBuilder.getFeatures()))
              .named(parentBuilder.getName() + " reserialized")

            

Reported by PMD.

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

Line: 141

                          .withTearDown(parentBuilder.getTearDown())
            .createTestSuite());

    derivedSuites.add(
        createDerivedKeySetSuite(keySetGenerator(parentBuilder.getSubjectGenerator()))
            .withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
            .named(parentBuilder.getName() + " keys")
            .suppressing(parentBuilder.getSuppressedTests())
            .withSetUp(parentBuilder.getSetUp())

            

Reported by PMD.

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

Line: 142

                          .createTestSuite());

    derivedSuites.add(
        createDerivedKeySetSuite(keySetGenerator(parentBuilder.getSubjectGenerator()))
            .withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
            .named(parentBuilder.getName() + " keys")
            .suppressing(parentBuilder.getSuppressedTests())
            .withSetUp(parentBuilder.getSetUp())
            .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 142

                          .createTestSuite());

    derivedSuites.add(
        createDerivedKeySetSuite(keySetGenerator(parentBuilder.getSubjectGenerator()))
            .withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
            .named(parentBuilder.getName() + " keys")
            .suppressing(parentBuilder.getSuppressedTests())
            .withSetUp(parentBuilder.getSetUp())
            .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 142

                          .createTestSuite());

    derivedSuites.add(
        createDerivedKeySetSuite(keySetGenerator(parentBuilder.getSubjectGenerator()))
            .withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
            .named(parentBuilder.getName() + " keys")
            .suppressing(parentBuilder.getSuppressedTests())
            .withSetUp(parentBuilder.getSetUp())
            .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 142

                          .createTestSuite());

    derivedSuites.add(
        createDerivedKeySetSuite(keySetGenerator(parentBuilder.getSubjectGenerator()))
            .withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
            .named(parentBuilder.getName() + " keys")
            .suppressing(parentBuilder.getSuppressedTests())
            .withSetUp(parentBuilder.getSetUp())
            .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 142

                          .createTestSuite());

    derivedSuites.add(
        createDerivedKeySetSuite(keySetGenerator(parentBuilder.getSubjectGenerator()))
            .withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
            .named(parentBuilder.getName() + " keys")
            .suppressing(parentBuilder.getSuppressedTests())
            .withSetUp(parentBuilder.getSetUp())
            .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

android/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java
15 issues
Avoid reassigning parameters such as 'permitsToTake'
Design

Line: 243

                  }

    @Override
    long storedPermitsToWaitTime(double storedPermits, double permitsToTake) {
      double availablePermitsAboveThreshold = storedPermits - thresholdPermits;
      long micros = 0;
      // measuring the integral on the right part of the function (the climbing line)
      if (availablePermitsAboveThreshold > 0.0) {
        double permitsAboveThresholdToTake = min(availablePermitsAboveThreshold, permitsToTake);

            

Reported by PMD.

Class cannot be instantiated and does not provide any static methods or fields
Error

Line: 26

              
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class SmoothRateLimiter extends RateLimiter {
  /*
   * How is the RateLimiter designed, and why?
   *
   * The primary feature of a RateLimiter is its "stable rate", the maximum rate that it should
   * allow in normal conditions. This is enforced by "throttling" incoming requests as needed. For

            

Reported by PMD.

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

Line: 206

                 * </ul>
   */
  static final class SmoothWarmingUp extends SmoothRateLimiter {
    private final long warmupPeriodMicros;
    /**
     * The slope of the line from the stable interval (when permits == 0), to the cold interval
     * (when permits == maxPermits)
     */
    private double slope;

            

Reported by PMD.

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

Line: 211

                   * The slope of the line from the stable interval (when permits == 0), to the cold interval
     * (when permits == maxPermits)
     */
    private double slope;

    private double thresholdPermits;
    private double coldFactor;

    SmoothWarmingUp(

            

Reported by PMD.

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

Line: 213

                   */
    private double slope;

    private double thresholdPermits;
    private double coldFactor;

    SmoothWarmingUp(
        SleepingStopwatch stopwatch, long warmupPeriod, TimeUnit timeUnit, double coldFactor) {
      super(stopwatch);

            

Reported by PMD.

Private field 'coldFactor' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 214

                  private double slope;

    private double thresholdPermits;
    private double coldFactor;

    SmoothWarmingUp(
        SleepingStopwatch stopwatch, long warmupPeriod, TimeUnit timeUnit, double coldFactor) {
      super(stopwatch);
      this.warmupPeriodMicros = timeUnit.toMicros(warmupPeriod);

            

Reported by PMD.

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

Line: 214

                  private double slope;

    private double thresholdPermits;
    private double coldFactor;

    SmoothWarmingUp(
        SleepingStopwatch stopwatch, long warmupPeriod, TimeUnit timeUnit, double coldFactor) {
      super(stopwatch);
      this.warmupPeriodMicros = timeUnit.toMicros(warmupPeriod);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 247

                    double availablePermitsAboveThreshold = storedPermits - thresholdPermits;
      long micros = 0;
      // measuring the integral on the right part of the function (the climbing line)
      if (availablePermitsAboveThreshold > 0.0) {
        double permitsAboveThresholdToTake = min(availablePermitsAboveThreshold, permitsToTake);
        // TODO(cpovirk): Figure out a good name for this variable.
        double length =
            permitsToTime(availablePermitsAboveThreshold)
                + permitsToTime(availablePermitsAboveThreshold - permitsAboveThresholdToTake);

            

Reported by PMD.

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

Line: 279

                 */
  static final class SmoothBursty extends SmoothRateLimiter {
    /** The work (permits) of how many seconds can be saved up if this RateLimiter is unused? */
    final double maxBurstSeconds;

    SmoothBursty(SleepingStopwatch stopwatch, double maxBurstSeconds) {
      super(stopwatch);
      this.maxBurstSeconds = maxBurstSeconds;
    }

            

Reported by PMD.

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

Line: 313

                }

  /** The currently stored permits. */
  double storedPermits;

  /** The maximum number of stored permits. */
  double maxPermits;

  /**

            

Reported by PMD.

android/guava/src/com/google/common/hash/MessageDigestHashFunction.java
15 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 36

               */
@Immutable
@ElementTypesAreNonnullByDefault
final class MessageDigestHashFunction extends AbstractHashFunction implements Serializable {

  @SuppressWarnings("Immutable") // cloned before each use
  private final MessageDigest prototype;

  private final int bytes;

            

Reported by PMD.

You shouldnt declare field of MessageDigest type, because unsynchronized access could cause problems
Design

Line: 39

              final class MessageDigestHashFunction extends AbstractHashFunction implements Serializable {

  @SuppressWarnings("Immutable") // cloned before each use
  private final MessageDigest prototype;

  private final int bytes;
  private final boolean supportsClone;
  private final String toString;


            

Reported by PMD.

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

Line: 39

              final class MessageDigestHashFunction extends AbstractHashFunction implements Serializable {

  @SuppressWarnings("Immutable") // cloned before each use
  private final MessageDigest prototype;

  private final int bytes;
  private final boolean supportsClone;
  private final String toString;


            

Reported by PMD.

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

Line: 41

                @SuppressWarnings("Immutable") // cloned before each use
  private final MessageDigest prototype;

  private final int bytes;
  private final boolean supportsClone;
  private final String toString;

  MessageDigestHashFunction(String algorithmName, String toString) {
    this.prototype = getMessageDigest(algorithmName);

            

Reported by PMD.

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

Line: 42

                private final MessageDigest prototype;

  private final int bytes;
  private final boolean supportsClone;
  private final String toString;

  MessageDigestHashFunction(String algorithmName, String toString) {
    this.prototype = getMessageDigest(algorithmName);
    this.bytes = prototype.getDigestLength();

            

Reported by PMD.

Field supportsClone has the same name as a method
Error

Line: 42

                private final MessageDigest prototype;

  private final int bytes;
  private final boolean supportsClone;
  private final String toString;

  MessageDigestHashFunction(String algorithmName, String toString) {
    this.prototype = getMessageDigest(algorithmName);
    this.bytes = prototype.getDigestLength();

            

Reported by PMD.

Field toString has the same name as a method
Error

Line: 43

              
  private final int bytes;
  private final boolean supportsClone;
  private final String toString;

  MessageDigestHashFunction(String algorithmName, String toString) {
    this.prototype = getMessageDigest(algorithmName);
    this.bytes = prototype.getDigestLength();
    this.toString = checkNotNull(toString);

            

Reported by PMD.

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

Line: 43

              
  private final int bytes;
  private final boolean supportsClone;
  private final String toString;

  MessageDigestHashFunction(String algorithmName, String toString) {
    this.prototype = getMessageDigest(algorithmName);
    this.bytes = prototype.getDigestLength();
    this.toString = checkNotNull(toString);

            

Reported by PMD.

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

Line: 102

                }

  private static final class SerializedForm implements Serializable {
    private final String algorithmName;
    private final int bytes;
    private final String toString;

    private SerializedForm(String algorithmName, int bytes, String toString) {
      this.algorithmName = algorithmName;

            

Reported by PMD.

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

Line: 103

              
  private static final class SerializedForm implements Serializable {
    private final String algorithmName;
    private final int bytes;
    private final String toString;

    private SerializedForm(String algorithmName, int bytes, String toString) {
      this.algorithmName = algorithmName;
      this.bytes = bytes;

            

Reported by PMD.

guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableList.java
15 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 28

               *
 * @author Hayward Chan
 */
abstract class ForwardingImmutableList<E> extends ImmutableList<E> {

  ForwardingImmutableList() {}

  abstract List<E> delegateList();


            

Reported by PMD.

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

Line: 28

               *
 * @author Hayward Chan
 */
abstract class ForwardingImmutableList<E> extends ImmutableList<E> {

  ForwardingImmutableList() {}

  abstract List<E> delegateList();


            

Reported by PMD.

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

Line: 35

                abstract List<E> delegateList();

  public int indexOf(@Nullable Object object) {
    return delegateList().indexOf(object);
  }

  public int lastIndexOf(@Nullable Object object) {
    return delegateList().lastIndexOf(object);
  }

            

Reported by PMD.

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

Line: 39

                }

  public int lastIndexOf(@Nullable Object object) {
    return delegateList().lastIndexOf(object);
  }

  public E get(int index) {
    return delegateList().get(index);
  }

            

Reported by PMD.

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

Line: 43

                }

  public E get(int index) {
    return delegateList().get(index);
  }

  public ImmutableList<E> subList(int fromIndex, int toIndex) {
    return unsafeDelegateList(delegateList().subList(fromIndex, toIndex));
  }

            

Reported by PMD.

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

Line: 47

                }

  public ImmutableList<E> subList(int fromIndex, int toIndex) {
    return unsafeDelegateList(delegateList().subList(fromIndex, toIndex));
  }

  @Override
  public Object[] toArray() {
    // Note that ArrayList.toArray() doesn't work here because it returns E[]

            

Reported by PMD.

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

Line: 59

              
  @Override
  public boolean equals(Object obj) {
    return delegateList().equals(obj);
  }

  @Override
  public int hashCode() {
    return delegateList().hashCode();

            

Reported by PMD.

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

Line: 64

              
  @Override
  public int hashCode() {
    return delegateList().hashCode();
  }

  @Override
  public UnmodifiableIterator<E> iterator() {
    return Iterators.unmodifiableIterator(delegateList().iterator());

            

Reported by PMD.

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

Line: 69

              
  @Override
  public UnmodifiableIterator<E> iterator() {
    return Iterators.unmodifiableIterator(delegateList().iterator());
  }

  @Override
  public boolean contains(@Nullable Object object) {
    return object != null && delegateList().contains(object);

            

Reported by PMD.

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

Line: 74

              
  @Override
  public boolean contains(@Nullable Object object) {
    return object != null && delegateList().contains(object);
  }

  @Override
  public boolean containsAll(Collection<?> targets) {
    return delegateList().containsAll(targets);

            

Reported by PMD.

android/guava-tests/benchmark/com/google/common/math/StatsBenchmark.java
15 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 73

                }

  static class MeanAndVariance {
    private final double mean;
    private final double variance;

    MeanAndVariance(double mean, double variance) {
      this.mean = mean;
      this.variance = variance;

            

Reported by PMD.

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

Line: 74

              
  static class MeanAndVariance {
    private final double mean;
    private final double variance;

    MeanAndVariance(double mean, double variance) {
      this.mean = mean;
      this.variance = variance;
    }

            

Reported by PMD.

Ensure you override both equals() and hashCode()
Error

Line: 82

                  }

    @Override
    public int hashCode() {
      return Doubles.hashCode(mean) * 31 + Doubles.hashCode(variance);
    }
  }

  enum VarianceAlgorithm {

            

Reported by PMD.

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

Line: 144

                }

  @Param({"100", "10000"})
  int n;

  @Param MeanAlgorithm meanAlgorithm;
  @Param VarianceAlgorithm varianceAlgorithm;

  private double[][] values = new double[0x100][];

            

Reported by PMD.

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

Line: 146

                @Param({"100", "10000"})
  int n;

  @Param MeanAlgorithm meanAlgorithm;
  @Param VarianceAlgorithm varianceAlgorithm;

  private double[][] values = new double[0x100][];

  @BeforeExperiment

            

Reported by PMD.

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

Line: 147

                int n;

  @Param MeanAlgorithm meanAlgorithm;
  @Param VarianceAlgorithm varianceAlgorithm;

  private double[][] values = new double[0x100][];

  @BeforeExperiment
  void setUp() {

            

Reported by PMD.

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

Line: 149

                @Param MeanAlgorithm meanAlgorithm;
  @Param VarianceAlgorithm varianceAlgorithm;

  private double[][] values = new double[0x100][];

  @BeforeExperiment
  void setUp() {
    Random rng = new Random();
    for (int i = 0; i < 0x100; i++) {

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 151

              
  private double[][] values = new double[0x100][];

  @BeforeExperiment
  void setUp() {
    Random rng = new Random();
    for (int i = 0; i < 0x100; i++) {
      values[i] = new double[n];
      for (int j = 0; j < n; j++) {

            

Reported by PMD.

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

Line: 166

                int meanAndVariance(int reps) {
    int tmp = 0;
    for (int i = 0; i < reps; i++) {
      tmp += varianceAlgorithm.variance(values[i & 0xFF], meanAlgorithm).hashCode();
    }
    return tmp;
  }
}

            

Reported by PMD.

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

Line: 69

                    }
    };

    abstract double mean(double[] values);
  }

  static class MeanAndVariance {
    private final double mean;
    private final double variance;

            

Reported by PMD.