The following issues were found

android/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java
6 issues
This class has too many methods, consider refactoring it.
Design

Line: 48

               */
@GwtIncompatible
class SameThreadScheduledExecutorService extends AbstractExecutorService
    implements ListeningScheduledExecutorService {

  private final ListeningExecutorService delegate = newDirectExecutorService();

  @Override
  public void shutdown() {

            

Reported by PMD.

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

Line: 50

              class SameThreadScheduledExecutorService extends AbstractExecutorService
    implements ListeningScheduledExecutorService {

  private final ListeningExecutorService delegate = newDirectExecutorService();

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

            

Reported by PMD.

The String literal 'unit must not be null!' appears 7 times in this file; the first occurrence is on line 74
Error

Line: 74

              
  @Override
  public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
    Preconditions.checkNotNull(unit, "unit must not be null!");
    return delegate.awaitTermination(timeout, unit);
  }

  @Override
  public <T> ListenableFuture<T> submit(Callable<T> task) {

            

Reported by PMD.

The String literal 'tasks must not be null!' appears 4 times in this file; the first occurrence is on line 100
Error

Line: 100

                @Override
  public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
      throws InterruptedException {
    Preconditions.checkNotNull(tasks, "tasks must not be null!");
    return delegate.invokeAll(tasks);
  }

  @Override
  public <T> List<Future<T>> invokeAll(

            

Reported by PMD.

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

Line: 138

                public ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
    Preconditions.checkNotNull(command, "command must not be null");
    Preconditions.checkNotNull(unit, "unit must not be null!");
    return schedule(java.util.concurrent.Executors.callable(command), delay, unit);
  }

  @Override
  public <V> ListenableScheduledFuture<V> schedule(
      final Callable<V> callable, long delay, TimeUnit unit) {

            

Reported by PMD.

Avoid unused private fields such as 'exception'.
Design

Line: 152

              
  private static class ImmediateScheduledFuture<V> extends SimpleForwardingListenableFuture<V>
      implements ListenableScheduledFuture<V> {
    private ExecutionException exception;

    protected ImmediateScheduledFuture(ListenableFuture<V> future) {
      super(future);
    }


            

Reported by PMD.

android/guava-testlib/src/com/google/common/testing/EqualsTester.java
6 issues
Avoid using equals() to compare against null
Error

Line: 121

              
  private void testItems() {
    for (Object item : Iterables.concat(equalityGroups)) {
      assertTrue(item + " must not be Object#equals to null", !item.equals(null));
      assertTrue(
          item + " must not be Object#equals to an arbitrary object of another class",
          !item.equals(NotAnInstance.EQUAL_TO_NOTHING));
      assertEquals(item + " must be Object#equals to itself", item, item);
      assertEquals(

            

Reported by PMD.

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

Line: 82

              public final class EqualsTester {
  private static final int REPETITIONS = 3;

  private final List<List<Object>> equalityGroups = Lists.newArrayList();
  private final RelationshipTester.ItemReporter itemReporter;

  /** Constructs an empty EqualsTester instance */
  public EqualsTester() {
    this(new RelationshipTester.ItemReporter());

            

Reported by PMD.

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

Line: 83

                private static final int REPETITIONS = 3;

  private final List<List<Object>> equalityGroups = Lists.newArrayList();
  private final RelationshipTester.ItemReporter itemReporter;

  /** Constructs an empty EqualsTester instance */
  public EqualsTester() {
    this(new RelationshipTester.ItemReporter());
  }

            

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

                }

  /** Run tests on equals method, throwing a failure on an invalid test */
  public EqualsTester testEquals() {
    RelationshipTester<Object> delegate =
        new RelationshipTester<>(
            Equivalence.equals(), "Object#equals", "Object#hashCode", itemReporter);
    for (List<Object> group : equalityGroups) {
      delegate.addRelatedGroup(group);

            

Reported by PMD.

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

Line: 119

                  return this;
  }

  private void testItems() {
    for (Object item : Iterables.concat(equalityGroups)) {
      assertTrue(item + " must not be Object#equals to null", !item.equals(null));
      assertTrue(
          item + " must not be Object#equals to an arbitrary object of another class",
          !item.equals(NotAnInstance.EQUAL_TO_NOTHING));

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '106'-'117').
Error

Line: 106

              
  /** Run tests on equals method, throwing a failure on an invalid test */
  public EqualsTester testEquals() {
    RelationshipTester<Object> delegate =
        new RelationshipTester<>(
            Equivalence.equals(), "Object#equals", "Object#hashCode", itemReporter);
    for (List<Object> group : equalityGroups) {
      delegate.addRelatedGroup(group);
    }

            

Reported by PMD.

guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
6 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 29

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class DescendingImmutableSortedSet<E> extends ImmutableSortedSet<E> {
  private final ImmutableSortedSet<E> forward;

  DescendingImmutableSortedSet(ImmutableSortedSet<E> forward) {
    super(Ordering.from(forward.comparator()).reverse());
    this.forward = forward;

            

Reported by PMD.

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

Line: 29

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class DescendingImmutableSortedSet<E> extends ImmutableSortedSet<E> {
  private final ImmutableSortedSet<E> forward;

  DescendingImmutableSortedSet(ImmutableSortedSet<E> forward) {
    super(Ordering.from(forward.comparator()).reverse());
    this.forward = forward;

            

Reported by PMD.

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

Line: 30

              @GwtIncompatible
@ElementTypesAreNonnullByDefault
final class DescendingImmutableSortedSet<E> extends ImmutableSortedSet<E> {
  private final ImmutableSortedSet<E> forward;

  DescendingImmutableSortedSet(ImmutableSortedSet<E> forward) {
    super(Ordering.from(forward.comparator()).reverse());
    this.forward = forward;
  }

            

Reported by PMD.

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

Line: 54

              
  @Override
  ImmutableSortedSet<E> headSetImpl(E toElement, boolean inclusive) {
    return forward.tailSet(toElement, inclusive).descendingSet();
  }

  @Override
  ImmutableSortedSet<E> subSetImpl(
      E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {

            

Reported by PMD.

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

Line: 60

                @Override
  ImmutableSortedSet<E> subSetImpl(
      E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
    return forward.subSet(toElement, toInclusive, fromElement, fromInclusive).descendingSet();
  }

  @Override
  ImmutableSortedSet<E> tailSetImpl(E fromElement, boolean inclusive) {
    return forward.headSet(fromElement, inclusive).descendingSet();

            

Reported by PMD.

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

Line: 65

              
  @Override
  ImmutableSortedSet<E> tailSetImpl(E fromElement, boolean inclusive) {
    return forward.headSet(fromElement, inclusive).descendingSet();
  }

  @Override
  @GwtIncompatible("NavigableSet")
  public ImmutableSortedSet<E> descendingSet() {

            

Reported by PMD.

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

Line: 59

              
  @Override
  public ImmutableSortedSet<E> elementSet() {
    return forward.elementSet().descendingSet();
  }

  @Override
  Entry<E> getEntry(int index) {
    return forward.entrySet().asList().reverse().get(index);

            

Reported by PMD.

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

Line: 64

              
  @Override
  Entry<E> getEntry(int index) {
    return forward.entrySet().asList().reverse().get(index);
  }

  @Override
  public ImmutableSortedMultiset<E> descendingMultiset() {
    return forward;

            

Reported by PMD.

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

Line: 64

              
  @Override
  Entry<E> getEntry(int index) {
    return forward.entrySet().asList().reverse().get(index);
  }

  @Override
  public ImmutableSortedMultiset<E> descendingMultiset() {
    return forward;

            

Reported by PMD.

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

Line: 64

              
  @Override
  Entry<E> getEntry(int index) {
    return forward.entrySet().asList().reverse().get(index);
  }

  @Override
  public ImmutableSortedMultiset<E> descendingMultiset() {
    return forward;

            

Reported by PMD.

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

Line: 74

              
  @Override
  public ImmutableSortedMultiset<E> headMultiset(E upperBound, BoundType boundType) {
    return forward.tailMultiset(upperBound, boundType).descendingMultiset();
  }

  @Override
  public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) {
    return forward.headMultiset(lowerBound, boundType).descendingMultiset();

            

Reported by PMD.

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

Line: 79

              
  @Override
  public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) {
    return forward.headMultiset(lowerBound, boundType).descendingMultiset();
  }

  @Override
  boolean isPartialView() {
    return forward.isPartialView();

            

Reported by PMD.

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

Line: 48

              @GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractMultiset<E extends @Nullable Object> extends AbstractCollection<E>
    implements Multiset<E> {
  // Query Operations

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

            

Reported by PMD.

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

Line: 53

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

  @Override
  public boolean contains(@CheckForNull Object element) {
    return count(element) > 0;

            

Reported by PMD.

Field elementSet has the same name as a method
Error

Line: 130

              
  // Views

  @LazyInit @CheckForNull private transient Set<E> elementSet;

  @Override
  public Set<E> elementSet() {
    Set<E> result = elementSet;
    if (result == null) {

            

Reported by PMD.

Field entrySet has the same name as a method
Error

Line: 164

              
  abstract Iterator<E> elementIterator();

  @LazyInit @CheckForNull private transient Set<Entry<E>> entrySet;

  @Override
  public Set<Entry<E>> entrySet() {
    Set<Entry<E>> result = entrySet;
    if (result == null) {

            

Reported by PMD.

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

Line: 221

                 */
  @Override
  public final int hashCode() {
    return entrySet().hashCode();
  }

  /**
   * {@inheritDoc}
   *

            

Reported by PMD.

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

Line: 232

                 */
  @Override
  public final String toString() {
    return entrySet().toString();
  }
}

            

Reported by PMD.

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

Line: 38

              @GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
    extends IteratorBasedAbstractMap<K, V> implements NavigableMap<K, V> {

  @Override
  @CheckForNull
  public abstract V get(@CheckForNull Object key);


            

Reported by PMD.

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

Line: 93

                @Override
  @CheckForNull
  public Entry<K, V> lowerEntry(@ParametricNullness K key) {
    return headMap(key, false).lastEntry();
  }

  @Override
  @CheckForNull
  public Entry<K, V> floorEntry(@ParametricNullness K key) {

            

Reported by PMD.

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

Line: 99

                @Override
  @CheckForNull
  public Entry<K, V> floorEntry(@ParametricNullness K key) {
    return headMap(key, true).lastEntry();
  }

  @Override
  @CheckForNull
  public Entry<K, V> ceilingEntry(@ParametricNullness K key) {

            

Reported by PMD.

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

Line: 105

                @Override
  @CheckForNull
  public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
    return tailMap(key, true).firstEntry();
  }

  @Override
  @CheckForNull
  public Entry<K, V> higherEntry(@ParametricNullness K key) {

            

Reported by PMD.

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

Line: 111

                @Override
  @CheckForNull
  public Entry<K, V> higherEntry(@ParametricNullness K key) {
    return tailMap(key, false).firstEntry();
  }

  @Override
  @CheckForNull
  public K lowerKey(@ParametricNullness K key) {

            

Reported by PMD.

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

Line: 167

              
  @Override
  public NavigableSet<K> descendingKeySet() {
    return descendingMap().navigableKeySet();
  }

  @Override
  public NavigableMap<K, V> descendingMap() {
    return new DescendingMap();

            

Reported by PMD.

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

Line: 27

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractRangeSet<C extends Comparable> implements RangeSet<C> {
  AbstractRangeSet() {}

  @Override
  public boolean contains(C value) {
    return rangeContaining(value) != null;

            

Reported by PMD.

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

Line: 41

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

  @Override
  public void add(Range<C> range) {
    throw new UnsupportedOperationException();

            

Reported by PMD.

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

Line: 76

              
  @Override
  public boolean intersects(Range<C> otherRange) {
    return !subRangeSet(otherRange).isEmpty();
  }

  @Override
  public abstract boolean encloses(Range<C> otherRange);


            

Reported by PMD.

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

Line: 88

                    return true;
    } else if (obj instanceof RangeSet) {
      RangeSet<?> other = (RangeSet<?>) obj;
      return this.asRanges().equals(other.asRanges());
    }
    return false;
  }

  @Override

            

Reported by PMD.

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

Line: 95

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

  @Override
  public final String toString() {
    return asRanges().toString();

            

Reported by PMD.

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

Line: 100

              
  @Override
  public final String toString() {
    return asRanges().toString();
  }
}

            

Reported by PMD.

guava/src/com/google/common/io/CharSequenceReader.java
6 issues
This class has too many methods, consider refactoring it.
Design

Line: 37

              // TODO(cgdecker): make this public? as a type, or a method in CharStreams?
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class CharSequenceReader extends Reader {

  @CheckForNull private CharSequence seq;
  private int pos;
  private int mark;


            

Reported by PMD.

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

Line: 39

              @ElementTypesAreNonnullByDefault
final class CharSequenceReader extends Reader {

  @CheckForNull private CharSequence seq;
  private int pos;
  private int mark;

  /** Creates a new reader wrapping the given character sequence. */
  public CharSequenceReader(CharSequence seq) {

            

Reported by PMD.

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

Line: 40

              final class CharSequenceReader extends Reader {

  @CheckForNull private CharSequence seq;
  private int pos;
  private int mark;

  /** Creates a new reader wrapping the given character sequence. */
  public CharSequenceReader(CharSequence seq) {
    this.seq = checkNotNull(seq);

            

Reported by PMD.

Field mark has the same name as a method
Error

Line: 41

              
  @CheckForNull private CharSequence seq;
  private int pos;
  private int mark;

  /** Creates a new reader wrapping the given character sequence. */
  public CharSequenceReader(CharSequence seq) {
    this.seq = checkNotNull(seq);
  }

            

Reported by PMD.

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

Line: 41

              
  @CheckForNull private CharSequence seq;
  private int pos;
  private int mark;

  /** Creates a new reader wrapping the given character sequence. */
  public CharSequenceReader(CharSequence seq) {
    this.seq = checkNotNull(seq);
  }

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 147

              
  @Override
  public synchronized void close() throws IOException {
    seq = null;
  }
}

            

Reported by PMD.

guava/src/com/google/common/util/concurrent/ForwardingLock.java
6 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 28

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

  @Override
  public void lockInterruptibly() throws InterruptedException {
    delegate().lockInterruptibly();

            

Reported by PMD.

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

Line: 33

              
  @Override
  public void lockInterruptibly() throws InterruptedException {
    delegate().lockInterruptibly();
  }

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

            

Reported by PMD.

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

Line: 38

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

  @Override
  public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
    return delegate().tryLock(time, unit);

            

Reported by PMD.

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

Line: 43

              
  @Override
  public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
    return delegate().tryLock(time, unit);
  }

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

            

Reported by PMD.

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

Line: 48

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

  @Override
  public Condition newCondition() {
    return delegate().newCondition();

            

Reported by PMD.

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

Line: 53

              
  @Override
  public Condition newCondition() {
    return delegate().newCondition();
  }
}

            

Reported by PMD.

guava/src/com/google/common/collect/ImmutableMapKeySet.java
6 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 36

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class ImmutableMapKeySet<K, V> extends IndexedImmutableSet<K> {
  private final ImmutableMap<K, V> map;

  ImmutableMapKeySet(ImmutableMap<K, V> map) {
    this.map = map;
  }

            

Reported by PMD.

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

Line: 37

              @GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class ImmutableMapKeySet<K, V> extends IndexedImmutableSet<K> {
  private final ImmutableMap<K, V> map;

  ImmutableMapKeySet(ImmutableMap<K, V> map) {
    this.map = map;
  }


            

Reported by PMD.

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

Line: 65

              
  @Override
  K get(int index) {
    return map.entrySet().asList().get(index).getKey();
  }

  @Override
  public void forEach(Consumer<? super K> action) {
    checkNotNull(action);

            

Reported by PMD.

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

Line: 65

              
  @Override
  K get(int index) {
    return map.entrySet().asList().get(index).getKey();
  }

  @Override
  public void forEach(Consumer<? super K> action) {
    checkNotNull(action);

            

Reported by PMD.

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

Line: 65

              
  @Override
  K get(int index) {
    return map.entrySet().asList().get(index).getKey();
  }

  @Override
  public void forEach(Consumer<? super K> action) {
    checkNotNull(action);

            

Reported by PMD.

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

Line: 83

                @GwtIncompatible // serialization
  @SuppressWarnings("unused")
  private static class KeySetSerializedForm<K> implements Serializable {
    final ImmutableMap<K, ?> map;

    KeySetSerializedForm(ImmutableMap<K, ?> map) {
      this.map = map;
    }


            

Reported by PMD.