The following issues were found

android/guava/src/com/google/common/util/concurrent/RateLimiter.java
3 issues
This class has too many methods, consider refactoring it.
Design

Line: 96

              @Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class RateLimiter {
  /**
   * Creates a {@code RateLimiter} with the specified stable throughput, given as "permits per
   * second" (commonly referred to as <i>QPS</i>, queries per second).
   *
   * <p>The returned {@code RateLimiter} ensures that on average no more than {@code

            

Reported by PMD.

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

Line: 185

                 * The underlying timer; used both to measure elapsed time and sleep as necessary. A separate
   * object to facilitate testing.
   */
  private final SleepingStopwatch stopwatch;

  // Can't be initialized in the constructor because mocks don't call the constructor.
  @CheckForNull private volatile Object mutexDoNotUseDirectly;

  private Object mutex() {

            

Reported by PMD.

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

Line: 188

                private final SleepingStopwatch stopwatch;

  // Can't be initialized in the constructor because mocks don't call the constructor.
  @CheckForNull private volatile Object mutexDoNotUseDirectly;

  private Object mutex() {
    Object mutex = mutexDoNotUseDirectly;
    if (mutex == null) {
      synchronized (this) {

            

Reported by PMD.

android/guava/src/com/google/common/collect/ImmutableEnumSet.java
3 issues
Avoid reassigning parameters such as 'collection'
Design

Line: 82

                }

  @Override
  public boolean containsAll(Collection<?> collection) {
    if (collection instanceof ImmutableEnumSet<?>) {
      collection = ((ImmutableEnumSet<?>) collection).delegate;
    }
    return delegate.containsAll(collection);
  }

            

Reported by PMD.

Avoid reassigning parameters such as 'object'
Design

Line: 95

                }

  @Override
  public boolean equals(@CheckForNull Object object) {
    if (object == this) {
      return true;
    }
    if (object instanceof ImmutableEnumSet) {
      object = ((ImmutableEnumSet<?>) object).delegate;

            

Reported by PMD.

Field hashCode has the same name as a method
Error

Line: 110

                  return true;
  }

  @LazyInit private transient int hashCode;

  @Override
  public int hashCode() {
    int result = hashCode;
    return (result == 0) ? hashCode = delegate.hashCode() : result;

            

Reported by PMD.

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

Line: 31

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
  /**
   * Not supported. Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety,
   * instead. This method exists only to hide {@link ImmutableMap#builder} from consumers of {@code
   * ImmutableSortedMap}.
   *

            

Reported by PMD.

The String literal 'Pass keys of type Comparable' appears 4 times in this file; the first occurrence is on line 82
Error

Line: 82

                 * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
   *     ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
   */
  @DoNotCall("Pass keys of type Comparable")
  @Deprecated
  public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
    throw new UnsupportedOperationException();
  }


            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 131

                 */
  @DoNotCall("Pass keys of type Comparable")
  @Deprecated
  public static <K, V> ImmutableSortedMap<K, V> of(
      K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
    throw new UnsupportedOperationException();
  }

  // No copyOf() fauxveride; see ImmutableSortedSetFauxverideShim.

            

Reported by PMD.

android/guava/src/com/google/common/graph/AbstractGraphBuilder.java
3 issues
This abstract class does not have any abstract methods
Design

Line: 27

               * @author James Sexton
 */
@ElementTypesAreNonnullByDefault
abstract class AbstractGraphBuilder<N> {
  final boolean directed;
  boolean allowsSelfLoops = false;
  ElementOrder<N> nodeOrder = ElementOrder.insertion();
  ElementOrder<N> incidentEdgeOrder = ElementOrder.unordered();


            

Reported by PMD.

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

Line: 28

               */
@ElementTypesAreNonnullByDefault
abstract class AbstractGraphBuilder<N> {
  final boolean directed;
  boolean allowsSelfLoops = false;
  ElementOrder<N> nodeOrder = ElementOrder.insertion();
  ElementOrder<N> incidentEdgeOrder = ElementOrder.unordered();

  Optional<Integer> expectedNodeCount = Optional.absent();

            

Reported by PMD.

Avoid using redundant field initializer for 'allowsSelfLoops'
Performance

Line: 29

              @ElementTypesAreNonnullByDefault
abstract class AbstractGraphBuilder<N> {
  final boolean directed;
  boolean allowsSelfLoops = false;
  ElementOrder<N> nodeOrder = ElementOrder.insertion();
  ElementOrder<N> incidentEdgeOrder = ElementOrder.unordered();

  Optional<Integer> expectedNodeCount = Optional.absent();


            

Reported by PMD.

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

Line: 39

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMultisetFauxverideShim<E> extends ImmutableMultiset<E> {
  /**
   * Not supported. Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better
   * type-safety, instead. This method exists only to hide {@link ImmutableMultiset#builder} from
   * consumers of {@code ImmutableSortedMultiset}.
   *

            

Reported by PMD.

The String literal 'Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)' appears 7 times in this file; the first occurrence is on line 63
Error

Line: 63

                 * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
   *     ImmutableSortedMultiset#of(Comparable)}.</b>
   */
  @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
  @Deprecated
  public static <E> ImmutableSortedMultiset<E> of(E element) {
    throw new UnsupportedOperationException();
  }


            

Reported by PMD.

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

Line: 158

                 */
  @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
  @Deprecated
  public static <E> ImmutableSortedMultiset<E> copyOf(E[] elements) {
    throw new UnsupportedOperationException();
  }

  /*
   * We would like to include an unsupported "<E> copyOf(Iterable<E>)" here, providing only the

            

Reported by PMD.

android/guava/src/com/google/common/eventbus/DeadEvent.java
3 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 69

              
  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this).add("source", source).add("event", event).toString();
  }
}

            

Reported by PMD.

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

Line: 69

              
  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this).add("source", source).add("event", event).toString();
  }
}

            

Reported by PMD.

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

Line: 69

              
  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this).add("source", source).add("event", event).toString();
  }
}

            

Reported by PMD.

android/guava/src/com/google/common/io/CountingInputStream.java
3 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 36

              @ElementTypesAreNonnullByDefault
public final class CountingInputStream extends FilterInputStream {

  private long count;
  private long mark = -1;

  /**
   * Wraps another input stream, counting the number of bytes read.
   *

            

Reported by PMD.

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

Line: 37

              public final class CountingInputStream extends FilterInputStream {

  private long count;
  private long mark = -1;

  /**
   * Wraps another input stream, counting the number of bytes read.
   *
   * @param in the input stream to be wrapped

            

Reported by PMD.

Field mark has the same name as a method
Error

Line: 37

              public final class CountingInputStream extends FilterInputStream {

  private long count;
  private long mark = -1;

  /**
   * Wraps another input stream, counting the number of bytes read.
   *
   * @param in the input stream to be wrapped

            

Reported by PMD.

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

Line: 30

              @GwtCompatible
@CanIgnoreReturnValue
@ElementTypesAreNonnullByDefault
final class MathPreconditions {
  static int checkPositive(String role, int x) {
    if (x <= 0) {
      throw new IllegalArgumentException(role + " (" + x + ") must be > 0");
    }
    return x;

            

Reported by PMD.

The String literal ') must be >= 0' appears 4 times in this file; the first occurrence is on line 54
Error

Line: 54

              
  static int checkNonNegative(String role, int x) {
    if (x < 0) {
      throw new IllegalArgumentException(role + " (" + x + ") must be >= 0");
    }
    return x;
  }

  static long checkNonNegative(String role, long x) {

            

Reported by PMD.

Use opposite operator instead of the logic complement operator.
Design

Line: 74

                }

  static double checkNonNegative(String role, double x) {
    if (!(x >= 0)) { // not x < 0, to work with NaN.
      throw new IllegalArgumentException(role + " (" + x + ") must be >= 0");
    }
    return x;
  }


            

Reported by PMD.

android/guava-tests/test/com/google/common/escape/CharEscaperBuilderTest.java
3 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: 23

              
public class CharEscaperBuilderTest extends TestCase {

  public void testAddEscapes() {
    char[] cs = {'a', 'b', 'c'};
    CharEscaperBuilder builder = new CharEscaperBuilder().addEscapes(cs, "Z");
    Escaper escaper = builder.toEscaper();
    assertEquals("ZZZdef", escaper.escape("abcdef"));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                  char[] cs = {'a', 'b', 'c'};
    CharEscaperBuilder builder = new CharEscaperBuilder().addEscapes(cs, "Z");
    Escaper escaper = builder.toEscaper();
    assertEquals("ZZZdef", escaper.escape("abcdef"));
  }
}

            

Reported by PMD.

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

Line: 27

                  char[] cs = {'a', 'b', 'c'};
    CharEscaperBuilder builder = new CharEscaperBuilder().addEscapes(cs, "Z");
    Escaper escaper = builder.toEscaper();
    assertEquals("ZZZdef", escaper.escape("abcdef"));
  }
}

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/SetRemoveTester.java
3 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: 36

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetRemoveTester<E> extends AbstractSetTester<E> {
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemove_present() {
    getSet().remove(e0());
    assertFalse(
        "After remove(present) a set should not contain the removed element.",

            

Reported by PMD.

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

Line: 39

                @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemove_present() {
    getSet().remove(e0());
    assertFalse(
        "After remove(present) a set should not contain the removed element.",
        getSet().contains(e0()));
  }
}

            

Reported by PMD.

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

Line: 42

                  getSet().remove(e0());
    assertFalse(
        "After remove(present) a set should not contain the removed element.",
        getSet().contains(e0()));
  }
}

            

Reported by PMD.