The following issues were found

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

Line: 69

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public class Joiner {
  /** Returns a joiner which automatically places {@code separator} between consecutive elements. */
  public static Joiner on(String separator) {
    return new Joiner(separator);
  }


            

Reported by PMD.

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

Line: 80

                  return new Joiner(String.valueOf(separator));
  }

  private final String separator;

  private Joiner(String separator) {
    this.separator = checkNotNull(separator);
  }


            

Reported by PMD.

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

Line: 244

                  return new Joiner(this) {
      @Override
      CharSequence toString(@CheckForNull Object part) {
        return (part == null) ? nullText : Joiner.this.toString(part);
      }

      @Override
      public Joiner useForNull(String nullText) {
        throw new UnsupportedOperationException("already specified useForNull");

            

Reported by PMD.

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

Line: 244

                  return new Joiner(this) {
      @Override
      CharSequence toString(@CheckForNull Object part) {
        return (part == null) ? nullText : Joiner.this.toString(part);
      }

      @Override
      public Joiner useForNull(String nullText) {
        throw new UnsupportedOperationException("already specified useForNull");

            

Reported by PMD.

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

Line: 273

                      while (parts.hasNext()) {
          Object part = parts.next();
          if (part != null) {
            appendable.append(Joiner.this.toString(part));
            break;
          }
        }
        while (parts.hasNext()) {
          Object part = parts.next();

            

Reported by PMD.

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

Line: 273

                      while (parts.hasNext()) {
          Object part = parts.next();
          if (part != null) {
            appendable.append(Joiner.this.toString(part));
            break;
          }
        }
        while (parts.hasNext()) {
          Object part = parts.next();

            

Reported by PMD.

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

Line: 281

                        Object part = parts.next();
          if (part != null) {
            appendable.append(separator);
            appendable.append(Joiner.this.toString(part));
          }
        }
        return appendable;
      }


            

Reported by PMD.

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

Line: 281

                        Object part = parts.next();
          if (part != null) {
            appendable.append(separator);
            appendable.append(Joiner.this.toString(part));
          }
        }
        return appendable;
      }


            

Reported by PMD.

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

Line: 336

                 * @since 2.0
   */
  public static final class MapJoiner {
    private final Joiner joiner;
    private final String keyValueSeparator;

    private MapJoiner(Joiner joiner, String keyValueSeparator) {
      this.joiner = joiner; // only "this" is ever passed, so don't checkNotNull
      this.keyValueSeparator = checkNotNull(keyValueSeparator);

            

Reported by PMD.

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

Line: 337

                 */
  public static final class MapJoiner {
    private final Joiner joiner;
    private final String keyValueSeparator;

    private MapJoiner(Joiner joiner, String keyValueSeparator) {
      this.joiner = joiner; // only "this" is ever passed, so don't checkNotNull
      this.keyValueSeparator = checkNotNull(keyValueSeparator);
    }

            

Reported by PMD.

android/guava/src/com/google/common/primitives/Ints.java
18 issues
Avoid using a branching statement as the last in a loop.
Error

Line: 188

                        continue outer;
        }
      }
      return i;
    }
    return -1;
  }

  /**

            

Reported by PMD.

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

Line: 48

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Ints extends IntsMethodsForWeb {
  private Ints() {}

  /**
   * The number of bytes required to represent a primitive {@code int} value.
   *

            

Reported by PMD.

Possible God Class (WMC=59, ATFD=33, TCC=0.000%)
Design

Line: 48

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Ints extends IntsMethodsForWeb {
  private Ints() {}

  /**
   * The number of bytes required to represent a primitive {@code int} value.
   *

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 506

                public static void reverse(int[] array, int fromIndex, int toIndex) {
    checkNotNull(array);
    checkPositionIndexes(fromIndex, toIndex, array.length);
    for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
      int tmp = array[i];
      array[i] = array[j];
      array[j] = tmp;
    }
  }

            

Reported by PMD.

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

Line: 566

                @GwtCompatible
  private static class IntArrayAsList extends AbstractList<Integer>
      implements RandomAccess, Serializable {
    final int[] array;
    final int start;
    final int end;

    IntArrayAsList(int[] array) {
      this(array, 0, array.length);

            

Reported by PMD.

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

Line: 567

                private static class IntArrayAsList extends AbstractList<Integer>
      implements RandomAccess, Serializable {
    final int[] array;
    final int start;
    final int end;

    IntArrayAsList(int[] array) {
      this(array, 0, array.length);
    }

            

Reported by PMD.

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

Line: 568

                    implements RandomAccess, Serializable {
    final int[] array;
    final int start;
    final int end;

    IntArrayAsList(int[] array) {
      this(array, 0, array.length);
    }


            

Reported by PMD.

The user-supplied array 'array' is stored directly.
Design

Line: 574

                    this(array, 0, array.length);
    }

    IntArrayAsList(int[] array, int start, int end) {
      this.array = array;
      this.start = start;
      this.end = end;
    }


            

Reported by PMD.

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

Line: 653

                    if (object instanceof IntArrayAsList) {
        IntArrayAsList that = (IntArrayAsList) object;
        int size = size();
        if (that.size() != size) {
          return false;
        }
        for (int i = 0; i < size; i++) {
          if (array[start + i] != that.array[that.start + i]) {
            return false;

            

Reported by PMD.

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

Line: 739

                @CheckForNull
  public static Integer tryParse(String string, int radix) {
    Long result = Longs.tryParse(string, radix);
    if (result == null || result.longValue() != result.intValue()) {
      return null;
    } else {
      return result.intValue();
    }
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/reflect/AbstractInvocationHandlerTest.java
18 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 40

                private static final ImmutableList<String> LIST1 = ImmutableList.of("one", "two");
  private static final ImmutableList<String> LIST2 = ImmutableList.of("three");

  public void testDelegate() {
    assertEquals(LIST1, ImmutableList.copyOf(newDelegatingList(LIST1)));
    assertEquals(LIST1, ImmutableList.copyOf(newDelegatingListWithEquals(LIST1)));
  }

  public void testToString() {

            

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

                private static final ImmutableList<String> LIST1 = ImmutableList.of("one", "two");
  private static final ImmutableList<String> LIST2 = ImmutableList.of("three");

  public void testDelegate() {
    assertEquals(LIST1, ImmutableList.copyOf(newDelegatingList(LIST1)));
    assertEquals(LIST1, ImmutableList.copyOf(newDelegatingListWithEquals(LIST1)));
  }

  public void testToString() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

                private static final ImmutableList<String> LIST2 = ImmutableList.of("three");

  public void testDelegate() {
    assertEquals(LIST1, ImmutableList.copyOf(newDelegatingList(LIST1)));
    assertEquals(LIST1, ImmutableList.copyOf(newDelegatingListWithEquals(LIST1)));
  }

  public void testToString() {
    List<String> proxy = newDelegatingList(LIST1);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

              
  public void testDelegate() {
    assertEquals(LIST1, ImmutableList.copyOf(newDelegatingList(LIST1)));
    assertEquals(LIST1, ImmutableList.copyOf(newDelegatingListWithEquals(LIST1)));
  }

  public void testToString() {
    List<String> proxy = newDelegatingList(LIST1);
    assertEquals(Proxy.getInvocationHandler(proxy).toString(), proxy.toString());

            

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

                  assertEquals(LIST1, ImmutableList.copyOf(newDelegatingListWithEquals(LIST1)));
  }

  public void testToString() {
    List<String> proxy = newDelegatingList(LIST1);
    assertEquals(Proxy.getInvocationHandler(proxy).toString(), proxy.toString());
  }

  interface A {}

            

Reported by PMD.

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

Line: 47

              
  public void testToString() {
    List<String> proxy = newDelegatingList(LIST1);
    assertEquals(Proxy.getInvocationHandler(proxy).toString(), proxy.toString());
  }

  interface A {}

  interface B {}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

              
  public void testToString() {
    List<String> proxy = newDelegatingList(LIST1);
    assertEquals(Proxy.getInvocationHandler(proxy).toString(), proxy.toString());
  }

  interface A {}

  interface B {}

            

Reported by PMD.

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

Line: 47

              
  public void testToString() {
    List<String> proxy = newDelegatingList(LIST1);
    assertEquals(Proxy.getInvocationHandler(proxy).toString(), proxy.toString());
  }

  interface A {}

  interface B {}

            

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

              
  interface B {}

  public void testEquals() {
    class AB implements A, B {}
    class BA implements B, A {}
    AB ab = new AB();
    BA ba = new BA();
    new EqualsTester()

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 54

              
  interface B {}

  public void testEquals() {
    class AB implements A, B {}
    class BA implements B, A {}
    AB ab = new AB();
    BA ba = new BA();
    new EqualsTester()

            

Reported by PMD.

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

Line: 47

               * @param <V> Value parameter type
 */
@ElementTypesAreNonnullByDefault
class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
  private final boolean isDirected;
  private final boolean allowsSelfLoops;
  private final ElementOrder<N> nodeOrder;

  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;

            

Reported by PMD.

Field isDirected has the same name as a method
Error

Line: 48

               */
@ElementTypesAreNonnullByDefault
class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
  private final boolean isDirected;
  private final boolean allowsSelfLoops;
  private final ElementOrder<N> nodeOrder;

  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;


            

Reported by PMD.

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

Line: 48

               */
@ElementTypesAreNonnullByDefault
class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
  private final boolean isDirected;
  private final boolean allowsSelfLoops;
  private final ElementOrder<N> nodeOrder;

  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;


            

Reported by PMD.

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

Line: 49

              @ElementTypesAreNonnullByDefault
class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
  private final boolean isDirected;
  private final boolean allowsSelfLoops;
  private final ElementOrder<N> nodeOrder;

  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;

  long edgeCount; // must be updated when edges are added or removed

            

Reported by PMD.

Field allowsSelfLoops has the same name as a method
Error

Line: 49

              @ElementTypesAreNonnullByDefault
class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
  private final boolean isDirected;
  private final boolean allowsSelfLoops;
  private final ElementOrder<N> nodeOrder;

  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;

  long edgeCount; // must be updated when edges are added or removed

            

Reported by PMD.

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

Line: 50

              class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
  private final boolean isDirected;
  private final boolean allowsSelfLoops;
  private final ElementOrder<N> nodeOrder;

  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;

  long edgeCount; // must be updated when edges are added or removed


            

Reported by PMD.

Field nodeOrder has the same name as a method
Error

Line: 50

              class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
  private final boolean isDirected;
  private final boolean allowsSelfLoops;
  private final ElementOrder<N> nodeOrder;

  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;

  long edgeCount; // must be updated when edges are added or removed


            

Reported by PMD.

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

Line: 52

                private final boolean allowsSelfLoops;
  private final ElementOrder<N> nodeOrder;

  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;

  long edgeCount; // must be updated when edges are added or removed

  /** Constructs a graph with the properties specified in {@code builder}. */
  StandardValueGraph(AbstractGraphBuilder<? super N> builder) {

            

Reported by PMD.

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

Line: 54

              
  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;

  long edgeCount; // must be updated when edges are added or removed

  /** Constructs a graph with the properties specified in {@code builder}. */
  StandardValueGraph(AbstractGraphBuilder<? super N> builder) {
    this(
        builder,

            

Reported by PMD.

Field edgeCount has the same name as a method
Error

Line: 54

              
  final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;

  long edgeCount; // must be updated when edges are added or removed

  /** Constructs a graph with the properties specified in {@code builder}. */
  StandardValueGraph(AbstractGraphBuilder<? super N> builder) {
    this(
        builder,

            

Reported by PMD.

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

Line: 56

                }

  private abstract static class GeneralSpliterator<E> {
    final Spliterator<E> spliterator;

    GeneralSpliterator(Spliterator<E> spliterator) {
      this.spliterator = checkNotNull(spliterator);
    }


            

Reported by PMD.

The String literal 'AndroidJdkLibsChecker' appears 4 times in this file; the first occurrence is on line 118
Error

Line: 118

                 * from creating the Spliterator.OfInt in the first place. So it's probably OK for us to suppress
   * this particular violation.
   */
  @SuppressWarnings("AndroidJdkLibsChecker")
  private static final class GeneralSpliteratorOfPrimitive<E, C> extends GeneralSpliterator<E> {
    final Spliterator.OfPrimitive<E, C, ?> spliterator;
    final Function<Consumer<? super E>, C> consumerizer;

    GeneralSpliteratorOfPrimitive(

            

Reported by PMD.

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

Line: 120

                 */
  @SuppressWarnings("AndroidJdkLibsChecker")
  private static final class GeneralSpliteratorOfPrimitive<E, C> extends GeneralSpliterator<E> {
    final Spliterator.OfPrimitive<E, C, ?> spliterator;
    final Function<Consumer<? super E>, C> consumerizer;

    GeneralSpliteratorOfPrimitive(
        Spliterator.OfPrimitive<E, C, ?> spliterator,
        Function<Consumer<? super E>, C> consumerizer) {

            

Reported by PMD.

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

Line: 121

                @SuppressWarnings("AndroidJdkLibsChecker")
  private static final class GeneralSpliteratorOfPrimitive<E, C> extends GeneralSpliterator<E> {
    final Spliterator.OfPrimitive<E, C, ?> spliterator;
    final Function<Consumer<? super E>, C> consumerizer;

    GeneralSpliteratorOfPrimitive(
        Spliterator.OfPrimitive<E, C, ?> spliterator,
        Function<Consumer<? super E>, C> consumerizer) {
      super(spliterator);

            

Reported by PMD.

Avoid empty while statements
Error

Line: 162

                  NO_SPLIT_TRY_ADVANCE {
      @Override
      <E> void forEach(GeneralSpliterator<E> spliterator, Consumer<? super E> consumer) {
        while (spliterator.tryAdvance(consumer)) {
          // do nothing
        }
      }
    },
    MAXIMUM_SPLIT {

            

Reported by PMD.

These nested if statements could be combined
Design

Line: 214

                            spliterator.estimateSize(), originalSize));
    }
    if (trySplit != null) {
      if (trySplit.estimateSize() > originalSize) {
        fail(
            format(
                "estimated size of trySplit result (%s) is larger than original size (%s)",
                trySplit.estimateSize(), originalSize));
      }

            

Reported by PMD.

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

Line: 270

                          () -> new GeneralSpliteratorOfPrimitive<>(spliteratorSupplier.get(), c -> c::accept)));
  }

  private final ImmutableSet<Supplier<GeneralSpliterator<E>>> spliteratorSuppliers;

  private SpliteratorTester(ImmutableSet<Supplier<GeneralSpliterator<E>>> spliteratorSuppliers) {
    this.spliteratorSuppliers = checkNotNull(spliteratorSuppliers);
  }


            

Reported by PMD.

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

Line: 285

                  List<List<E>> resultsForAllStrategies = new ArrayList<>();
    for (Supplier<GeneralSpliterator<E>> spliteratorSupplier : spliteratorSuppliers) {
      GeneralSpliterator<E> spliterator = spliteratorSupplier.get();
      int characteristics = spliterator.characteristics();
      long estimatedSize = spliterator.estimateSize();
      for (SpliteratorDecompositionStrategy strategy :
          EnumSet.allOf(SpliteratorDecompositionStrategy.class)) {
        List<E> resultsForStrategy = new ArrayList<>();
        strategy.forEach(spliteratorSupplier.get(), resultsForStrategy::add);

            

Reported by PMD.

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

Line: 286

                  for (Supplier<GeneralSpliterator<E>> spliteratorSupplier : spliteratorSuppliers) {
      GeneralSpliterator<E> spliterator = spliteratorSupplier.get();
      int characteristics = spliterator.characteristics();
      long estimatedSize = spliterator.estimateSize();
      for (SpliteratorDecompositionStrategy strategy :
          EnumSet.allOf(SpliteratorDecompositionStrategy.class)) {
        List<E> resultsForStrategy = new ArrayList<>();
        strategy.forEach(spliteratorSupplier.get(), resultsForStrategy::add);


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 289

                    long estimatedSize = spliterator.estimateSize();
      for (SpliteratorDecompositionStrategy strategy :
          EnumSet.allOf(SpliteratorDecompositionStrategy.class)) {
        List<E> resultsForStrategy = new ArrayList<>();
        strategy.forEach(spliteratorSupplier.get(), resultsForStrategy::add);

        // TODO(cpovirk): better failure messages
        if ((characteristics & Spliterator.NONNULL) != 0) {
          assertFalse(resultsForStrategy.contains(null));

            

Reported by PMD.

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

Line: 79

                  // This dispatcher matches the original dispatch behavior of EventBus.

    /** Per-thread queue of events to dispatch. */
    private final ThreadLocal<Queue<Event>> queue =
        new ThreadLocal<Queue<Event>>() {
          @Override
          protected Queue<Event> initialValue() {
            return Queues.newArrayDeque();
          }

            

Reported by PMD.

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

Line: 88

                      };

    /** Per-thread dispatch state, used to avoid reentrant event dispatching. */
    private final ThreadLocal<Boolean> dispatching =
        new ThreadLocal<Boolean>() {
          @Override
          protected Boolean initialValue() {
            return false;
          }

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 107

                      dispatching.set(true);
        try {
          Event nextEvent;
          while ((nextEvent = queueForThread.poll()) != null) {
            while (nextEvent.subscribers.hasNext()) {
              nextEvent.subscribers.next().dispatchEvent(nextEvent.event);
            }
          }
        } finally {

            

Reported by PMD.

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

Line: 108

                      try {
          Event nextEvent;
          while ((nextEvent = queueForThread.poll()) != null) {
            while (nextEvent.subscribers.hasNext()) {
              nextEvent.subscribers.next().dispatchEvent(nextEvent.event);
            }
          }
        } finally {
          dispatching.remove();

            

Reported by PMD.

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

Line: 109

                        Event nextEvent;
          while ((nextEvent = queueForThread.poll()) != null) {
            while (nextEvent.subscribers.hasNext()) {
              nextEvent.subscribers.next().dispatchEvent(nextEvent.event);
            }
          }
        } finally {
          dispatching.remove();
          queue.remove();

            

Reported by PMD.

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

Line: 109

                        Event nextEvent;
          while ((nextEvent = queueForThread.poll()) != null) {
            while (nextEvent.subscribers.hasNext()) {
              nextEvent.subscribers.next().dispatchEvent(nextEvent.event);
            }
          }
        } finally {
          dispatching.remove();
          queue.remove();

            

Reported by PMD.

It is somewhat confusing to have a field name matching the declaring class name
Error

Line: 120

                  }

    private static final class Event {
      private final Object event;
      private final Iterator<Subscriber> subscribers;

      private Event(Object event, Iterator<Subscriber> subscribers) {
        this.event = event;
        this.subscribers = subscribers;

            

Reported by PMD.

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

Line: 120

                  }

    private static final class Event {
      private final Object event;
      private final Iterator<Subscriber> subscribers;

      private Event(Object event, Iterator<Subscriber> subscribers) {
        this.event = event;
        this.subscribers = subscribers;

            

Reported by PMD.

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

Line: 121

              
    private static final class Event {
      private final Object event;
      private final Iterator<Subscriber> subscribers;

      private Event(Object event, Iterator<Subscriber> subscribers) {
        this.event = event;
        this.subscribers = subscribers;
      }

            

Reported by PMD.

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

Line: 152

                  // in some cases.

    /** Global event queue. */
    private final ConcurrentLinkedQueue<EventWithSubscriber> queue =
        Queues.newConcurrentLinkedQueue();

    @Override
    void dispatch(Object event, Iterator<Subscriber> subscribers) {
      checkNotNull(event);

            

Reported by PMD.

android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
18 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 59

                 * In certain circumstances, this field might theoretically not be visible to an afterDone() call
   * triggered by cancel(). For details, see the comments on the fields of TimeoutFuture.
   */
  @CheckForNull ListenableFuture<? extends I> inputFuture;
  @CheckForNull F function;

  AbstractTransformFuture(ListenableFuture<? extends I> inputFuture, F function) {
    this.inputFuture = checkNotNull(inputFuture);
    this.function = checkNotNull(function);

            

Reported by PMD.

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

Line: 60

                 * triggered by cancel(). For details, see the comments on the fields of TimeoutFuture.
   */
  @CheckForNull ListenableFuture<? extends I> inputFuture;
  @CheckForNull F function;

  AbstractTransformFuture(ListenableFuture<? extends I> inputFuture, F function) {
    this.inputFuture = checkNotNull(inputFuture);
    this.function = checkNotNull(function);
  }

            

Reported by PMD.

Avoid really long methods.
Design

Line: 68

                }

  @Override
  public final void run() {
    ListenableFuture<? extends I> localInputFuture = inputFuture;
    F localFunction = function;
    if (isCancelled() | localInputFuture == null | localFunction == null) {
      return;
    }

            

Reported by PMD.

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

Line: 74

                  if (isCancelled() | localInputFuture == null | localFunction == null) {
      return;
    }
    inputFuture = null;

    if (localInputFuture.isCancelled()) {
      @SuppressWarnings("unchecked")
      boolean unused =
          setFuture((ListenableFuture<O>) localInputFuture); // Respects cancellation cause setting

            

Reported by PMD.

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

Line: 76

                  }
    inputFuture = null;

    if (localInputFuture.isCancelled()) {
      @SuppressWarnings("unchecked")
      boolean unused =
          setFuture((ListenableFuture<O>) localInputFuture); // Respects cancellation cause setting
      return;
    }

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 78

              
    if (localInputFuture.isCancelled()) {
      @SuppressWarnings("unchecked")
      boolean unused =
          setFuture((ListenableFuture<O>) localInputFuture); // Respects cancellation cause setting
      return;
    }

    /*

            

Reported by PMD.

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

Line: 106

                    // Set the cause of the exception as this future's exception.
      setException(e.getCause());
      return;
    } catch (RuntimeException e) {
      // Bug in inputFuture.get(). Propagate to the output Future so that its consumers don't hang.
      setException(e);
      return;
    } catch (Error e) {
      /*

            

Reported by PMD.

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

Line: 123

                  T transformResult;
    try {
      transformResult = doTransform(localFunction, sourceResult);
    } catch (Throwable t) {
      // This exception is irrelevant in this thread, but useful for the client.
      setException(t);
      return;
    } finally {
      function = null;

            

Reported by PMD.

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

Line: 128

                    setException(t);
      return;
    } finally {
      function = null;
    }

    /*
     * If set()/setValue() throws an Error, we let it propagate. Why? The most likely Error is a
     * StackOverflowError (from deep transform(..., directExecutor()) nesting), and calling

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 173

                /** Template method for subtypes to actually run the transform. */
  @ForOverride
  @ParametricNullness
  abstract T doTransform(F function, @ParametricNullness I result) throws Exception;

  /** Template method for subtypes to actually set the result. */
  @ForOverride
  abstract void setResult(@ParametricNullness T result);


            

Reported by PMD.

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

Line: 30

               * @author Joshua O'Madadhain
 */
@ElementTypesAreNonnullByDefault
abstract class ForwardingValueGraph<N, V> extends AbstractValueGraph<N, V> {

  abstract ValueGraph<N, V> delegate();

  @Override
  public Set<N> nodes() {

            

Reported by PMD.

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

Line: 36

              
  @Override
  public Set<N> nodes() {
    return delegate().nodes();
  }

  /**
   * Defer to {@link AbstractValueGraph#edges()} (based on {@link #successors(Object)}) for full
   * edges() implementation.

            

Reported by PMD.

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

Line: 45

                 */
  @Override
  protected long edgeCount() {
    return delegate().edges().size();
  }

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

            

Reported by PMD.

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

Line: 45

                 */
  @Override
  protected long edgeCount() {
    return delegate().edges().size();
  }

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

            

Reported by PMD.

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

Line: 50

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

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

            

Reported by PMD.

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

Line: 55

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

  @Override
  public ElementOrder<N> nodeOrder() {
    return delegate().nodeOrder();

            

Reported by PMD.

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

Line: 60

              
  @Override
  public ElementOrder<N> nodeOrder() {
    return delegate().nodeOrder();
  }

  @Override
  public ElementOrder<N> incidentEdgeOrder() {
    return delegate().incidentEdgeOrder();

            

Reported by PMD.

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

Line: 65

              
  @Override
  public ElementOrder<N> incidentEdgeOrder() {
    return delegate().incidentEdgeOrder();
  }

  @Override
  public Set<N> adjacentNodes(N node) {
    return delegate().adjacentNodes(node);

            

Reported by PMD.

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

Line: 70

              
  @Override
  public Set<N> adjacentNodes(N node) {
    return delegate().adjacentNodes(node);
  }

  @Override
  public Set<N> predecessors(N node) {
    return delegate().predecessors(node);

            

Reported by PMD.

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

Line: 75

              
  @Override
  public Set<N> predecessors(N node) {
    return delegate().predecessors(node);
  }

  @Override
  public Set<N> successors(N node) {
    return delegate().successors(node);

            

Reported by PMD.

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

Line: 46

              @GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingDeque<E extends @Nullable Object> extends ForwardingQueue<E>
    implements Deque<E> {

  /** Constructor for use by subclasses. */
  protected ForwardingDeque() {}

  @Override

            

Reported by PMD.

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

Line: 56

              
  @Override
  public void addFirst(@ParametricNullness E e) {
    delegate().addFirst(e);
  }

  @Override
  public void addLast(@ParametricNullness E e) {
    delegate().addLast(e);

            

Reported by PMD.

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

Line: 61

              
  @Override
  public void addLast(@ParametricNullness E e) {
    delegate().addLast(e);
  }

  @Override
  public Iterator<E> descendingIterator() {
    return delegate().descendingIterator();

            

Reported by PMD.

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

Line: 66

              
  @Override
  public Iterator<E> descendingIterator() {
    return delegate().descendingIterator();
  }

  @Override
  @ParametricNullness
  public E getFirst() {

            

Reported by PMD.

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

Line: 72

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

  @Override
  @ParametricNullness
  public E getLast() {

            

Reported by PMD.

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

Line: 78

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

  @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
  @Override
  public boolean offerFirst(@ParametricNullness E e) {

            

Reported by PMD.

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

Line: 84

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

  @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
  @Override
  public boolean offerLast(@ParametricNullness E e) {

            

Reported by PMD.

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

Line: 90

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

  @Override
  @CheckForNull
  public E peekFirst() {

            

Reported by PMD.

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

Line: 96

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

  @Override
  @CheckForNull
  public E peekLast() {

            

Reported by PMD.

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

Line: 102

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

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

            

Reported by PMD.

android/guava/src/com/google/common/graph/AbstractBaseGraph.java
18 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 95

                      }
        EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
        return isOrderingCompatible(endpointPair)
            && nodes().contains(endpointPair.nodeU())
            && successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
      }
    };
  }


            

Reported by PMD.

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

Line: 95

                      }
        EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
        return isOrderingCompatible(endpointPair)
            && nodes().contains(endpointPair.nodeU())
            && successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
      }
    };
  }


            

Reported by PMD.

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

Line: 96

                      EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
        return isOrderingCompatible(endpointPair)
            && nodes().contains(endpointPair.nodeU())
            && successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
      }
    };
  }

  @Override

            

Reported by PMD.

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

Line: 96

                      EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
        return isOrderingCompatible(endpointPair)
            && nodes().contains(endpointPair.nodeU())
            && successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
      }
    };
  }

  @Override

            

Reported by PMD.

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

Line: 109

                @Override
  public Set<EndpointPair<N>> incidentEdges(N node) {
    checkNotNull(node);
    checkArgument(nodes().contains(node), "Node %s is not an element of this graph.", node);
    return new IncidentEdgeSet<N>(this, node) {
      @Override
      public UnmodifiableIterator<EndpointPair<N>> iterator() {
        if (graph.isDirected()) {
          return Iterators.unmodifiableIterator(

            

Reported by PMD.

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

Line: 117

                        return Iterators.unmodifiableIterator(
              Iterators.concat(
                  Iterators.transform(
                      graph.predecessors(node).iterator(),
                      new Function<N, EndpointPair<N>>() {
                        @Override
                        public EndpointPair<N> apply(N predecessor) {
                          return EndpointPair.ordered(predecessor, node);
                        }

            

Reported by PMD.

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

Line: 126

                                    }),
                  Iterators.transform(
                      // filter out 'node' from successors (already covered by predecessors, above)
                      Sets.difference(graph.successors(node), ImmutableSet.of(node)).iterator(),
                      new Function<N, EndpointPair<N>>() {
                        @Override
                        public EndpointPair<N> apply(N successor) {
                          return EndpointPair.ordered(node, successor);
                        }

            

Reported by PMD.

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

Line: 136

                      } else {
          return Iterators.unmodifiableIterator(
              Iterators.transform(
                  graph.adjacentNodes(node).iterator(),
                  new Function<N, EndpointPair<N>>() {
                    @Override
                    public EndpointPair<N> apply(N adjacentNode) {
                      return EndpointPair.unordered(node, adjacentNode);
                    }

            

Reported by PMD.

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

Line: 151

                @Override
  public int degree(N node) {
    if (isDirected()) {
      return IntMath.saturatedAdd(predecessors(node).size(), successors(node).size());
    } else {
      Set<N> neighbors = adjacentNodes(node);
      int selfLoopCount = (allowsSelfLoops() && neighbors.contains(node)) ? 1 : 0;
      return IntMath.saturatedAdd(neighbors.size(), selfLoopCount);
    }

            

Reported by PMD.

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

Line: 151

                @Override
  public int degree(N node) {
    if (isDirected()) {
      return IntMath.saturatedAdd(predecessors(node).size(), successors(node).size());
    } else {
      Set<N> neighbors = adjacentNodes(node);
      int selfLoopCount = (allowsSelfLoops() && neighbors.contains(node)) ? 1 : 0;
      return IntMath.saturatedAdd(neighbors.size(), selfLoopCount);
    }

            

Reported by PMD.