The following issues were found

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

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.

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.

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.

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

Line: 31

              @GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
final class EmptyContiguousSet<C extends Comparable> extends ContiguousSet<C> {
  EmptyContiguousSet(DiscreteDomain<C> domain) {
    super(domain);
  }

  @Override

            

Reported by PMD.

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

Line: 31

              @GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
final class EmptyContiguousSet<C extends Comparable> extends ContiguousSet<C> {
  EmptyContiguousSet(DiscreteDomain<C> domain) {
    super(domain);
  }

  @Override

            

Reported by PMD.

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

Line: 128

                public boolean equals(@CheckForNull Object object) {
    if (object instanceof Set) {
      Set<?> that = (Set<?>) object;
      return that.isEmpty();
    }
    return false;
  }

  @GwtIncompatible // not used in GWT

            

Reported by PMD.

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

Line: 146

              
  @GwtIncompatible // serialization
  private static final class SerializedForm<C extends Comparable> implements Serializable {
    private final DiscreteDomain<C> domain;

    private SerializedForm(DiscreteDomain<C> domain) {
      this.domain = domain;
    }


            

Reported by PMD.

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

Line: 168

                @GwtIncompatible // NavigableSet
  @Override
  ImmutableSortedSet<C> createDescendingSet() {
    return ImmutableSortedSet.emptySet(Ordering.natural().reverse());
  }
}

            

Reported by PMD.

guava/src/com/google/common/collect/DiscreteDomain.java
5 issues
The String literal 'distance' appears 4 times in this file; the first occurrence is on line 82
Error

Line: 82

              
    @Override
    Integer offset(Integer origin, long distance) {
      checkNonnegative(distance, "distance");
      return Ints.checkedCast(origin.longValue() + distance);
    }

    @Override
    public long distance(Integer start, Integer end) {

            

Reported by PMD.

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

Line: 225

              
    @Override
    public long distance(BigInteger start, BigInteger end) {
      return end.subtract(start).max(MIN_LONG).min(MAX_LONG).longValue();
    }

    private Object readResolve() {
      return INSTANCE;
    }

            

Reported by PMD.

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

Line: 225

              
    @Override
    public long distance(BigInteger start, BigInteger end) {
      return end.subtract(start).max(MIN_LONG).min(MAX_LONG).longValue();
    }

    private Object readResolve() {
      return INSTANCE;
    }

            

Reported by PMD.

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

Line: 225

              
    @Override
    public long distance(BigInteger start, BigInteger end) {
      return end.subtract(start).max(MIN_LONG).min(MAX_LONG).longValue();
    }

    private Object readResolve() {
      return INSTANCE;
    }

            

Reported by PMD.

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

Line: 240

                  private static final long serialVersionUID = 0;
  }

  final boolean supportsFastOffset;

  /** Constructor for use by subclasses. */
  protected DiscreteDomain() {
    this(false);
  }

            

Reported by PMD.

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 '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.

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.

guava/src/com/google/common/base/Defaults.java
5 issues
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 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 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.

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(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.

guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java
5 issues
Avoid throwing raw exception types.
Design

Line: 44

                    DELEGATE_METHOD = ForwardingObject.class.getDeclaredMethod("delegate");
      DELEGATE_METHOD.setAccessible(true);
    } catch (SecurityException e) {
      throw new RuntimeException(e);
    } catch (NoSuchMethodException e) {
      throw new AssertionError(e);
    }
  }


            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 69

                                T stubber = doReturn(delegate).when(mock);
                  DELEGATE_METHOD.invoke(stubber);
                } catch (Exception e) {
                  throw new RuntimeException(e);
                }
                return mock;
              }
            });
  }

            

Reported by PMD.

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

               *
 * @author Ben Yu
 */
final class ForwardingObjectTester {

  private static final Method DELEGATE_METHOD;

  static {
    try {

            

Reported by PMD.

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

Line: 66

                            public T apply(Object delegate) {
                T mock = mock(forwarderClass, CALLS_REAL_METHODS.get());
                try {
                  T stubber = doReturn(delegate).when(mock);
                  DELEGATE_METHOD.invoke(stubber);
                } catch (Exception e) {
                  throw new RuntimeException(e);
                }
                return mock;

            

Reported by PMD.

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

Line: 68

                              try {
                  T stubber = doReturn(delegate).when(mock);
                  DELEGATE_METHOD.invoke(stubber);
                } catch (Exception e) {
                  throw new RuntimeException(e);
                }
                return mock;
              }
            });

            

Reported by PMD.

guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
5 issues
Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 59

                  checkNotNull(timeoutUnit);
    try {
      return callable.call();
    } catch (RuntimeException e) {
      throw new UncheckedExecutionException(e);
    } catch (Exception e) {
      throw new ExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);

            

Reported by PMD.

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

Line: 61

                    return callable.call();
    } catch (RuntimeException e) {
      throw new UncheckedExecutionException(e);
    } catch (Exception e) {
      throw new ExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);
    } catch (Throwable e) {
      // It's a non-Error, non-Exception Throwable. Such classes are usually intended to extend

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 65

                    throw new ExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);
    } catch (Throwable e) {
      // It's a non-Error, non-Exception Throwable. Such classes are usually intended to extend
      // Exception, so we'll treat it like an Exception.
      throw new ExecutionException(e);
    }
  }

            

Reported by PMD.

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

Line: 85

                  checkNotNull(timeoutUnit);
    try {
      runnable.run();
    } catch (RuntimeException e) {
      throw new UncheckedExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);
    } catch (Throwable e) {
      // It's a non-Error, non-Exception Throwable. Such classes are usually intended to extend

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 89

                    throw new UncheckedExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);
    } catch (Throwable e) {
      // It's a non-Error, non-Exception Throwable. Such classes are usually intended to extend
      // Exception, so we'll treat it like a RuntimeException.
      throw new UncheckedExecutionException(e);
    }
  }

            

Reported by PMD.

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.

guava/src/com/google/common/base/Platform.java
5 issues
Logger calls should be surrounded by log level guards.
Design

Line: 125

                            "https://stackoverflow.com/q/5189914/28465",
              "https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ"));
    }
    logger.log(
        java.util.logging.Level.WARNING,
        "Later in 2020, we will remove GWT-RPC support for Guava types. You are seeing this"
            + " warning because you are sending a Guava type over GWT-RPC, which will break. You"
            + " can identify which type by looking at the class name in the attached stack trace.",
        new Throwable());

            

Reported by PMD.

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

Line: 33

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class Platform {
  private static final Logger logger = Logger.getLogger(Platform.class.getName());
  private static final PatternCompiler patternCompiler = loadPatternCompiler();

  private Platform() {}


            

Reported by PMD.

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

Line: 50

                }

  static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
    WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
    return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
  }

  static String formatCompact4Digits(double value) {
    return String.format(Locale.ROOT, "%.4g", value);

            

Reported by PMD.

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

Line: 51

              
  static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
    WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
    return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
  }

  static String formatCompact4Digits(double value) {
    return String.format(Locale.ROOT, "%.4g", value);
  }

            

Reported by PMD.

Avoid unused private methods such as 'logPatternCompilerError(ServiceConfigurationError)'.
Design

Line: 96

                  return new JdkPatternCompiler();
  }

  private static void logPatternCompilerError(ServiceConfigurationError e) {
    logger.log(Level.WARNING, "Error loading regex compiler, falling back to next option", e);
  }

  private static final class JdkPatternCompiler implements PatternCompiler {
    @Override

            

Reported by PMD.