The following issues were found

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

Line: 53

               */
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactLinkedHashSet<E extends @Nullable Object> extends CompactHashSet<E> {

  /** Creates an empty {@code CompactLinkedHashSet} instance. */
  public static <E extends @Nullable Object> CompactLinkedHashSet<E> create() {
    return new CompactLinkedHashSet<>();
  }

            

Reported by PMD.

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

Line: 53

               */
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactLinkedHashSet<E extends @Nullable Object> extends CompactHashSet<E> {

  /** Creates an empty {@code CompactLinkedHashSet} instance. */
  public static <E extends @Nullable Object> CompactLinkedHashSet<E> create() {
    return new CompactLinkedHashSet<>();
  }

            

Reported by PMD.

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

Line: 70

                public static <E extends @Nullable Object> CompactLinkedHashSet<E> create(
      Collection<? extends E> collection) {
    CompactLinkedHashSet<E> set = createWithExpectedSize(collection.size());
    set.addAll(collection);
    return set;
  }

  /**
   * Creates a {@code CompactLinkedHashSet} instance containing the given elements in unspecified

            

Reported by PMD.

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

Line: 153

                @CanIgnoreReturnValue
  Set<E> convertToHashFloodingResistantImplementation() {
    Set<E> result = super.convertToHashFloodingResistantImplementation();
    this.predecessor = null;
    this.successor = null;
    return result;
  }

  /*

            

Reported by PMD.

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

Line: 154

                Set<E> convertToHashFloodingResistantImplementation() {
    Set<E> result = super.convertToHashFloodingResistantImplementation();
    this.predecessor = null;
    this.successor = null;
    return result;
  }

  /*
   * For discussion of the safety of the following methods for operating on predecessors and

            

Reported by PMD.

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

Line: 40

              @ElementTypesAreNonnullByDefault
final class EdgesConnecting<E> extends AbstractSet<E> {

  private final Map<?, E> nodeToOutEdge;
  private final Object targetNode;

  EdgesConnecting(Map<?, E> nodeToEdgeMap, Object targetNode) {
    this.nodeToOutEdge = checkNotNull(nodeToEdgeMap);
    this.targetNode = checkNotNull(targetNode);

            

Reported by PMD.

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

Line: 41

              final class EdgesConnecting<E> extends AbstractSet<E> {

  private final Map<?, E> nodeToOutEdge;
  private final Object targetNode;

  EdgesConnecting(Map<?, E> nodeToEdgeMap, Object targetNode) {
    this.nodeToOutEdge = checkNotNull(nodeToEdgeMap);
    this.targetNode = checkNotNull(targetNode);
  }

            

Reported by PMD.

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

Line: 52

                public UnmodifiableIterator<E> iterator() {
    E connectingEdge = getConnectingEdge();
    return (connectingEdge == null)
        ? ImmutableSet.<E>of().iterator()
        : Iterators.singletonIterator(connectingEdge);
  }

  @Override
  public int size() {

            

Reported by PMD.

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

Line: 52

                public UnmodifiableIterator<E> iterator() {
    E connectingEdge = getConnectingEdge();
    return (connectingEdge == null)
        ? ImmutableSet.<E>of().iterator()
        : Iterators.singletonIterator(connectingEdge);
  }

  @Override
  public int size() {

            

Reported by PMD.

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

Line: 64

                @Override
  public boolean contains(@CheckForNull Object edge) {
    E connectingEdge = getConnectingEdge();
    return (connectingEdge != null && connectingEdge.equals(edge));
  }

  @CheckForNull
  private E getConnectingEdge() {
    return nodeToOutEdge.get(targetNode);

            

Reported by PMD.

android/guava/src/com/google/common/base/Defaults.java
5 issues
The class 'Defaults' has a Standard Cyclomatic Complexity of 6 (Highest = 10).
Design

Line: 30

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Defaults {
  private Defaults() {}

  private static final Double DOUBLE_DEFAULT = 0d;
  private static final Float FLOAT_DEFAULT = 0f;


            

Reported by PMD.

The class 'Defaults' has a Modified Cyclomatic Complexity of 6 (Highest = 10).
Design

Line: 30

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Defaults {
  private Defaults() {}

  private static final Double DOUBLE_DEFAULT = 0d;
  private static final Float FLOAT_DEFAULT = 0f;


            

Reported by PMD.

The method 'defaultValue(Class)' has a cyclomatic complexity of 10.
Design

Line: 43

                 */
  @SuppressWarnings("unchecked")
  @CheckForNull
  public static <T> T defaultValue(Class<T> type) {
    checkNotNull(type);
    if (type.isPrimitive()) {
      if (type == boolean.class) {
        return (T) Boolean.FALSE;
      } else if (type == char.class) {

            

Reported by PMD.

The method 'defaultValue' has a Standard Cyclomatic Complexity of 10.
Design

Line: 43

                 */
  @SuppressWarnings("unchecked")
  @CheckForNull
  public static <T> T defaultValue(Class<T> type) {
    checkNotNull(type);
    if (type.isPrimitive()) {
      if (type == boolean.class) {
        return (T) Boolean.FALSE;
      } else if (type == char.class) {

            

Reported by PMD.

The method 'defaultValue' has a Modified Cyclomatic Complexity of 10.
Design

Line: 43

                 */
  @SuppressWarnings("unchecked")
  @CheckForNull
  public static <T> T defaultValue(Class<T> type) {
    checkNotNull(type);
    if (type.isPrimitive()) {
      if (type == boolean.class) {
        return (T) Boolean.FALSE;
      } else if (type == char.class) {

            

Reported by PMD.

android/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java
5 issues
All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 25

              
/** Parser for a map of reversed domain names stored as a serialized radix tree. */
@GwtCompatible
final class TrieParser {
  private static final Joiner PREFIX_JOINER = Joiner.on("");

  /**
   * Parses a serialized trie representation of a map of reversed public suffixes into an immutable
   * map of public suffixes.

            

Reported by PMD.

The method 'doParseTrieToBuilder(Deque, CharSequence, int, ImmutableMap.Builder)' has a cyclomatic complexity of 17.
Design

Line: 52

                 * @param builder A map builder to which all entries will be added.
   * @return The number of characters consumed from {@code encoded}.
   */
  private static int doParseTrieToBuilder(
      Deque<CharSequence> stack,
      CharSequence encoded,
      int start,
      ImmutableMap.Builder<String, PublicSuffixType> builder) {


            

Reported by PMD.

The method 'doParseTrieToBuilder(Deque, CharSequence, int, ImmutableMap.Builder)' has an NPath complexity of 252, current threshold is 200
Design

Line: 52

                 * @param builder A map builder to which all entries will be added.
   * @return The number of characters consumed from {@code encoded}.
   */
  private static int doParseTrieToBuilder(
      Deque<CharSequence> stack,
      CharSequence encoded,
      int start,
      ImmutableMap.Builder<String, PublicSuffixType> builder) {


            

Reported by PMD.

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

Line: 78

                    // ':' represents an interior node that represents a private entry in the map
      // ',' represents a leaf node, which represents a private entry in the map.
      String domain = PREFIX_JOINER.join(stack);
      if (domain.length() > 0) {
        builder.put(domain, PublicSuffixType.fromCode(c));
      }
    }
    idx++;


            

Reported by PMD.

Found 'DD'-anomaly for variable 'c' (lines '60'-'64').
Error

Line: 60

              
    int encodedLen = encoded.length();
    int idx = start;
    char c = '\0';

    // Read all of the characters for this node.
    for (; idx < encodedLen; idx++) {
      c = encoded.charAt(idx);
      if (c == '&' || c == '?' || c == '!' || c == ':' || c == ',') {

            

Reported by PMD.

android/guava/src/com/google/common/reflect/TypeVisitor.java
5 issues
This abstract class does not have any abstract methods
Design

Line: 58

               * @author Ben Yu
 */
@ElementTypesAreNonnullByDefault
abstract class TypeVisitor {

  private final Set<Type> visited = Sets.newHashSet();

  /**
   * Visits the given types. Null types are ignored. This allows subclasses to call {@code

            

Reported by PMD.

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

Line: 60

              @ElementTypesAreNonnullByDefault
abstract class TypeVisitor {

  private final Set<Type> visited = Sets.newHashSet();

  /**
   * Visits the given types. Null types are ignored. This allows subclasses to call {@code
   * visit(parameterizedType.getOwnerType())} safely without having to check nulls.
   */

            

Reported by PMD.

The method 'visit(Type...)' has a cyclomatic complexity of 11.
Design

Line: 66

                 * Visits the given types. Null types are ignored. This allows subclasses to call {@code
   * visit(parameterizedType.getOwnerType())} safely without having to check nulls.
   */
  public final void visit(@Nullable Type... types) {
    for (Type type : types) {
      if (type == null || !visited.add(type)) {
        // null owner type, or already visited;
        continue;
      }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'succeeded' (lines '72'-'94').
Error

Line: 72

                      // null owner type, or already visited;
        continue;
      }
      boolean succeeded = false;
      try {
        if (type instanceof TypeVariable) {
          visitTypeVariable((TypeVariable<?>) type);
        } else if (type instanceof WildcardType) {
          visitWildcardType((WildcardType) type);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'succeeded' (lines '72'-'87').
Error

Line: 72

                      // null owner type, or already visited;
        continue;
      }
      boolean succeeded = false;
      try {
        if (type instanceof TypeVariable) {
          visitTypeVariable((TypeVariable<?>) type);
        } else if (type instanceof WildcardType) {
          visitWildcardType((WildcardType) type);

            

Reported by PMD.

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

Line: 62

                @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
  @Override
  public boolean offer(@ParametricNullness E o) {
    return delegate().offer(o);
  }

  @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
  @Override
  @CheckForNull

            

Reported by PMD.

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

Line: 69

                @Override
  @CheckForNull
  public E poll() {
    return delegate().poll();
  }

  @CanIgnoreReturnValue
  @Override
  @ParametricNullness

            

Reported by PMD.

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

Line: 76

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

  @Override
  @CheckForNull
  public E peek() {

            

Reported by PMD.

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

Line: 82

                @Override
  @CheckForNull
  public E peek() {
    return delegate().peek();
  }

  @Override
  @ParametricNullness
  public E element() {

            

Reported by PMD.

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

Line: 88

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

  /**
   * A sensible definition of {@link #offer} in terms of {@link #add}. If you override {@link #add},
   * you may wish to override {@link #offer} to forward to this implementation.

            

Reported by PMD.

android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java
5 issues
Class contains multiple getInstance methods. Please review.
Error

Line: 32

               * @since 13.0
 */
@Beta
public final class ImmutableTypeToInstanceMap<B> extends ForwardingMap<TypeToken<? extends B>, B>
    implements TypeToInstanceMap<B> {

  /** Returns an empty type to instance map. */
  public static <B> ImmutableTypeToInstanceMap<B> of() {
    return new ImmutableTypeToInstanceMap<B>(ImmutableMap.<TypeToken<? extends B>, B>of());

            

Reported by PMD.

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

Line: 63

                 */
  @Beta
  public static final class Builder<B> {
    private final ImmutableMap.Builder<TypeToken<? extends B>, B> mapBuilder =
        ImmutableMap.builder();

    private Builder() {}

    /**

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 98

                  }
  }

  private final ImmutableMap<TypeToken<? extends B>, B> delegate;

  private ImmutableTypeToInstanceMap(ImmutableMap<TypeToken<? extends B>, B> delegate) {
    this.delegate = delegate;
  }


            

Reported by PMD.

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

Line: 98

                  }
  }

  private final ImmutableMap<TypeToken<? extends B>, B> delegate;

  private ImmutableTypeToInstanceMap(ImmutableMap<TypeToken<? extends B>, B> delegate) {
    this.delegate = delegate;
  }


            

Reported by PMD.

The String literal 'Always throws UnsupportedOperationException' appears 4 times in this file; the first occurrence is on line 123
Error

Line: 123

                @CanIgnoreReturnValue
  @Deprecated
  @Override
  @DoNotCall("Always throws UnsupportedOperationException")
  public <T extends B> T putInstance(TypeToken<T> type, T value) {
    throw new UnsupportedOperationException();
  }

  /**

            

Reported by PMD.

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

Line: 40

               */
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements BiMap<K, V> {

  /**
   * Returns the empty bimap.
   *
   * <p><b>Performance note:</b> the instance returned is a singleton.

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 40

               */
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements BiMap<K, V> {

  /**
   * Returns the empty bimap.
   *
   * <p><b>Performance note:</b> the instance returned is a singleton.

            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 100

                 *
   * @throws IllegalArgumentException if duplicate keys or values are added
   */
  public static <K, V> ImmutableBiMap<K, V> of(
      K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
    checkEntryNotNull(k1, v1);
    checkEntryNotNull(k2, v2);
    checkEntryNotNull(k3, v3);
    checkEntryNotNull(k4, v4);

            

Reported by PMD.

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

Line: 297

                    ImmutableBiMap<K, V> bimap = (ImmutableBiMap<K, V>) map;
      // TODO(lowasser): if we need to make a copy of a BiMap because the
      // forward map is a view, don't make a copy of the non-view delegate map
      if (!bimap.isPartialView()) {
        return bimap;
      }
    }
    return copyOf(map.entrySet());
  }

            

Reported by PMD.

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

Line: 339

                 */
  @Override
  public ImmutableSet<V> values() {
    return inverse().keySet();
  }

  @Override
  final ImmutableSet<V> createValues() {
    throw new AssertionError("should never be called");

            

Reported by PMD.

guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/ShortsMethodsForWeb.java
5 issues
Do not use the short type
Performance

Line: 24

              abstract class ShortsMethodsForWeb {

  @JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
  public static native short min(short... array);

  @JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
  public static native short max(short... array);
}

            

Reported by PMD.

Do not use the short type
Performance

Line: 24

              abstract class ShortsMethodsForWeb {

  @JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
  public static native short min(short... array);

  @JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
  public static native short max(short... array);
}

            

Reported by PMD.

Do not use the short type
Performance

Line: 27

                public static native short min(short... array);

  @JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
  public static native short max(short... array);
}

            

Reported by PMD.

Do not use the short type
Performance

Line: 27

                public static native short min(short... array);

  @JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
  public static native short max(short... array);
}

            

Reported by PMD.

This abstract class does not have any abstract methods
Design

Line: 21

              import jsinterop.annotations.JsPackage;

/** Web specializations for {@link Shorts} methods. */
abstract class ShortsMethodsForWeb {

  @JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
  public static native short min(short... array);

  @JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)

            

Reported by PMD.

android/guava/src/com/google/common/graph/UndirectedGraphConnections.java
5 issues
This class has too many methods, consider refactoring it.
Design

Line: 42

               * @param <V> Value parameter type
 */
@ElementTypesAreNonnullByDefault
final class UndirectedGraphConnections<N, V> implements GraphConnections<N, V> {
  private final Map<N, V> adjacentNodeValues;

  private UndirectedGraphConnections(Map<N, V> adjacentNodeValues) {
    this.adjacentNodeValues = checkNotNull(adjacentNodeValues);
  }

            

Reported by PMD.

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

Line: 43

               */
@ElementTypesAreNonnullByDefault
final class UndirectedGraphConnections<N, V> implements GraphConnections<N, V> {
  private final Map<N, V> adjacentNodeValues;

  private UndirectedGraphConnections(Map<N, V> adjacentNodeValues) {
    this.adjacentNodeValues = checkNotNull(adjacentNodeValues);
  }


            

Reported by PMD.

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

Line: 84

                @Override
  public Iterator<EndpointPair<N>> incidentEdgeIterator(final N thisNode) {
    return Iterators.transform(
        adjacentNodeValues.keySet().iterator(),
        new Function<N, EndpointPair<N>>() {
          @Override
          public EndpointPair<N> apply(N incidentNode) {
            return EndpointPair.unordered(thisNode, incidentNode);
          }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'unused' (lines '102'-'103').
Error

Line: 102

                @Override
  public void removePredecessor(N node) {
    @SuppressWarnings("unused")
    V unused = removeSuccessor(node);
  }

  @Override
  @CheckForNull
  public V removeSuccessor(N node) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'unused' (lines '114'-'115').
Error

Line: 114

                @Override
  public void addPredecessor(N node, V value) {
    @SuppressWarnings("unused")
    V unused = addSuccessor(node, value);
  }

  @Override
  @CheckForNull
  public V addSuccessor(N node, V value) {

            

Reported by PMD.