The following issues were found

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

Line: 33

              /** @author Colin Decker */
public class TestOutputStream extends FilterOutputStream {

  private final ImmutableSet<TestOption> options;
  private boolean closed;

  public TestOutputStream(OutputStream out, TestOption... options) throws IOException {
    this(out, Arrays.asList(options));
  }

            

Reported by PMD.

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

Line: 34

              public class TestOutputStream extends FilterOutputStream {

  private final ImmutableSet<TestOption> options;
  private boolean closed;

  public TestOutputStream(OutputStream out, TestOption... options) throws IOException {
    this(out, Arrays.asList(options));
  }


            

Reported by PMD.

Field closed has the same name as a method
Error

Line: 34

              public class TestOutputStream extends FilterOutputStream {

  private final ImmutableSet<TestOption> options;
  private boolean closed;

  public TestOutputStream(OutputStream out, TestOption... options) throws IOException {
    this(out, Arrays.asList(options));
  }


            

Reported by PMD.

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.

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

Line: 29

              @ElementTypesAreNonnullByDefault
final class NullsFirstOrdering<T extends @Nullable Object> extends Ordering<@Nullable T>
    implements Serializable {
  final Ordering<? super T> ordering;

  NullsFirstOrdering(Ordering<? super T> ordering) {
    this.ordering = ordering;
  }


            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 37

              
  @Override
  public int compare(@CheckForNull T left, @CheckForNull T right) {
    if (left == right) {
      return 0;
    }
    if (left == null) {
      return RIGHT_IS_GREATER;
    }

            

Reported by PMD.

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

Line: 53

                @SuppressWarnings("nullness") // should be safe, but not sure if we can avoid the warning
  public <S extends @Nullable T> Ordering<S> reverse() {
    // ordering.reverse() might be optimized, so let it do its thing
    return ordering.reverse().nullsLast();
  }

  @SuppressWarnings("unchecked") // still need the right way to explain this
  @Override
  public <S extends T> Ordering<@Nullable S> nullsFirst() {

            

Reported by PMD.

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

Line: 29

              @ElementTypesAreNonnullByDefault
final class NullsLastOrdering<T extends @Nullable Object> extends Ordering<@Nullable T>
    implements Serializable {
  final Ordering<? super T> ordering;

  NullsLastOrdering(Ordering<? super T> ordering) {
    this.ordering = ordering;
  }


            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 37

              
  @Override
  public int compare(@CheckForNull T left, @CheckForNull T right) {
    if (left == right) {
      return 0;
    }
    if (left == null) {
      return LEFT_IS_GREATER;
    }

            

Reported by PMD.

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

Line: 53

                @SuppressWarnings("nullness") // should be safe, but not sure if we can avoid the warning
  public <S extends @Nullable T> Ordering<S> reverse() {
    // ordering.reverse() might be optimized, so let it do its thing
    return ordering.reverse().nullsFirst();
  }

  @Override
  public <S extends T> Ordering<@Nullable S> nullsFirst() {
    return ordering.<S>nullsFirst();

            

Reported by PMD.

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

Line: 42

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet<E> {
  /**
   * Not supported. Use {@link ImmutableSortedSet#toImmutableSortedSet} instead. This method exists
   * only to hide {@link ImmutableSet#toImmutableSet} from consumers of {@code ImmutableSortedSet}.
   *
   * @throws UnsupportedOperationException always

            

Reported by PMD.

The String literal 'Pass parameters of type Comparable' appears 6 times in this file; the first occurrence is on line 108
Error

Line: 108

                 * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
   *     ImmutableSortedSet#of(Comparable, Comparable)}.</b>
   */
  @DoNotCall("Pass parameters of type Comparable")
  @Deprecated
  public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
    throw new UnsupportedOperationException();
  }


            

Reported by PMD.

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

Line: 186

                 */
  @DoNotCall("Pass parameters of type Comparable")
  @Deprecated
  public static <E> ImmutableSortedSet<E> copyOf(E[] elements) {
    throw new UnsupportedOperationException();
  }

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

            

Reported by PMD.

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

Line: 43

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMultisetFauxverideShim<E> extends ImmutableMultiset<E> {
  /**
   * Not supported. Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset} instead. This
   * method exists only to hide {@link ImmutableMultiset#toImmutableMultiset} 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 100
Error

Line: 100

                 * @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: 195

                 */
  @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.

guava/src/com/google/common/collect/RegularImmutableList.java
3 issues
The user-supplied array 'array' is stored directly.
Design

Line: 38

              
  @VisibleForTesting final transient Object[] array;

  RegularImmutableList(Object[] array) {
    this.array = array;
  }

  @Override
  public int size() {

            

Reported by PMD.

Returning 'array' may expose an internal array.
Design

Line: 54

              
  @Override
  Object[] internalArray() {
    return array;
  }

  @Override
  int internalArrayStart() {
    return 0;

            

Reported by PMD.

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

Line: 38

              
  @VisibleForTesting final transient Object[] array;

  RegularImmutableList(Object[] array) {
    this.array = array;
  }

  @Override
  public int size() {

            

Reported by PMD.

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

Line: 35

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
  /**
   * Not supported. Use {@link ImmutableSortedMap#toImmutableSortedMap}, which offers better
   * type-safety, instead. This method exists only to hide {@link ImmutableMap#toImmutableMap} 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 121
Error

Line: 121

                 * @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: 170

                 */
  @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.

guava/src/com/google/common/collect/SingletonImmutableBiMap.java
3 issues
Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 46

                  checkEntryNotNull(singleKey, singleValue);
    this.singleKey = singleKey;
    this.singleValue = singleValue;
    this.inverse = null;
  }

  private SingletonImmutableBiMap(K singleKey, V singleValue, ImmutableBiMap<V, K> inverse) {
    this.singleKey = singleKey;
    this.singleValue = singleValue;

            

Reported by PMD.

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

Line: 68

              
  @Override
  public void forEach(BiConsumer<? super K, ? super V> action) {
    checkNotNull(action).accept(singleKey, singleValue);
  }

  @Override
  public boolean containsKey(@CheckForNull Object key) {
    return singleKey.equals(key);

            

Reported by PMD.

Field inverse has the same name as a method
Error

Line: 96

                  return ImmutableSet.of(singleKey);
  }

  @CheckForNull private final transient ImmutableBiMap<V, K> inverse;
  @LazyInit @RetainedWith @CheckForNull private transient ImmutableBiMap<V, K> lazyInverse;

  @Override
  public ImmutableBiMap<V, K> inverse() {
    if (inverse != null) {

            

Reported by PMD.

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

Line: 37

               */
@GwtIncompatible // unnecessary
@ElementTypesAreNonnullByDefault
class ImmutableMapEntry<K, V> extends ImmutableEntry<K, V> {
  /**
   * Creates an {@code ImmutableMapEntry} array to hold parameterized entries. The result must never
   * be upcast back to ImmutableMapEntry[] (or Object[], etc.), or allowed to escape the class.
   *
   * <p>The returned array has all its elements set to their initial null values. However, we don't

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 80

                  return true;
  }

  static class NonTerminalImmutableMapEntry<K, V> extends ImmutableMapEntry<K, V> {
    /*
     * Yes, we sometimes set nextInKeyBucket to null, even for this "non-terminal" entry. We don't
     * do that with a plain NonTerminalImmutableMapEntry, but we do do it with the BiMap-specific
     * subclass below. That's because the Entry might be non-terminal in the key bucket but terminal
     * in the value bucket (or vice versa).

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 107

                  }
  }

  static final class NonTerminalImmutableBiMapEntry<K, V>
      extends NonTerminalImmutableMapEntry<K, V> {
    @CheckForNull private final transient ImmutableMapEntry<K, V> nextInValueBucket;

    NonTerminalImmutableBiMapEntry(
        K key,

            

Reported by PMD.