The following issues were found

guava/src/com/google/common/util/concurrent/Callables.java
4 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 89

                    @ParametricNullness
      public T call() throws Exception {
        Thread currentThread = Thread.currentThread();
        String oldName = currentThread.getName();
        boolean restoreName = trySetName(nameSupplier.get(), currentThread);
        try {
          return callable.call();
        } finally {
          if (restoreName) {

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 95

                        return callable.call();
        } finally {
          if (restoreName) {
            boolean unused = trySetName(oldName, currentThread);
          }
        }
      }
    };
  }

            

Reported by PMD.

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

Line: 118

                    @Override
      public void run() {
        Thread currentThread = Thread.currentThread();
        String oldName = currentThread.getName();
        boolean restoreName = trySetName(nameSupplier.get(), currentThread);
        try {
          task.run();
        } finally {
          if (restoreName) {

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 124

                        task.run();
        } finally {
          if (restoreName) {
            boolean unused = trySetName(oldName, currentThread);
          }
        }
      }
    };
  }

            

Reported by PMD.

guava/src/com/google/common/graph/ImmutableValueGraph.java
4 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 90

                  for (N node : graph.nodes()) {
      nodeConnections.put(node, connectionsOf(graph, node));
    }
    return nodeConnections.build();
  }

  private static <N, V> GraphConnections<N, V> connectionsOf(
      final ValueGraph<N, V> graph, final N node) {
    Function<N, V> successorNodeToValueFn =

            

Reported by PMD.

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

Line: 133

                 */
  public static class Builder<N, V> {

    private final MutableValueGraph<N, V> mutableValueGraph;

    Builder(ValueGraphBuilder<N, V> graphBuilder) {
      // The incidentEdgeOrder for immutable graphs is always stable. However, we don't want to
      // modify this builder, so we make a copy instead.
      this.mutableValueGraph =

            

Reported by PMD.

Found 'DU'-anomaly for variable 'successorNodeToValueFn' (lines '95'-'108').
Error

Line: 95

              
  private static <N, V> GraphConnections<N, V> connectionsOf(
      final ValueGraph<N, V> graph, final N node) {
    Function<N, V> successorNodeToValueFn =
        new Function<N, V>() {
          @Override
          public V apply(N successorNode) {
            // requireNonNull is safe because the endpoint pair comes from the graph.
            return requireNonNull(graph.edgeValueOrDefault(node, successorNode, null));

            

Reported by PMD.

Found 'DU'-anomaly for variable 'successorNodeToValueFn' (lines '95'-'108').
Error

Line: 95

              
  private static <N, V> GraphConnections<N, V> connectionsOf(
      final ValueGraph<N, V> graph, final N node) {
    Function<N, V> successorNodeToValueFn =
        new Function<N, V>() {
          @Override
          public V apply(N successorNode) {
            // requireNonNull is safe because the endpoint pair comes from the graph.
            return requireNonNull(graph.edgeValueOrDefault(node, successorNode, null));

            

Reported by PMD.

guava/src/com/google/common/base/AbstractIterator.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 34

              @GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractIterator<T extends @Nullable Object> implements Iterator<T> {
  private State state = State.NOT_READY;

  protected AbstractIterator() {}

  private enum State {
    READY,

            

Reported by PMD.

Field next has the same name as a method
Error

Line: 45

                  FAILED,
  }

  @CheckForNull private T next;

  @CheckForNull
  protected abstract T computeNext();

  @CanIgnoreReturnValue

            

Reported by PMD.

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

Line: 45

                  FAILED,
  }

  @CheckForNull private T next;

  @CheckForNull
  protected abstract T computeNext();

  @CanIgnoreReturnValue

            

Reported by PMD.

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

Line: 89

                  state = State.NOT_READY;
    // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
    T result = uncheckedCastNullableTToT(next);
    next = null;
    return result;
  }

  @Override
  public final void remove() {

            

Reported by PMD.

guava/src/com/google/common/math/DoubleUtils.java
4 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 91

                static double bigToDouble(BigInteger x) {
    // This is an extremely fast implementation of BigInteger.doubleValue(). JDK patch pending.
    BigInteger absX = x.abs();
    int exponent = absX.bitLength() - 1;
    // exponent == floor(log2(abs(x)))
    if (exponent < Long.SIZE - 1) {
      return x.longValue();
    } else if (exponent > MAX_EXPONENT) {
      return x.signum() * POSITIVE_INFINITY;

            

Reported by PMD.

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

Line: 108

                   * It helps to consider the real number signif = absX * 2^(SIGNIFICAND_BITS - exponent).
     */
    int shift = exponent - SIGNIFICAND_BITS - 1;
    long twiceSignifFloor = absX.shiftRight(shift).longValue();
    long signifFloor = twiceSignifFloor >> 1;
    signifFloor &= SIGNIFICAND_MASK; // remove the implied bit

    /*
     * We round up if either the fractional part of signif is strictly greater than 0.5 (which is

            

Reported by PMD.

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

Line: 108

                   * It helps to consider the real number signif = absX * 2^(SIGNIFICAND_BITS - exponent).
     */
    int shift = exponent - SIGNIFICAND_BITS - 1;
    long twiceSignifFloor = absX.shiftRight(shift).longValue();
    long signifFloor = twiceSignifFloor >> 1;
    signifFloor &= SIGNIFICAND_MASK; // remove the implied bit

    /*
     * We round up if either the fractional part of signif is strictly greater than 0.5 (which is

            

Reported by PMD.

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

Line: 118

                   * >= 0.5 and signifFloor is odd (which is true if both the 0.5 bit and the 1 bit are set).
     */
    boolean increment =
        (twiceSignifFloor & 1) != 0 && ((signifFloor & 1) != 0 || absX.getLowestSetBit() < shift);
    long signifRounded = increment ? signifFloor + 1 : signifFloor;
    long bits = (long) (exponent + EXPONENT_BIAS) << SIGNIFICAND_BITS;
    bits += signifRounded;
    /*
     * If signifRounded == 2^53, we'd need to set all of the significand bits to zero and add 1 to

            

Reported by PMD.

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

Line: 91

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public interface Multiset<E extends @Nullable Object> extends Collection<E> {
  // Query Operations

  /**
   * Returns the total number of all occurrences of all elements in this multiset.
   *

            

Reported by PMD.

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

Line: 346

                @Beta
  default void forEachEntry(ObjIntConsumer<? super E> action) {
    checkNotNull(action);
    entrySet().forEach(entry -> action.accept(entry.getElement(), entry.getCount()));
  }

  // Comparison and hashing

  /**

            

Reported by PMD.

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

Line: 467

                @Override
  default void forEach(Consumer<? super E> action) {
    checkNotNull(action);
    entrySet()
        .forEach(
            entry -> {
              E elem = entry.getElement();
              int count = entry.getCount();
              for (int i = 0; i < count; i++) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'elem' (lines '470'-'476').
Error

Line: 470

                  entrySet()
        .forEach(
            entry -> {
              E elem = entry.getElement();
              int count = entry.getCount();
              for (int i = 0; i < count; i++) {
                action.accept(elem);
              }
            });

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/UncaughtExceptionHandlersTest.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 29

              
public class UncaughtExceptionHandlersTest extends TestCase {

  private Runtime runtimeMock;

  @Override
  protected void setUp() {
    runtimeMock = mock(Runtime.class);
  }

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 31

              
  private Runtime runtimeMock;

  @Override
  protected void setUp() {
    runtimeMock = mock(Runtime.class);
  }

  public void testExiter() {

            

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

                  runtimeMock = mock(Runtime.class);
  }

  public void testExiter() {
    new Exiter(runtimeMock).uncaughtException(new Thread(), new Exception());
    verify(runtimeMock).exit(1);
  }
}

            

Reported by PMD.

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

Line: 38

              
  public void testExiter() {
    new Exiter(runtimeMock).uncaughtException(new Thread(), new Exception());
    verify(runtimeMock).exit(1);
  }
}

            

Reported by PMD.

guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java
4 issues
Class contains multiple getInstance methods. Please review.
Error

Line: 40

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

  private final Map<TypeToken<? extends B>, B> backingMap = Maps.newHashMap();

  @Override

            

Reported by PMD.

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

Line: 43

              public final class MutableTypeToInstanceMap<B> extends ForwardingMap<TypeToken<? extends B>, B>
    implements TypeToInstanceMap<B> {

  private final Map<TypeToken<? extends B>, B> backingMap = Maps.newHashMap();

  @Override
  public <T extends B> @Nullable T getInstance(Class<T> type) {
    return trustedGet(TypeToken.of(type));
  }

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 116

              
  private static final class UnmodifiableEntry<K, V> extends ForwardingMapEntry<K, V> {

    private final Entry<K, V> delegate;

    static <K, V> Set<Entry<K, V>> transformEntries(final Set<Entry<K, V>> entries) {
      return new ForwardingSet<Map.Entry<K, V>>() {
        @Override
        protected Set<Entry<K, V>> delegate() {

            

Reported by PMD.

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

Line: 116

              
  private static final class UnmodifiableEntry<K, V> extends ForwardingMapEntry<K, V> {

    private final Entry<K, V> delegate;

    static <K, V> Set<Entry<K, V>> transformEntries(final Set<Entry<K, V>> entries) {
      return new ForwardingSet<Map.Entry<K, V>>() {
        @Override
        protected Set<Entry<K, V>> delegate() {

            

Reported by PMD.

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

Line: 77

              @GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public class TreeMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractSortedKeySortedSetMultimap<K, V> {
  private transient Comparator<? super K> keyComparator;
  private transient Comparator<? super V> valueComparator;

  /**
   * Creates an empty {@code TreeMultimap} ordered by the natural ordering of its keys and values.

            

Reported by PMD.

Field keyComparator has the same name as a method
Error

Line: 78

              @ElementTypesAreNonnullByDefault
public class TreeMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractSortedKeySortedSetMultimap<K, V> {
  private transient Comparator<? super K> keyComparator;
  private transient Comparator<? super V> valueComparator;

  /**
   * Creates an empty {@code TreeMultimap} ordered by the natural ordering of its keys and values.
   */

            

Reported by PMD.

Field valueComparator has the same name as a method
Error

Line: 79

              public class TreeMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractSortedKeySortedSetMultimap<K, V> {
  private transient Comparator<? super K> keyComparator;
  private transient Comparator<? super V> valueComparator;

  /**
   * Creates an empty {@code TreeMultimap} ordered by the natural ordering of its keys and values.
   */
  public static <K extends Comparable, V extends Comparable> TreeMultimap<K, V> create() {

            

Reported by PMD.

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

Line: 145

                @Override
  Collection<V> createCollection(@ParametricNullness K key) {
    if (key == null) {
      keyComparator().compare(key, key);
    }
    return super.createCollection(key);
  }

  /**

            

Reported by PMD.

guava/src/com/google/common/base/Optional.java
4 issues
This class has too many methods, consider refactoring it.
Design

Line: 86

              @DoNotMock("Use Optional.of(value) or Optional.absent()")
@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
public abstract class Optional<T> implements Serializable {
  /**
   * Returns an {@code Optional} instance with no contained reference.
   *
   * <p><b>Comparison to {@code java.util.Optional}:</b> this method is equivalent to Java 8's
   * {@code Optional.empty}.

            

Reported by PMD.

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

Line: 159

                 * @since 21.0
   */
  public java.util.Optional<T> toJavaUtil() {
    return java.util.Optional.ofNullable(orNull());
  }

  Optional() {}

  /**

            

Reported by PMD.

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

Line: 350

                        protected T computeNext() {
            while (iterator.hasNext()) {
              Optional<? extends T> optional = iterator.next();
              if (optional.isPresent()) {
                return optional.get();
              }
            }
            return endOfData();
          }

            

Reported by PMD.

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

Line: 351

                          while (iterator.hasNext()) {
              Optional<? extends T> optional = iterator.next();
              if (optional.isPresent()) {
                return optional.get();
              }
            }
            return endOfData();
          }
        };

            

Reported by PMD.

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

Line: 43

                public boolean contains(@CheckForNull Object target) {
    // The collection's contains() is at least as fast as ImmutableList's
    // and is often faster.
    return delegateCollection().contains(target);
  }

  @Override
  public int size() {
    return delegateCollection().size();

            

Reported by PMD.

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

Line: 48

              
  @Override
  public int size() {
    return delegateCollection().size();
  }

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

            

Reported by PMD.

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

Line: 53

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

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

            

Reported by PMD.

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

Line: 58

              
  @Override
  boolean isPartialView() {
    return delegateCollection().isPartialView();
  }

  /** Serialized form that leads to the same performance as the original list. */
  @GwtIncompatible // serialization
  static class SerializedForm implements Serializable {

            

Reported by PMD.