The following issues were found

guava/src/com/google/common/cache/ForwardingCache.java
14 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 49

                @Override
  @CheckForNull
  public V getIfPresent(Object key) {
    return delegate().getIfPresent(key);
  }

  /** @since 11.0 */
  @Override
  public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {

            

Reported by PMD.

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

Line: 55

                /** @since 11.0 */
  @Override
  public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
    return delegate().get(key, valueLoader);
  }

  /** @since 11.0 */
  @Override
  /*

            

Reported by PMD.

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

Line: 65

                 * differ: <? extends Object> means "non-null types," while <?> means "all types."
   */
  public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) {
    return delegate().getAllPresent(keys);
  }

  /** @since 11.0 */
  @Override
  public void put(K key, V value) {

            

Reported by PMD.

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

Line: 71

                /** @since 11.0 */
  @Override
  public void put(K key, V value) {
    delegate().put(key, value);
  }

  /** @since 12.0 */
  @Override
  public void putAll(Map<? extends K, ? extends V> m) {

            

Reported by PMD.

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

Line: 77

                /** @since 12.0 */
  @Override
  public void putAll(Map<? extends K, ? extends V> m) {
    delegate().putAll(m);
  }

  @Override
  public void invalidate(Object key) {
    delegate().invalidate(key);

            

Reported by PMD.

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

Line: 82

              
  @Override
  public void invalidate(Object key) {
    delegate().invalidate(key);
  }

  /** @since 11.0 */
  @Override
  // For discussion of <? extends Object>, see getAllPresent.

            

Reported by PMD.

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

Line: 89

                @Override
  // For discussion of <? extends Object>, see getAllPresent.
  public void invalidateAll(Iterable<? extends Object> keys) {
    delegate().invalidateAll(keys);
  }

  @Override
  public void invalidateAll() {
    delegate().invalidateAll();

            

Reported by PMD.

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

Line: 94

              
  @Override
  public void invalidateAll() {
    delegate().invalidateAll();
  }

  @Override
  public long size() {
    return delegate().size();

            

Reported by PMD.

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

Line: 99

              
  @Override
  public long size() {
    return delegate().size();
  }

  @Override
  public CacheStats stats() {
    return delegate().stats();

            

Reported by PMD.

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

Line: 104

              
  @Override
  public CacheStats stats() {
    return delegate().stats();
  }

  @Override
  public ConcurrentMap<K, V> asMap() {
    return delegate().asMap();

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java
14 issues
This class name ends with Test but contains no test cases
Error

Line: 41

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class LongArrayAsListTest extends TestCase {

  private static List<Long> asList(Long[] values) {
    long[] temp = new long[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).

            

Reported by PMD.

JUnit 4 indicates test suites via annotations, not the suite method.
Design

Line: 51

                  return Longs.asList(temp);
  }

  @GwtIncompatible // suite
  public static Test suite() {
    List<ListTestSuiteBuilder<Long>> builders =
        ImmutableList.of(
            ListTestSuiteBuilder.using(new LongsAsListGenerator()).named("Longs.asList"),
            ListTestSuiteBuilder.using(new LongsAsListHeadSubListGenerator())

            

Reported by PMD.

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

Line: 66

                  TestSuite suite = new TestSuite();
    for (ListTestSuiteBuilder<Long> builder : builders) {
      suite.addTest(
          builder
              .withFeatures(
                  CollectionSize.ONE,
                  CollectionSize.SEVERAL,
                  CollectionFeature.RESTRICTS_ELEMENTS,
                  ListFeature.SUPPORTS_SET)

            

Reported by PMD.

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

Line: 92

                  protected List<Long> create(Long[] elements) {
      Long[] suffix = {Long.MIN_VALUE, Long.MAX_VALUE};
      Long[] all = concat(elements, suffix);
      return asList(all).subList(0, elements.length);
    }
  }

  public static final class LongsAsListTailSubListGenerator extends TestLongListGenerator {
    @Override

            

Reported by PMD.

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

Line: 101

                  protected List<Long> create(Long[] elements) {
      Long[] prefix = {(long) 86, (long) 99};
      Long[] all = concat(prefix, elements);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  public static final class LongsAsListMiddleSubListGenerator extends TestLongListGenerator {
    @Override

            

Reported by PMD.

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

Line: 111

                    Long[] prefix = {Long.MIN_VALUE, Long.MAX_VALUE};
      Long[] suffix = {(long) 86, (long) 99};
      Long[] all = concat(concat(prefix, elements), suffix);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  private static Long[] concat(Long[] left, Long[] right) {
    Long[] result = new Long[left.length + right.length];

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 43

              @GwtCompatible(emulated = true)
public class LongArrayAsListTest extends TestCase {

  private static List<Long> asList(Long[] values) {
    long[] temp = new long[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Longs.asList(temp);

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 115

                  }
  }

  private static Long[] concat(Long[] left, Long[] right) {
    Long[] result = new Long[left.length + right.length];
    System.arraycopy(left, 0, result, 0, left.length);
    System.arraycopy(right, 0, result, left.length, right.length);
    return result;
  }

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 142

                   * Creates a new collection containing the given elements; implement this method instead of
     * {@link #create(Object...)}.
     */
    protected abstract List<Long> create(Long[] elements);

    @Override
    public Long[] createArray(int length) {
      return new Long[length];
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'temp' (lines '44'-'46').
Error

Line: 44

              public class LongArrayAsListTest extends TestCase {

  private static List<Long> asList(Long[] values) {
    long[] temp = new long[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Longs.asList(temp);
  }

            

Reported by PMD.

guava/src/com/google/common/math/PairedStatsAccumulator.java
14 issues
This class has too many methods, consider refactoring it.
Design

Line: 36

              @Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class PairedStatsAccumulator {

  // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();

            

Reported by PMD.

Field xStats has the same name as a method
Error

Line: 40

              
  // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {

            

Reported by PMD.

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

Line: 40

              
  // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {

            

Reported by PMD.

Field yStats has the same name as a method
Error

Line: 41

                // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {
    // We extend the recursive expression for the one-variable case at Art of Computer Programming

            

Reported by PMD.

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

Line: 41

                // These fields must satisfy the requirements of PairedStats' constructor as well as those of the
  // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {
    // We extend the recursive expression for the one-variable case at Art of Computer Programming

            

Reported by PMD.

Avoid using redundant field initializer for 'sumOfProductsOfDeltas'
Performance

Line: 42

                // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {
    // We extend the recursive expression for the one-variable case at Art of Computer Programming
    // vol. 2, Knuth, 4.2.2, (16) to the two-variable case. We have two value series x_i and y_i.

            

Reported by PMD.

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

Line: 42

                // stat methods of this class.
  private final StatsAccumulator xStats = new StatsAccumulator();
  private final StatsAccumulator yStats = new StatsAccumulator();
  private double sumOfProductsOfDeltas = 0.0;

  /** Adds the given pair of values to the dataset. */
  public void add(double x, double y) {
    // We extend the recursive expression for the one-variable case at Art of Computer Programming
    // vol. 2, Knuth, 4.2.2, (16) to the two-variable case. We have two value series x_i and y_i.

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 59

                  //               = (x_n - X_n) (y_n - Y_{n-1})
    xStats.add(x);
    if (isFinite(x) && isFinite(y)) {
      if (xStats.count() > 1) {
        sumOfProductsOfDeltas += (x - xStats.mean()) * (y - yStats.mean());
      }
    } else {
      sumOfProductsOfDeltas = NaN;
    }

            

Reported by PMD.

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

Line: 86

                    // in NaN naturally.
      sumOfProductsOfDeltas +=
          values.sumOfProductsOfDeltas()
              + (values.xStats().mean() - xStats.mean())
                  * (values.yStats().mean() - yStats.mean())
                  * values.count();
    }
    yStats.addAll(values.yStats());
  }

            

Reported by PMD.

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

Line: 87

                    sumOfProductsOfDeltas +=
          values.sumOfProductsOfDeltas()
              + (values.xStats().mean() - xStats.mean())
                  * (values.yStats().mean() - yStats.mean())
                  * values.count();
    }
    yStats.addAll(values.yStats());
  }


            

Reported by PMD.

guava/src/com/google/common/math/ToDoubleRounder.java
14 issues
The class 'ToDoubleRounder' has a Standard Cyclomatic Complexity of 8 (Highest = 34).
Design

Line: 29

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ToDoubleRounder<X extends Number & Comparable<X>> {
  /**
   * Returns x rounded to either the greatest double less than or equal to the precise value of x,
   * or the least double greater than or equal to the precise value of x.
   */
  abstract double roundToDoubleArbitrarily(X x);

            

Reported by PMD.

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

Line: 29

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ToDoubleRounder<X extends Number & Comparable<X>> {
  /**
   * Returns x rounded to either the greatest double less than or equal to the precise value of x,
   * or the least double greater than or equal to the precise value of x.
   */
  abstract double roundToDoubleArbitrarily(X x);

            

Reported by PMD.

The method 'roundToDouble' has a Modified Cyclomatic Complexity of 23.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

The method 'roundToDouble' has a Standard Cyclomatic Complexity of 34.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

The method 'roundToDouble(X, RoundingMode)' has a NCSS line count of 78.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

The method 'roundToDouble(X, RoundingMode)' has an NPath complexity of 1089, current threshold is 200
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

The method 'roundToDouble(X, RoundingMode)' has a cyclomatic complexity of 42.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

Avoid really long methods.
Design

Line: 46

                abstract X minus(X a, X b);

  /** Rounds {@code x} to a {@code double}. */
  final double roundToDouble(X x, RoundingMode mode) {
    checkNotNull(x, "x");
    checkNotNull(mode, "mode");
    double roundArbitrarily = roundToDoubleArbitrarily(x);
    if (Double.isInfinite(roundArbitrarily)) {
      switch (mode) {

            

Reported by PMD.

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

Line: 128

              
          X deltaToFloor = minus(x, roundFloor);
          X deltaToCeiling = minus(roundCeiling, x);
          int diff = deltaToFloor.compareTo(deltaToCeiling);
          if (diff < 0) { // closer to floor
            return roundFloorAsDouble;
          } else if (diff > 0) { // closer to ceiling
            return roundCeilingAsDouble;
          }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'cmpXToRoundArbitrarily' (lines '72'-'152').
Error

Line: 72

                    }
    }
    X roundArbitrarilyAsX = toX(roundArbitrarily, RoundingMode.UNNECESSARY);
    int cmpXToRoundArbitrarily = x.compareTo(roundArbitrarilyAsX);
    switch (mode) {
      case UNNECESSARY:
        checkRoundingUnnecessary(cmpXToRoundArbitrarily == 0);
        return roundArbitrarily;
      case FLOOR:

            

Reported by PMD.

android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java
14 issues
Avoid reassigning parameters such as 'args'
Design

Line: 65

                 */
  @Override
  @CheckForNull
  public final Object invoke(Object proxy, Method method, @CheckForNull @Nullable Object[] args)
      throws Throwable {
    if (args == null) {
      args = NO_ARGS;
    }
    if (args.length == 0 && method.getName().equals("hashCode")) {

            

Reported by PMD.

The method 'invoke(Object, Method, Object)' has a cyclomatic complexity of 11.
Design

Line: 65

                 */
  @Override
  @CheckForNull
  public final Object invoke(Object proxy, Method method, @CheckForNull @Nullable Object[] args)
      throws Throwable {
    if (args == null) {
      args = NO_ARGS;
    }
    if (args.length == 0 && method.getName().equals("hashCode")) {

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 70

                  if (args == null) {
      args = NO_ARGS;
    }
    if (args.length == 0 && method.getName().equals("hashCode")) {
      return hashCode();
    }
    if (args.length == 1
        && method.getName().equals("equals")
        && method.getParameterTypes()[0] == Object.class) {

            

Reported by PMD.

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

Line: 70

                  if (args == null) {
      args = NO_ARGS;
    }
    if (args.length == 0 && method.getName().equals("hashCode")) {
      return hashCode();
    }
    if (args.length == 1
        && method.getName().equals("equals")
        && method.getParameterTypes()[0] == Object.class) {

            

Reported by PMD.

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

Line: 74

                    return hashCode();
    }
    if (args.length == 1
        && method.getName().equals("equals")
        && method.getParameterTypes()[0] == Object.class) {
      Object arg = args[0];
      if (arg == null) {
        return false;
      }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 74

                    return hashCode();
    }
    if (args.length == 1
        && method.getName().equals("equals")
        && method.getParameterTypes()[0] == Object.class) {
      Object arg = args[0];
      if (arg == null) {
        return false;
      }

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 80

                    if (arg == null) {
        return false;
      }
      if (proxy == arg) {
        return true;
      }
      return isProxyOfSameInterfaces(arg, proxy.getClass())
          && equals(Proxy.getInvocationHandler(arg));
    }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 86

                    return isProxyOfSameInterfaces(arg, proxy.getClass())
          && equals(Proxy.getInvocationHandler(arg));
    }
    if (args.length == 0 && method.getName().equals("toString")) {
      return toString();
    }
    return handleInvocation(proxy, method, args);
  }


            

Reported by PMD.

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

Line: 86

                    return isProxyOfSameInterfaces(arg, proxy.getClass())
          && equals(Proxy.getInvocationHandler(arg));
    }
    if (args.length == 0 && method.getName().equals("toString")) {
      return toString();
    }
    return handleInvocation(proxy, method, args);
  }


            

Reported by PMD.

Overriding method merely calls super
Design

Line: 116

                 * <p>Subclasses can override this method to provide custom equality.
   */
  @Override
  public boolean equals(@CheckForNull Object obj) {
    return super.equals(obj);
  }

  /**
   * By default delegates to {@link Object#hashCode}. The dynamic proxies' {@code hashCode()} will

            

Reported by PMD.

android/guava/src/com/google/common/cache/ForwardingCache.java
14 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 49

                @Override
  @CheckForNull
  public V getIfPresent(Object key) {
    return delegate().getIfPresent(key);
  }

  /** @since 11.0 */
  @Override
  public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {

            

Reported by PMD.

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

Line: 55

                /** @since 11.0 */
  @Override
  public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
    return delegate().get(key, valueLoader);
  }

  /** @since 11.0 */
  @Override
  /*

            

Reported by PMD.

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

Line: 65

                 * differ: <? extends Object> means "non-null types," while <?> means "all types."
   */
  public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) {
    return delegate().getAllPresent(keys);
  }

  /** @since 11.0 */
  @Override
  public void put(K key, V value) {

            

Reported by PMD.

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

Line: 71

                /** @since 11.0 */
  @Override
  public void put(K key, V value) {
    delegate().put(key, value);
  }

  /** @since 12.0 */
  @Override
  public void putAll(Map<? extends K, ? extends V> m) {

            

Reported by PMD.

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

Line: 77

                /** @since 12.0 */
  @Override
  public void putAll(Map<? extends K, ? extends V> m) {
    delegate().putAll(m);
  }

  @Override
  public void invalidate(Object key) {
    delegate().invalidate(key);

            

Reported by PMD.

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

Line: 82

              
  @Override
  public void invalidate(Object key) {
    delegate().invalidate(key);
  }

  /** @since 11.0 */
  @Override
  // For discussion of <? extends Object>, see getAllPresent.

            

Reported by PMD.

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

Line: 89

                @Override
  // For discussion of <? extends Object>, see getAllPresent.
  public void invalidateAll(Iterable<? extends Object> keys) {
    delegate().invalidateAll(keys);
  }

  @Override
  public void invalidateAll() {
    delegate().invalidateAll();

            

Reported by PMD.

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

Line: 94

              
  @Override
  public void invalidateAll() {
    delegate().invalidateAll();
  }

  @Override
  public long size() {
    return delegate().size();

            

Reported by PMD.

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

Line: 99

              
  @Override
  public long size() {
    return delegate().size();
  }

  @Override
  public CacheStats stats() {
    return delegate().stats();

            

Reported by PMD.

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

Line: 104

              
  @Override
  public CacheStats stats() {
    return delegate().stats();
  }

  @Override
  public ConcurrentMap<K, V> asMap() {
    return delegate().asMap();

            

Reported by PMD.

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

Line: 34

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
  static final class RegularEntrySet<K, V> extends ImmutableMapEntrySet<K, V> {
    private final transient ImmutableMap<K, V> map;
    private final transient ImmutableList<Entry<K, V>> entries;

    RegularEntrySet(ImmutableMap<K, V> map, Entry<K, V>[] entries) {

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 35

              @GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
  static final class RegularEntrySet<K, V> extends ImmutableMapEntrySet<K, V> {
    private final transient ImmutableMap<K, V> map;
    private final transient ImmutableList<Entry<K, V>> entries;

    RegularEntrySet(ImmutableMap<K, V> map, Entry<K, V>[] entries) {
      this(map, ImmutableList.<Entry<K, V>>asImmutableList(entries));

            

Reported by PMD.

Field map has the same name as a method
Error

Line: 36

              @ElementTypesAreNonnullByDefault
abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
  static final class RegularEntrySet<K, V> extends ImmutableMapEntrySet<K, V> {
    private final transient ImmutableMap<K, V> map;
    private final transient ImmutableList<Entry<K, V>> entries;

    RegularEntrySet(ImmutableMap<K, V> map, Entry<K, V>[] entries) {
      this(map, ImmutableList.<Entry<K, V>>asImmutableList(entries));
    }

            

Reported by PMD.

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

Line: 76

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

  @Override
  public boolean contains(@CheckForNull Object object) {
    if (object instanceof Entry) {

            

Reported by PMD.

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

Line: 83

                public boolean contains(@CheckForNull Object object) {
    if (object instanceof Entry) {
      Entry<?, ?> entry = (Entry<?, ?>) object;
      V value = map().get(entry.getKey());
      return value != null && value.equals(entry.getValue());
    }
    return false;
  }


            

Reported by PMD.

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

Line: 83

                public boolean contains(@CheckForNull Object object) {
    if (object instanceof Entry) {
      Entry<?, ?> entry = (Entry<?, ?>) object;
      V value = map().get(entry.getKey());
      return value != null && value.equals(entry.getValue());
    }
    return false;
  }


            

Reported by PMD.

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

Line: 84

                  if (object instanceof Entry) {
      Entry<?, ?> entry = (Entry<?, ?>) object;
      V value = map().get(entry.getKey());
      return value != null && value.equals(entry.getValue());
    }
    return false;
  }

  @Override

            

Reported by PMD.

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

Line: 84

                  if (object instanceof Entry) {
      Entry<?, ?> entry = (Entry<?, ?>) object;
      V value = map().get(entry.getKey());
      return value != null && value.equals(entry.getValue());
    }
    return false;
  }

  @Override

            

Reported by PMD.

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

Line: 91

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

  @Override
  @GwtIncompatible // not used in GWT
  boolean isHashCodeFast() {

            

Reported by PMD.

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

Line: 97

                @Override
  @GwtIncompatible // not used in GWT
  boolean isHashCodeFast() {
    return map().isHashCodeFast();
  }

  @Override
  public int hashCode() {
    return map().hashCode();

            

Reported by PMD.

android/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java
14 issues
This class name ends with Test but contains no test cases
Error

Line: 41

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class DoubleArrayAsListTest extends TestCase {

  private static List<Double> asList(Double[] values) {
    double[] temp = new double[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).

            

Reported by PMD.

JUnit 4 indicates test suites via annotations, not the suite method.
Design

Line: 51

                  return Doubles.asList(temp);
  }

  @GwtIncompatible // suite
  public static Test suite() {
    List<ListTestSuiteBuilder<Double>> builders =
        ImmutableList.of(
            ListTestSuiteBuilder.using(new DoublesAsListGenerator()).named("Doubles.asList"),
            ListTestSuiteBuilder.using(new DoublsAsListHeadSubListGenerator())

            

Reported by PMD.

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

Line: 66

                  TestSuite suite = new TestSuite();
    for (ListTestSuiteBuilder<Double> builder : builders) {
      suite.addTest(
          builder
              .withFeatures(
                  CollectionSize.ONE,
                  CollectionSize.SEVERAL,
                  CollectionFeature.RESTRICTS_ELEMENTS,
                  ListFeature.SUPPORTS_SET)

            

Reported by PMD.

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

Line: 92

                  protected List<Double> create(Double[] elements) {
      Double[] suffix = {Double.MIN_VALUE, Double.MAX_VALUE};
      Double[] all = concat(elements, suffix);
      return asList(all).subList(0, elements.length);
    }
  }

  public static final class DoublesAsListTailSubListGenerator extends TestDoubleListGenerator {
    @Override

            

Reported by PMD.

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

Line: 101

                  protected List<Double> create(Double[] elements) {
      Double[] prefix = {(double) 86, (double) 99};
      Double[] all = concat(prefix, elements);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  public static final class DoublesAsListMiddleSubListGenerator extends TestDoubleListGenerator {
    @Override

            

Reported by PMD.

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

Line: 111

                    Double[] prefix = {Double.MIN_VALUE, Double.MAX_VALUE};
      Double[] suffix = {(double) 86, (double) 99};
      Double[] all = concat(concat(prefix, elements), suffix);
      return asList(all).subList(2, elements.length + 2);
    }
  }

  private static Double[] concat(Double[] left, Double[] right) {
    Double[] result = new Double[left.length + right.length];

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 43

              @GwtCompatible(emulated = true)
public class DoubleArrayAsListTest extends TestCase {

  private static List<Double> asList(Double[] values) {
    double[] temp = new double[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Doubles.asList(temp);

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 115

                  }
  }

  private static Double[] concat(Double[] left, Double[] right) {
    Double[] result = new Double[left.length + right.length];
    System.arraycopy(left, 0, result, 0, left.length);
    System.arraycopy(right, 0, result, left.length, right.length);
    return result;
  }

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 142

                   * Creates a new collection containing the given elements; implement this method instead of
     * {@link #create(Object...)}.
     */
    protected abstract List<Double> create(Double[] elements);

    @Override
    public Double[] createArray(int length) {
      return new Double[length];
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'temp' (lines '44'-'46').
Error

Line: 44

              public class DoubleArrayAsListTest extends TestCase {

  private static List<Double> asList(Double[] values) {
    double[] temp = new double[values.length];
    for (int i = 0; i < values.length; i++) {
      temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
    }
    return Doubles.asList(temp);
  }

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MapGenerators.java
14 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 89

                    for (UnhashableObject value : elements) {
        builder.put(key++, value);
      }
      return builder.build().values();
    }
  }

  public static class ImmutableMapKeyListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 100

                    for (int i = 0; i < elements.length; i++) {
        builder.put(elements[i], i);
      }
      return builder.build().keySet().asList();
    }
  }

  public static class ImmutableMapValueListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 100

                    for (int i = 0; i < elements.length; i++) {
        builder.put(elements[i], i);
      }
      return builder.build().keySet().asList();
    }
  }

  public static class ImmutableMapValueListGenerator extends TestStringListGenerator {
    @Override

            

Reported by PMD.

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

Line: 111

                    for (int i = 0; i < elements.length; i++) {
        builder.put(i, elements[i]);
      }
      return builder.build().values().asList();
    }
  }

  public static class ImmutableMapEntryListGenerator
      implements TestListGenerator<Entry<String, Integer>> {

            

Reported by PMD.

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

Line: 111

                    for (int i = 0; i < elements.length; i++) {
        builder.put(i, elements[i]);
      }
      return builder.build().values().asList();
    }
  }

  public static class ImmutableMapEntryListGenerator
      implements TestListGenerator<Entry<String, Integer>> {

            

Reported by PMD.

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

Line: 128

                        mapEntry("toaster", -2));
    }

    @SuppressWarnings("unchecked")
    @Override
    public Entry<String, Integer>[] createArray(int length) {
      return new Entry[length];
    }


            

Reported by PMD.

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

Line: 147

                      Entry<String, Integer> entry = (Entry<String, Integer>) o;
        builder.put(entry);
      }
      return builder.build().entrySet().asList();
    }
  }

  public static class ImmutableEnumMapGenerator extends TestEnumMapGenerator {
    @Override

            

Reported by PMD.

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

Line: 147

                      Entry<String, Integer> entry = (Entry<String, Integer>) o;
        builder.put(entry);
      }
      return builder.build().entrySet().asList();
    }
  }

  public static class ImmutableEnumMapGenerator extends TestEnumMapGenerator {
    @Override

            

Reported by PMD.

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

Line: 179

              
        @Override
        public int compare(Entry<AnEnum, String> left, Entry<AnEnum, String> right) {
          return left.getKey().compareTo(right.getKey());
        }
      }.sortedCopy(insertionOrder);
    }
  }


            

Reported by PMD.

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

Line: 210

                    for (Object elem : elements) {
        @SuppressWarnings("unchecked") // safe by generator contract
        Entry<String, Collection<Integer>> entry = (Entry<String, Collection<Integer>>) elem;
        Integer value = Iterables.getOnlyElement(entry.getValue());
        builder.put(entry.getKey(), value);
      }
      return builder.build().asMultimap().asMap();
    }


            

Reported by PMD.

android/guava/src/com/google/common/primitives/UnsignedLongs.java
14 issues
Avoid reassigning parameters such as 'x'
Design

Line: 457

                 * @throws IllegalArgumentException if {@code radix} is not between {@link Character#MIN_RADIX}
   *     and {@link Character#MAX_RADIX}.
   */
  public static String toString(long x, int radix) {
    checkArgument(
        radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX,
        "radix (%s) must be between Character.MIN_RADIX and Character.MAX_RADIX",
        radix);
    if (x == 0) {

            

Reported by PMD.

Avoid reassigning parameters such as 'x'
Design

Line: 457

                 * @throws IllegalArgumentException if {@code radix} is not between {@link Character#MIN_RADIX}
   *     and {@link Character#MAX_RADIX}.
   */
  public static String toString(long x, int radix) {
    checkArgument(
        radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX,
        "radix (%s) must be between Character.MIN_RADIX and Character.MAX_RADIX",
        radix);
    if (x == 0) {

            

Reported by PMD.

Avoid reassigning parameters such as 'x'
Design

Line: 457

                 * @throws IllegalArgumentException if {@code radix} is not between {@link Character#MIN_RADIX}
   *     and {@link Character#MAX_RADIX}.
   */
  public static String toString(long x, int radix) {
    checkArgument(
        radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX,
        "radix (%s) must be between Character.MIN_RADIX and Character.MAX_RADIX",
        radix);
    if (x == 0) {

            

Reported by PMD.

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

Line: 54

              @Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class UnsignedLongs {
  private UnsignedLongs() {}

  public static final long MAX_VALUE = -1L; // Equivalent to 2^64 - 1

  /**

            

Reported by PMD.

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

Line: 54

              @Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class UnsignedLongs {
  private UnsignedLongs() {}

  public static final long MAX_VALUE = -1L; // Equivalent to 2^64 - 1

  /**

            

Reported by PMD.

The method 'parseUnsignedLong(String, int)' has a cyclomatic complexity of 12.
Design

Line: 338

                 *     Long#parseLong(String)})
   */
  @CanIgnoreReturnValue
  public static long parseUnsignedLong(String string, int radix) {
    checkNotNull(string);
    if (string.length() == 0) {
      throw new NumberFormatException("empty string");
    }
    if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 186

                 *
   * @since 23.1
   */
  public static void sort(long[] array) {
    checkNotNull(array);
    sort(array, 0, array.length);
  }

  /**

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 215

                 *
   * @since 23.1
   */
  public static void sortDescending(long[] array) {
    checkNotNull(array);
    sortDescending(array, 0, array.length);
  }

  /**

            

Reported by PMD.

Found 'DU'-anomaly for variable 'maxSafePos' (lines '347'-'361').
Error

Line: 347

                    throw new NumberFormatException("illegal radix: " + radix);
    }

    int maxSafePos = ParseOverflowDetection.maxSafeDigits[radix] - 1;
    long value = 0;
    for (int pos = 0; pos < string.length(); pos++) {
      int digit = Character.digit(string.charAt(pos), radix);
      if (digit == -1) {
        throw new NumberFormatException(string);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'value' (lines '348'-'361').
Error

Line: 348

                  }

    int maxSafePos = ParseOverflowDetection.maxSafeDigits[radix] - 1;
    long value = 0;
    for (int pos = 0; pos < string.length(); pos++) {
      int digit = Character.digit(string.charAt(pos), radix);
      if (digit == -1) {
        throw new NumberFormatException(string);
      }

            

Reported by PMD.