The following issues were found

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

Line: 69

                      + " GraphBuilder)")
@ElementTypesAreNonnullByDefault
public abstract class Traverser<N> {
  private final SuccessorsFunction<N> successorFunction;

  private Traverser(SuccessorsFunction<N> successorFunction) {
    this.successorFunction = checkNotNull(successorFunction);
  }


            

Reported by PMD.

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

Line: 246

                  return new Iterable<N>() {
      @Override
      public Iterator<N> iterator() {
        return newTraversal().breadthFirst(validated.iterator());
      }
    };
  }

  /**

            

Reported by PMD.

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

Line: 301

                  return new Iterable<N>() {
      @Override
      public Iterator<N> iterator() {
        return newTraversal().preOrder(validated.iterator());
      }
    };
  }

  /**

            

Reported by PMD.

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

Line: 356

                  return new Iterable<N>() {
      @Override
      public Iterator<N> iterator() {
        return newTraversal().postOrder(validated.iterator());
      }
    };
  }

  abstract Traversal<N> newTraversal();

            

Reported by PMD.

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

Line: 378

                 * non-empty iterator to find first unvisited node.
   */
  private abstract static class Traversal<N> {
    final SuccessorsFunction<N> successorFunction;

    Traversal(SuccessorsFunction<N> successorFunction) {
      this.successorFunction = successorFunction;
    }


            

Reported by PMD.

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

Line: 451

                        do {
            N next = visitNext(horizon);
            if (next != null) {
              Iterator<? extends N> successors = successorFunction.successors(next).iterator();
              if (successors.hasNext()) {
                // BFS: horizon.addLast(successors)
                // Pre-order: horizon.addFirst(successors)
                order.insertInto(horizon, successors);
              }

            

Reported by PMD.

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

Line: 474

                      @CheckForNull
        protected N computeNext() {
          for (N next = visitNext(horizon); next != null; next = visitNext(horizon)) {
            Iterator<? extends N> successors = successorFunction.successors(next).iterator();
            if (!successors.hasNext()) {
              return next;
            }
            horizon.addFirst(successors);
            ancestorStack.push(next);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'validated' (lines '242'-'249').
Error

Line: 242

                 * @since 24.1
   */
  public final Iterable<N> breadthFirst(Iterable<? extends N> startNodes) {
    final ImmutableSet<N> validated = validate(startNodes);
    return new Iterable<N>() {
      @Override
      public Iterator<N> iterator() {
        return newTraversal().breadthFirst(validated.iterator());
      }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'validated' (lines '242'-'249').
Error

Line: 242

                 * @since 24.1
   */
  public final Iterable<N> breadthFirst(Iterable<? extends N> startNodes) {
    final ImmutableSet<N> validated = validate(startNodes);
    return new Iterable<N>() {
      @Override
      public Iterator<N> iterator() {
        return newTraversal().breadthFirst(validated.iterator());
      }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'validated' (lines '297'-'304').
Error

Line: 297

                 * @since 24.1
   */
  public final Iterable<N> depthFirstPreOrder(Iterable<? extends N> startNodes) {
    final ImmutableSet<N> validated = validate(startNodes);
    return new Iterable<N>() {
      @Override
      public Iterator<N> iterator() {
        return newTraversal().preOrder(validated.iterator());
      }

            

Reported by PMD.

guava/src/com/google/common/collect/FluentIterable.java
17 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;

            

Reported by PMD.

Possible God Class (WMC=56, ATFD=8, TCC=0.000%)
Design

Line: 113

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class FluentIterable<E extends @Nullable Object> implements Iterable<E> {
  // We store 'iterable' and use it instead of 'this' to allow Iterables to perform instanceof
  // checks on the _original_ iterable when FluentIterable.from is used.
  // To avoid a self retain cycle under j2objc, we store Optional.absent() instead of
  // Optional.of(this). To access the delegate iterable, call #getDelegate(), which converts to
  // absent() back to 'this'.

            

Reported by PMD.

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

Line: 113

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class FluentIterable<E extends @Nullable Object> implements Iterable<E> {
  // We store 'iterable' and use it instead of 'this' to allow Iterables to perform instanceof
  // checks on the _original_ iterable when FluentIterable.from is used.
  // To avoid a self retain cycle under j2objc, we store Optional.absent() instead of
  // Optional.of(this). To access the delegate iterable, call #getDelegate(), which converts to
  // absent() back to 'this'.

            

Reported by PMD.

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

Line: 119

                // To avoid a self retain cycle under j2objc, we store Optional.absent() instead of
  // Optional.of(this). To access the delegate iterable, call #getDelegate(), which converts to
  // absent() back to 'this'.
  private final Optional<Iterable<E>> iterableDelegate;

  /** Constructor for use by subclasses. */
  protected FluentIterable() {
    this.iterableDelegate = Optional.absent();
  }

            

Reported by PMD.

The String literal 'nullness' appears 12 times in this file; the first occurrence is on line 474
Error

Line: 474

                 *
   * <p><b>{@code Stream} equivalent:</b> {@code stream.filter(predicate).findFirst()}.
   */
  @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
  public final Optional<E> firstMatch(Predicate<? super E> predicate) {
    return Iterables.tryFind(getDelegate(), predicate);
  }

  /**

            

Reported by PMD.

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

Line: 524

                 */
  @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
  public final Optional<E> first() {
    Iterator<E> iterator = getDelegate().iterator();
    return iterator.hasNext() ? Optional.of(iterator.next()) : Optional.<E>absent();
  }

  /**
   * Returns an {@link Optional} containing the last element in this fluent iterable. If the

            

Reported by PMD.

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

Line: 547

                  Iterable<E> iterable = getDelegate();
    if (iterable instanceof List) {
      List<E> list = (List<E>) iterable;
      if (list.isEmpty()) {
        return Optional.absent();
      }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();

            

Reported by PMD.

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

Line: 550

                    if (list.isEmpty()) {
        return Optional.absent();
      }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();
    if (!iterator.hasNext()) {
      return Optional.absent();
    }

            

Reported by PMD.

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

Line: 550

                    if (list.isEmpty()) {
        return Optional.absent();
      }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();
    if (!iterator.hasNext()) {
      return Optional.absent();
    }

            

Reported by PMD.

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

Line: 552

                    }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();
    if (!iterator.hasNext()) {
      return Optional.absent();
    }

    /*

            

Reported by PMD.

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

Line: 28

               * @author James Sexton
 */
@ElementTypesAreNonnullByDefault
abstract class ForwardingGraph<N> extends AbstractGraph<N> {

  abstract BaseGraph<N> delegate();

  @Override
  public Set<N> nodes() {

            

Reported by PMD.

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

Line: 34

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

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

            

Reported by PMD.

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

Line: 43

                 */
  @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: 43

                 */
  @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: 48

              
  @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: 53

              
  @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: 58

              
  @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: 63

              
  @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: 68

              
  @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: 73

              
  @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/FluentIterable.java
17 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;

            

Reported by PMD.

Possible God Class (WMC=55, ATFD=8, TCC=0.000%)
Design

Line: 116

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class FluentIterable<E extends @Nullable Object> implements Iterable<E> {
  // We store 'iterable' and use it instead of 'this' to allow Iterables to perform instanceof
  // checks on the _original_ iterable when FluentIterable.from is used.
  // To avoid a self retain cycle under j2objc, we store Optional.absent() instead of
  // Optional.of(this). To access the delegate iterable, call #getDelegate(), which converts to
  // absent() back to 'this'.

            

Reported by PMD.

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

Line: 116

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class FluentIterable<E extends @Nullable Object> implements Iterable<E> {
  // We store 'iterable' and use it instead of 'this' to allow Iterables to perform instanceof
  // checks on the _original_ iterable when FluentIterable.from is used.
  // To avoid a self retain cycle under j2objc, we store Optional.absent() instead of
  // Optional.of(this). To access the delegate iterable, call #getDelegate(), which converts to
  // absent() back to 'this'.

            

Reported by PMD.

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

Line: 122

                // To avoid a self retain cycle under j2objc, we store Optional.absent() instead of
  // Optional.of(this). To access the delegate iterable, call #getDelegate(), which converts to
  // absent() back to 'this'.
  private final Optional<Iterable<E>> iterableDelegate;

  /** Constructor for use by subclasses. */
  protected FluentIterable() {
    this.iterableDelegate = Optional.absent();
  }

            

Reported by PMD.

The String literal 'nullness' appears 12 times in this file; the first occurrence is on line 477
Error

Line: 477

                 *
   * <p><b>{@code Stream} equivalent:</b> {@code stream.filter(predicate).findFirst()}.
   */
  @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
  public final Optional<E> firstMatch(Predicate<? super E> predicate) {
    return Iterables.tryFind(getDelegate(), predicate);
  }

  /**

            

Reported by PMD.

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

Line: 527

                 */
  @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
  public final Optional<E> first() {
    Iterator<E> iterator = getDelegate().iterator();
    return iterator.hasNext() ? Optional.of(iterator.next()) : Optional.<E>absent();
  }

  /**
   * Returns an {@link Optional} containing the last element in this fluent iterable. If the

            

Reported by PMD.

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

Line: 550

                  Iterable<E> iterable = getDelegate();
    if (iterable instanceof List) {
      List<E> list = (List<E>) iterable;
      if (list.isEmpty()) {
        return Optional.absent();
      }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();

            

Reported by PMD.

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

Line: 553

                    if (list.isEmpty()) {
        return Optional.absent();
      }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();
    if (!iterator.hasNext()) {
      return Optional.absent();
    }

            

Reported by PMD.

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

Line: 553

                    if (list.isEmpty()) {
        return Optional.absent();
      }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();
    if (!iterator.hasNext()) {
      return Optional.absent();
    }

            

Reported by PMD.

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

Line: 555

                    }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();
    if (!iterator.hasNext()) {
      return Optional.absent();
    }

    /*

            

Reported by PMD.

android/guava/src/com/google/common/collect/CartesianList.java
17 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 43

                  ImmutableList.Builder<List<E>> axesBuilder = new ImmutableList.Builder<>(lists.size());
    for (List<? extends E> list : lists) {
      List<E> copy = ImmutableList.copyOf(list);
      if (copy.isEmpty()) {
        return ImmutableList.of();
      }
      axesBuilder.add(copy);
    }
    return new CartesianList<E>(axesBuilder.build());

            

Reported by PMD.

New exception is thrown in catch block, original stack trace may be lost
Design

Line: 60

                      axesSizeProduct[i] = IntMath.checkedMultiply(axesSizeProduct[i + 1], axes.get(i).size());
      }
    } catch (ArithmeticException e) {
      throw new IllegalArgumentException(
          "Cartesian product too large; must have size at most Integer.MAX_VALUE");
    }
    this.axesSizeProduct = axesSizeProduct;
  }


            

Reported by PMD.

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

Line: 67

                }

  private int getAxisIndexForProductIndex(int index, int axis) {
    return (index / axesSizeProduct[axis + 1]) % axes.get(axis).size();
  }

  @Override
  public int indexOf(@CheckForNull Object o) {
    if (!(o instanceof List)) {

            

Reported by PMD.

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

Line: 76

                    return -1;
    }
    List<?> list = (List<?>) o;
    if (list.size() != axes.size()) {
      return -1;
    }
    ListIterator<?> itr = list.listIterator();
    int computedIndex = 0;
    while (itr.hasNext()) {

            

Reported by PMD.

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

Line: 79

                  if (list.size() != axes.size()) {
      return -1;
    }
    ListIterator<?> itr = list.listIterator();
    int computedIndex = 0;
    while (itr.hasNext()) {
      int axisIndex = itr.nextIndex();
      int elemIndex = axes.get(axisIndex).indexOf(itr.next());
      if (elemIndex == -1) {

            

Reported by PMD.

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

Line: 83

                  int computedIndex = 0;
    while (itr.hasNext()) {
      int axisIndex = itr.nextIndex();
      int elemIndex = axes.get(axisIndex).indexOf(itr.next());
      if (elemIndex == -1) {
        return -1;
      }
      computedIndex += elemIndex * axesSizeProduct[axisIndex + 1];
    }

            

Reported by PMD.

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

Line: 98

                    return -1;
    }
    List<?> list = (List<?>) o;
    if (list.size() != axes.size()) {
      return -1;
    }
    ListIterator<?> itr = list.listIterator();
    int computedIndex = 0;
    while (itr.hasNext()) {

            

Reported by PMD.

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

Line: 101

                  if (list.size() != axes.size()) {
      return -1;
    }
    ListIterator<?> itr = list.listIterator();
    int computedIndex = 0;
    while (itr.hasNext()) {
      int axisIndex = itr.nextIndex();
      int elemIndex = axes.get(axisIndex).lastIndexOf(itr.next());
      if (elemIndex == -1) {

            

Reported by PMD.

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

Line: 105

                  int computedIndex = 0;
    while (itr.hasNext()) {
      int axisIndex = itr.nextIndex();
      int elemIndex = axes.get(axisIndex).lastIndexOf(itr.next());
      if (elemIndex == -1) {
        return -1;
      }
      computedIndex += elemIndex * axesSizeProduct[axisIndex + 1];
    }

            

Reported by PMD.

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

Line: 128

                    public E get(int axis) {
        checkElementIndex(axis, size());
        int axisIndex = getAxisIndexForProductIndex(index, axis);
        return axes.get(axis).get(axisIndex);
      }

      @Override
      boolean isPartialView() {
        return true;

            

Reported by PMD.

android/guava/src/com/google/common/io/Closer.java
17 issues
Avoid throwing raw exception types.
Design

Line: 153

                  checkNotNull(e);
    thrown = e;
    Throwables.propagateIfPossible(e, IOException.class);
    throw new RuntimeException(e);
  }

  /**
   * Stores the given throwable and rethrows it. It will be rethrown as is if it is an {@code
   * IOException}, {@code RuntimeException}, {@code Error} or a checked exception of the given type.

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 176

                  thrown = e;
    Throwables.propagateIfPossible(e, IOException.class);
    Throwables.propagateIfPossible(e, declaredType);
    throw new RuntimeException(e);
  }

  /**
   * Stores the given throwable and rethrows it. It will be rethrown as is if it is an {@code
   * IOException}, {@code RuntimeException}, {@code Error} or a checked exception of either of the

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 200

                  thrown = e;
    Throwables.propagateIfPossible(e, IOException.class);
    Throwables.propagateIfPossible(e, declaredType1, declaredType2);
    throw new RuntimeException(e);
  }

  /**
   * Closes all {@code Closeable} instances that have been added to this {@code Closer}. If an
   * exception was thrown in the try block and passed to one of the {@code exceptionThrown} methods,

            

Reported by PMD.

Logger calls should be surrounded by log level guards.
Design

Line: 254

                  @Override
    public void suppress(Closeable closeable, Throwable thrown, Throwable suppressed) {
      // log to the same place as Closeables
      Closeables.logger.log(
          Level.WARNING, "Suppressing exception thrown when closing " + closeable, suppressed);
    }
  }

  /**

            

Reported by PMD.

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

Line: 108

                  return new Closer(SUPPRESSOR);
  }

  @VisibleForTesting final Suppressor suppressor;

  // only need space for 2 elements in most cases, so try to use the smallest array possible
  private final Deque<Closeable> stack = new ArrayDeque<>(4);
  @CheckForNull private Throwable thrown;


            

Reported by PMD.

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

Line: 111

                @VisibleForTesting final Suppressor suppressor;

  // only need space for 2 elements in most cases, so try to use the smallest array possible
  private final Deque<Closeable> stack = new ArrayDeque<>(4);
  @CheckForNull private Throwable thrown;

  @VisibleForTesting
  Closer(Suppressor suppressor) {
    this.suppressor = checkNotNull(suppressor); // checkNotNull to satisfy null tests

            

Reported by PMD.

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

Line: 112

              
  // only need space for 2 elements in most cases, so try to use the smallest array possible
  private final Deque<Closeable> stack = new ArrayDeque<>(4);
  @CheckForNull private Throwable thrown;

  @VisibleForTesting
  Closer(Suppressor suppressor) {
    this.suppressor = checkNotNull(suppressor); // checkNotNull to satisfy null tests
  }

            

Reported by PMD.

Ensure that resources like this Closeable object are closed after use
Error

Line: 216

              
    // close closeables in LIFO order
    while (!stack.isEmpty()) {
      Closeable closeable = stack.removeFirst();
      try {
        closeable.close();
      } catch (Throwable e) {
        if (throwable == null) {
          throwable = e;

            

Reported by PMD.

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

Line: 218

                  while (!stack.isEmpty()) {
      Closeable closeable = stack.removeFirst();
      try {
        closeable.close();
      } catch (Throwable e) {
        if (throwable == null) {
          throwable = e;
        } else {
          suppressor.suppress(closeable, throwable, e);

            

Reported by PMD.

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

Line: 219

                    Closeable closeable = stack.removeFirst();
      try {
        closeable.close();
      } catch (Throwable e) {
        if (throwable == null) {
          throwable = e;
        } else {
          suppressor.suppress(closeable, throwable, e);
        }

            

Reported by PMD.

android/guava-tests/test/com/google/common/net/HttpHeadersTest.java
17 issues
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

               */
public class HttpHeadersTest extends TestCase {

  public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

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

Line: 39

                public void testConstantNameMatchesString() throws Exception {
    // Special case some of the weird HTTP Header names...
    ImmutableBiMap<String, String> specialCases =
        ImmutableBiMap.<String, String>builder()
            .put("CDN_LOOP", "CDN-Loop")
            .put("ETAG", "ETag")
            .put("SOURCE_MAP", "SourceMap")
            .put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
            .put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")

            

Reported by PMD.

android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
17 issues
This class has too many methods, consider refactoring it.
Design

Line: 37

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractExecutionThreadService implements Service {
  private static final Logger logger =
      Logger.getLogger(AbstractExecutionThreadService.class.getName());

  /* use AbstractService for state management */
  private final Service delegate =

            

Reported by PMD.

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

Line: 42

                    Logger.getLogger(AbstractExecutionThreadService.class.getName());

  /* use AbstractService for state management */
  private final Service delegate =
      new AbstractService() {
        @Override
        protected final void doStart() {
          Executor executor =
              MoreExecutors.renamingDecorator(

            

Reported by PMD.

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

Line: 66

                                  // which case we should skip right down to shutdown.
                    if (isRunning()) {
                      try {
                        AbstractExecutionThreadService.this.run();
                      } catch (Throwable t) {
                        try {
                          shutDown();
                        } catch (Exception ignored) {
                          // TODO(lukes): if guava ever moves to java7, this would be a good

            

Reported by PMD.

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

Line: 66

                                  // which case we should skip right down to shutdown.
                    if (isRunning()) {
                      try {
                        AbstractExecutionThreadService.this.run();
                      } catch (Throwable t) {
                        try {
                          shutDown();
                        } catch (Exception ignored) {
                          // TODO(lukes): if guava ever moves to java7, this would be a good

            

Reported by PMD.

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

Line: 67

                                  if (isRunning()) {
                      try {
                        AbstractExecutionThreadService.this.run();
                      } catch (Throwable t) {
                        try {
                          shutDown();
                        } catch (Exception ignored) {
                          // TODO(lukes): if guava ever moves to java7, this would be a good
                          // candidate for a suppressed exception, or maybe we could generalize

            

Reported by PMD.

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

Line: 70

                                    } catch (Throwable t) {
                        try {
                          shutDown();
                        } catch (Exception ignored) {
                          // TODO(lukes): if guava ever moves to java7, this would be a good
                          // candidate for a suppressed exception, or maybe we could generalize
                          // Closer.Suppressor
                          logger.log(
                              Level.WARNING,

            

Reported by PMD.

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

Line: 86

              
                    shutDown();
                    notifyStopped();
                  } catch (Throwable t) {
                    notifyFailed(t);
                  }
                }
              });
        }

            

Reported by PMD.

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

Line: 100

              
        @Override
        public String toString() {
          return AbstractExecutionThreadService.this.toString();
        }
      };

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

            

Reported by PMD.

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

Line: 100

              
        @Override
        public String toString() {
          return AbstractExecutionThreadService.this.toString();
        }
      };

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

            

Reported by PMD.

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

Line: 112

                 *
   * <p>By default this method does nothing.
   */
  protected void startUp() throws Exception {}

  /**
   * Run the service. This method is invoked on the execution thread. Implementations must respond
   * to stop requests. You could poll for lifecycle changes in a work loop:
   *

            

Reported by PMD.

guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java
17 issues
Avoid throwing null pointer exceptions.
Design

Line: 208

                private static <E> List<E> nullCheckedList(Object... array) {
    for (int i = 0, len = array.length; i < len; i++) {
      if (array[i] == null) {
        throw new NullPointerException("at index " + i);
      }
    }
    @SuppressWarnings("unchecked")
    E[] castedArray = (E[]) array;
    return Arrays.asList(castedArray);

            

Reported by PMD.

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

Line: 41

               */
@SuppressWarnings("serial") // we're overriding default serialization
public abstract class ImmutableList<E> extends ImmutableCollection<E>
    implements List<E>, RandomAccess {
  static final ImmutableList<Object> EMPTY =
      new RegularImmutableList<Object>(Collections.emptyList());

  ImmutableList() {}


            

Reported by PMD.

The String literal 'unchecked' appears 6 times in this file; the first occurrence is on line 52
Error

Line: 52

                }

  // Casting to any type is safe because the list will never hold any elements.
  @SuppressWarnings("unchecked")
  public static <E> ImmutableList<E> of() {
    return (ImmutableList<E>) EMPTY;
  }

  public static <E> ImmutableList<E> of(E element) {

            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 96

                      ImmutableList.<E>nullCheckedList(e1, e2, e3, e4, e5, e6, e7, e8, e9));
  }

  public static <E> ImmutableList<E> of(
      E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
    return new RegularImmutableList<E>(
        ImmutableList.<E>nullCheckedList(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10));
  }


            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 102

                      ImmutableList.<E>nullCheckedList(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10));
  }

  public static <E> ImmutableList<E> of(
      E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11) {
    return new RegularImmutableList<E>(
        ImmutableList.<E>nullCheckedList(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11));
  }


            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 108

                      ImmutableList.<E>nullCheckedList(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11));
  }

  public static <E> ImmutableList<E> of(
      E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11, E e12, E... others) {
    final int paramCount = 12;
    Object[] array = new Object[paramCount + others.length];
    arrayCopy(array, 0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12);
    arrayCopy(array, paramCount, others);

            

Reported by PMD.

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

Line: 140

                     */
      @SuppressWarnings("unchecked") // all supported methods are covariant
      ImmutableCollection<E> list = (ImmutableCollection<E>) elements;
      return list.asList();
    }
    return copyFromCollection(elements);
  }

  public static <E> ImmutableList<E> copyOf(E[] elements) {

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 206

                }

  private static <E> List<E> nullCheckedList(Object... array) {
    for (int i = 0, len = array.length; i < len; i++) {
      if (array[i] == null) {
        throw new NullPointerException("at index " + i);
      }
    }
    @SuppressWarnings("unchecked")

            

Reported by PMD.

The method 'addAll(int, Collection)' is missing an @Override annotation.
Design

Line: 226

                  return (object == null) ? -1 : Lists.lastIndexOfImpl(this, object);
  }

  public final boolean addAll(int index, Collection<? extends E> newElements) {
    throw new UnsupportedOperationException();
  }

  public final E set(int index, E element) {
    throw new UnsupportedOperationException();

            

Reported by PMD.

The method 'set(int, E)' is missing an @Override annotation.
Design

Line: 230

                  throw new UnsupportedOperationException();
  }

  public final E set(int index, E element) {
    throw new UnsupportedOperationException();
  }

  public final void add(int index, E element) {
    throw new UnsupportedOperationException();

            

Reported by PMD.

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

Line: 28

               * @author James Sexton
 */
@ElementTypesAreNonnullByDefault
abstract class ForwardingGraph<N> extends AbstractGraph<N> {

  abstract BaseGraph<N> delegate();

  @Override
  public Set<N> nodes() {

            

Reported by PMD.

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

Line: 34

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

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

            

Reported by PMD.

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

Line: 43

                 */
  @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: 43

                 */
  @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: 48

              
  @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: 53

              
  @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: 58

              
  @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: 63

              
  @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: 68

              
  @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: 73

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