The following issues were found

android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java
98 issues
Avoid throwing raw exception types.
Design

Line: 196

                    doTestNulls(cls, Visibility.PACKAGE);
    } catch (Exception e) {
      throwIfUnchecked(e);
      throw new RuntimeException(e);
    }
  }

  void doTestNulls(Class<?> cls, Visibility visibility)
      throws ParameterNotInstantiableException, IllegalAccessException, InvocationTargetException,

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 288

                    doTestEquals(cls);
    } catch (Exception e) {
      throwIfUnchecked(e);
      throw new RuntimeException(e);
    }
  }

  void doTestEquals(Class<?> cls)
      throws ParameterNotInstantiableException, ParameterHasNoDistinctValueException,

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.testing.NullPointerTester.isNullable;

            

Reported by PMD.

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

Line: 83

               */
@Beta
@GwtIncompatible
public final class ClassSanityTester {

  private static final Ordering<Invokable<?, ?>> BY_METHOD_NAME =
      new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {

            

Reported by PMD.

The class 'ClassSanityTester' has a total cyclomatic complexity of 87 (highest 11).
Design

Line: 83

               */
@Beta
@GwtIncompatible
public final class ClassSanityTester {

  private static final Ordering<Invokable<?, ?>> BY_METHOD_NAME =
      new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {

            

Reported by PMD.

Possible God Class (WMC=87, ATFD=70, TCC=1.449%)
Design

Line: 83

               */
@Beta
@GwtIncompatible
public final class ClassSanityTester {

  private static final Ordering<Invokable<?, ?>> BY_METHOD_NAME =
      new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {

            

Reported by PMD.

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

Line: 89

                    new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
          return left.getName().compareTo(right.getName());
        }
      };

  private static final Ordering<Invokable<?, ?>> BY_PARAMETERS =
      new Ordering<Invokable<?, ?>>() {

            

Reported by PMD.

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

Line: 97

                    new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
          return Ordering.usingToString().compare(left.getParameters(), right.getParameters());
        }
      };

  private static final Ordering<Invokable<?, ?>> BY_NUMBER_OF_PARAMETERS =
      new Ordering<Invokable<?, ?>>() {

            

Reported by PMD.

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

Line: 105

                    new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
          return Ints.compare(left.getParameters().size(), right.getParameters().size());
        }
      };

  private final MutableClassToInstanceMap<Object> defaultValues =
      MutableClassToInstanceMap.create();

            

Reported by PMD.

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

Line: 105

                    new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
          return Ints.compare(left.getParameters().size(), right.getParameters().size());
        }
      };

  private final MutableClassToInstanceMap<Object> defaultValues =
      MutableClassToInstanceMap.create();

            

Reported by PMD.

guava/src/com/google/common/collect/CompactHashMap.java
98 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.CompactHashing.UNSET;
import static com.google.common.collect.Hashing.smearedHash;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 84

               */
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMap<K, V> implements Serializable {
  /*
   * TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
   * world. Figure out what sort of space-time tradeoff we're actually going to get here with the
   * *Map variants. This class is particularly hard to benchmark, because the benefit is not only in

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 84

               */
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMap<K, V> implements Serializable {
  /*
   * TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
   * world. Figure out what sort of space-time tradeoff we're actually going to get here with the
   * *Map variants. This class is particularly hard to benchmark, because the benefit is not only in

            

Reported by PMD.

Possible God Class (WMC=113, ATFD=20, TCC=5.051%)
Design

Line: 84

               */
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMap<K, V> implements Serializable {
  /*
   * TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
   * world. Figure out what sort of space-time tradeoff we're actually going to get here with the
   * *Map variants. This class is particularly hard to benchmark, because the benefit is not only in

            

Reported by PMD.

The class 'CompactHashMap' has a total cyclomatic complexity of 113 (highest 10).
Design

Line: 84

               */
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMap<K, V> implements Serializable {
  /*
   * TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
   * world. Figure out what sort of space-time tradeoff we're actually going to get here with the
   * *Map variants. This class is particularly hard to benchmark, because the benefit is not only in

            

Reported by PMD.

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

Line: 85

              @GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMap<K, V> implements Serializable {
  /*
   * TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
   * world. Figure out what sort of space-time tradeoff we're actually going to get here with the
   * *Map variants. This class is particularly hard to benchmark, because the benefit is not only in
   * less allocation, but also having the GC do less work to scan the heap because of fewer

            

Reported by PMD.

Field values has the same name as a method
Error

Line: 218

                 * The values of the entries in the map, in the range of [0, size()). The values in [size(),
   * values.length) are all {@code null}.
   */
  @VisibleForTesting @CheckForNull transient @Nullable Object[] values;

  /**
   * Keeps track of metadata like the number of hash table bits and modifications of this data
   * structure (to make it possible to throw ConcurrentModificationException in the iterator). Note
   * that we choose not to make this volatile, so we do less of a "best effort" to track such

            

Reported by PMD.

Field size has the same name as a method
Error

Line: 235

                private transient int metadata;

  /** The number of elements contained in the set. */
  private transient int size;

  /** Constructs a new empty instance of {@code CompactHashMap}. */
  CompactHashMap() {
    init(CompactHashing.DEFAULT_SIZE);
  }

            

Reported by PMD.

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

Line: 282

                  return expectedSize;
  }

  @SuppressWarnings("unchecked")
  @VisibleForTesting
  @CheckForNull
  Map<K, V> delegateOrNull() {
    if (table instanceof Map) {
      return (Map<K, V>) table;

            

Reported by PMD.

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

Line: 304

                    newDelegate.put(key(i), value(i));
    }
    this.table = newDelegate;
    this.entries = null;
    this.keys = null;
    this.values = null;
    incrementModCount();
    return newDelegate;
  }

            

Reported by PMD.

guava/src/com/google/common/reflect/TypeToken.java
98 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 15

               * the License.
 */

package com.google.common.reflect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;

            

Reported by PMD.

The class 'TypeToken' has a total cyclomatic complexity of 128 (highest 8).
Design

Line: 103

              @Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {

  private final Type runtimeType;

  /** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
  @CheckForNull private transient TypeResolver invariantTypeResolver;

            

Reported by PMD.

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

Line: 103

              @Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {

  private final Type runtimeType;

  /** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
  @CheckForNull private transient TypeResolver invariantTypeResolver;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 103

              @Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {

  private final Type runtimeType;

  /** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
  @CheckForNull private transient TypeResolver invariantTypeResolver;

            

Reported by PMD.

Possible God Class (WMC=128, ATFD=95, TCC=12.649%)
Design

Line: 103

              @Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {

  private final Type runtimeType;

  /** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
  @CheckForNull private transient TypeResolver invariantTypeResolver;

            

Reported by PMD.

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

Line: 196

                 */
  public final Class<? super T> getRawType() {
    // For wildcard or type variable, the first bound determines the runtime type.
    Class<?> rawType = getRawTypes().iterator().next();
    @SuppressWarnings("unchecked") // raw type is |T|
    Class<? super T> result = (Class<? super T>) rawType;
    return result;
  }


            

Reported by PMD.

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

Line: 196

                 */
  public final Class<? super T> getRawType() {
    // For wildcard or type variable, the first bound determines the runtime type.
    Class<?> rawType = getRawTypes().iterator().next();
    @SuppressWarnings("unchecked") // raw type is |T|
    Class<? super T> result = (Class<? super T>) rawType;
    return result;
  }


            

Reported by PMD.

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

Line: 197

                public final Class<? super T> getRawType() {
    // For wildcard or type variable, the first bound determines the runtime type.
    Class<?> rawType = getRawTypes().iterator().next();
    @SuppressWarnings("unchecked") // raw type is |T|
    Class<? super T> result = (Class<? super T>) rawType;
    return result;
  }

  /** Returns the represented type. */

            

Reported by PMD.

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

Line: 285

                  checkNotNull(type);
    // Being conservative here because the user could use resolveType() to resolve a type in an
    // invariant context.
    return of(getInvariantTypeResolver().resolveType(type));
  }

  private TypeToken<?> resolveSupertype(Type type) {
    TypeToken<?> supertype = of(getCovariantTypeResolver().resolveType(type));
    // super types' type mapping is a subset of type mapping of this type.

            

Reported by PMD.

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

Line: 289

                }

  private TypeToken<?> resolveSupertype(Type type) {
    TypeToken<?> supertype = of(getCovariantTypeResolver().resolveType(type));
    // super types' type mapping is a subset of type mapping of this type.
    supertype.covariantTypeResolver = covariantTypeResolver;
    supertype.invariantTypeResolver = invariantTypeResolver;
    return supertype;
  }

            

Reported by PMD.

android/guava/src/com/google/common/reflect/TypeToken.java
98 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 15

               * the License.
 */

package com.google.common.reflect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;

            

Reported by PMD.

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

Line: 103

              @Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {

  private final Type runtimeType;

  /** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
  @CheckForNull private transient TypeResolver invariantTypeResolver;

            

Reported by PMD.

Possible God Class (WMC=128, ATFD=95, TCC=12.649%)
Design

Line: 103

              @Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {

  private final Type runtimeType;

  /** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
  @CheckForNull private transient TypeResolver invariantTypeResolver;

            

Reported by PMD.

The class 'TypeToken' has a total cyclomatic complexity of 128 (highest 8).
Design

Line: 103

              @Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {

  private final Type runtimeType;

  /** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
  @CheckForNull private transient TypeResolver invariantTypeResolver;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 103

              @Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {

  private final Type runtimeType;

  /** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
  @CheckForNull private transient TypeResolver invariantTypeResolver;

            

Reported by PMD.

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

Line: 196

                 */
  public final Class<? super T> getRawType() {
    // For wildcard or type variable, the first bound determines the runtime type.
    Class<?> rawType = getRawTypes().iterator().next();
    @SuppressWarnings("unchecked") // raw type is |T|
    Class<? super T> result = (Class<? super T>) rawType;
    return result;
  }


            

Reported by PMD.

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

Line: 196

                 */
  public final Class<? super T> getRawType() {
    // For wildcard or type variable, the first bound determines the runtime type.
    Class<?> rawType = getRawTypes().iterator().next();
    @SuppressWarnings("unchecked") // raw type is |T|
    Class<? super T> result = (Class<? super T>) rawType;
    return result;
  }


            

Reported by PMD.

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

Line: 197

                public final Class<? super T> getRawType() {
    // For wildcard or type variable, the first bound determines the runtime type.
    Class<?> rawType = getRawTypes().iterator().next();
    @SuppressWarnings("unchecked") // raw type is |T|
    Class<? super T> result = (Class<? super T>) rawType;
    return result;
  }

  /** Returns the represented type. */

            

Reported by PMD.

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

Line: 285

                  checkNotNull(type);
    // Being conservative here because the user could use resolveType() to resolve a type in an
    // invariant context.
    return of(getInvariantTypeResolver().resolveType(type));
  }

  private TypeToken<?> resolveSupertype(Type type) {
    TypeToken<?> supertype = of(getCovariantTypeResolver().resolveType(type));
    // super types' type mapping is a subset of type mapping of this type.

            

Reported by PMD.

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

Line: 289

                }

  private TypeToken<?> resolveSupertype(Type type) {
    TypeToken<?> supertype = of(getCovariantTypeResolver().resolveType(type));
    // super types' type mapping is a subset of type mapping of this type.
    supertype.covariantTypeResolver = covariantTypeResolver;
    supertype.invariantTypeResolver = invariantTypeResolver;
    return supertype;
  }

            

Reported by PMD.

guava-testlib/src/com/google/common/testing/ClassSanityTester.java
98 issues
Avoid throwing raw exception types.
Design

Line: 196

                    doTestNulls(cls, Visibility.PACKAGE);
    } catch (Exception e) {
      throwIfUnchecked(e);
      throw new RuntimeException(e);
    }
  }

  void doTestNulls(Class<?> cls, Visibility visibility)
      throws ParameterNotInstantiableException, IllegalAccessException, InvocationTargetException,

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 288

                    doTestEquals(cls);
    } catch (Exception e) {
      throwIfUnchecked(e);
      throw new RuntimeException(e);
    }
  }

  void doTestEquals(Class<?> cls)
      throws ParameterNotInstantiableException, ParameterHasNoDistinctValueException,

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.testing.NullPointerTester.isNullable;

            

Reported by PMD.

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

Line: 83

               */
@Beta
@GwtIncompatible
public final class ClassSanityTester {

  private static final Ordering<Invokable<?, ?>> BY_METHOD_NAME =
      new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {

            

Reported by PMD.

Possible God Class (WMC=87, ATFD=70, TCC=1.449%)
Design

Line: 83

               */
@Beta
@GwtIncompatible
public final class ClassSanityTester {

  private static final Ordering<Invokable<?, ?>> BY_METHOD_NAME =
      new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {

            

Reported by PMD.

The class 'ClassSanityTester' has a total cyclomatic complexity of 87 (highest 11).
Design

Line: 83

               */
@Beta
@GwtIncompatible
public final class ClassSanityTester {

  private static final Ordering<Invokable<?, ?>> BY_METHOD_NAME =
      new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {

            

Reported by PMD.

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

Line: 89

                    new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
          return left.getName().compareTo(right.getName());
        }
      };

  private static final Ordering<Invokable<?, ?>> BY_PARAMETERS =
      new Ordering<Invokable<?, ?>>() {

            

Reported by PMD.

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

Line: 97

                    new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
          return Ordering.usingToString().compare(left.getParameters(), right.getParameters());
        }
      };

  private static final Ordering<Invokable<?, ?>> BY_NUMBER_OF_PARAMETERS =
      new Ordering<Invokable<?, ?>>() {

            

Reported by PMD.

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

Line: 105

                    new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
          return Ints.compare(left.getParameters().size(), right.getParameters().size());
        }
      };

  private final MutableClassToInstanceMap<Object> defaultValues =
      MutableClassToInstanceMap.create();

            

Reported by PMD.

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

Line: 105

                    new Ordering<Invokable<?, ?>>() {
        @Override
        public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
          return Ints.compare(left.getParameters().size(), right.getParameters().size());
        }
      };

  private final MutableClassToInstanceMap<Object> defaultValues =
      MutableClassToInstanceMap.create();

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java
97 issues
Avoid throwing null pointer exceptions.
Design

Line: 891

              
  public static class NPETask implements Callable<String> {
    public String call() {
      throw new NullPointerException();
    }
  }

  public static class CallableOne implements Callable<Integer> {
    public Integer call() {

            

Reported by PMD.

System.out.printf is used
Design

Line: 130

                  } finally {
      long elapsedMillis = (System.nanoTime() - t0) / (1000L * 1000L);
      if (elapsedMillis >= profileThreshold)
        System.out.printf("%n%s: %d%n", toString(), elapsedMillis);
    }
  }

  //     /**
  //      * Runs all JSR166 unit tests using junit.textui.TestRunner

            

Reported by PMD.

Avoid reassigning parameters such as 'millis'
Design

Line: 434

                 * Delays, via Thread.sleep, for the given millisecond delay, but if the sleep is shorter than
   * specified, may re-sleep or yield until time elapses.
   */
  static void delay(long millis) throws InterruptedException {
    long startTime = System.nanoTime();
    long ns = millis * 1000 * 1000;
    for (; ; ) {
      if (millis > 0L) Thread.sleep(millis);
      else // too short to sleep

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 534

              
  // Some convenient Integer constants

  public static final Integer zero = new Integer(0);
  public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 535

                // Some convenient Integer constants

  public static final Integer zero = new Integer(0);
  public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 536

              
  public static final Integer zero = new Integer(0);
  public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 537

                public static final Integer zero = new Integer(0);
  public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);
  public static final Integer eight = new Integer(8);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 538

                public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);
  public static final Integer eight = new Integer(8);
  public static final Integer nine = new Integer(9);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 539

                public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);
  public static final Integer eight = new Integer(8);
  public static final Integer nine = new Integer(9);
  public static final Integer m1 = new Integer(-1);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 540

                public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);
  public static final Integer eight = new Integer(8);
  public static final Integer nine = new Integer(9);
  public static final Integer m1 = new Integer(-1);
  public static final Integer m2 = new Integer(-2);

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java
97 issues
Avoid throwing null pointer exceptions.
Design

Line: 910

                public static class NPETask implements Callable<String> {
    @Override
    public String call() {
      throw new NullPointerException();
    }
  }

  public static class CallableOne implements Callable<Integer> {
    @Override

            

Reported by PMD.

System.out.printf is used
Design

Line: 131

                  } finally {
      long elapsedMillis = (System.nanoTime() - t0) / (1000L * 1000L);
      if (elapsedMillis >= profileThreshold)
        System.out.printf("%n%s: %d%n", toString(), elapsedMillis);
    }
  }

  //     /**
  //      * Runs all JSR166 unit tests using junit.textui.TestRunner

            

Reported by PMD.

Avoid reassigning parameters such as 'millis'
Design

Line: 437

                 * Delays, via Thread.sleep, for the given millisecond delay, but if the sleep is shorter than
   * specified, may re-sleep or yield until time elapses.
   */
  static void delay(long millis) throws InterruptedException {
    long startTime = System.nanoTime();
    long ns = millis * 1000 * 1000;
    for (; ; ) {
      if (millis > 0L) Thread.sleep(millis);
      else // too short to sleep

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 537

              
  // Some convenient Integer constants

  public static final Integer zero = new Integer(0);
  public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 538

                // Some convenient Integer constants

  public static final Integer zero = new Integer(0);
  public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 539

              
  public static final Integer zero = new Integer(0);
  public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 540

                public static final Integer zero = new Integer(0);
  public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);
  public static final Integer eight = new Integer(8);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 541

                public static final Integer one = new Integer(1);
  public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);
  public static final Integer eight = new Integer(8);
  public static final Integer nine = new Integer(9);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 542

                public static final Integer two = new Integer(2);
  public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);
  public static final Integer eight = new Integer(8);
  public static final Integer nine = new Integer(9);
  public static final Integer m1 = new Integer(-1);

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 543

                public static final Integer three = new Integer(3);
  public static final Integer four = new Integer(4);
  public static final Integer five = new Integer(5);
  public static final Integer six = new Integer(6);
  public static final Integer seven = new Integer(7);
  public static final Integer eight = new Integer(8);
  public static final Integer nine = new Integer(9);
  public static final Integer m1 = new Integer(-1);
  public static final Integer m2 = new Integer(-2);

            

Reported by PMD.

guava/src/com/google/common/collect/TreeMultiset.java
97 issues
Avoid really long classes.
Design

Line: 63

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
    implements Serializable {

  /**
   * Creates a new, empty multiset, sorted according to the elements' natural order. All elements
   * inserted into the multiset must implement the {@code Comparable} interface. Furthermore, all

            

Reported by PMD.

Possible God Class (WMC=82, ATFD=70, TCC=21.390%)
Design

Line: 63

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
    implements Serializable {

  /**
   * Creates a new, empty multiset, sorted according to the elements' natural order. All elements
   * inserted into the multiset must implement the {@code Comparable} interface. Furthermore, all

            

Reported by PMD.

The class 'TreeMultiset' has a total cyclomatic complexity of 82 (highest 8).
Design

Line: 63

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
    implements Serializable {

  /**
   * Creates a new, empty multiset, sorted according to the elements' natural order. All elements
   * inserted into the multiset must implement the {@code Comparable} interface. Furthermore, all

            

Reported by PMD.

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

Line: 64

              @GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
    implements Serializable {

  /**
   * Creates a new, empty multiset, sorted according to the elements' natural order. All elements
   * inserted into the multiset must implement the {@code Comparable} interface. Furthermore, all
   * such elements must be <i>mutually comparable</i>: {@code e1.compareTo(e2)} must not throw a

            

Reported by PMD.

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

Line: 93

                 * @param comparator the comparator that will be used to sort this multiset. A null value
   *     indicates that the elements' <i>natural ordering</i> should be used.
   */
  @SuppressWarnings("unchecked")
  public static <E extends @Nullable Object> TreeMultiset<E> create(
      @CheckForNull Comparator<? super E> comparator) {
    return (comparator == null)
        ? new TreeMultiset<E>((Comparator) Ordering.natural())
        : new TreeMultiset<E>(comparator);

            

Reported by PMD.

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

Line: 183

                  }
    // The cast is safe because we call this method only if hasLowerBound().
    int cmp =
        comparator()
            .compare(uncheckedCastNullableTToT(range.getLowerEndpoint()), node.getElement());
    if (cmp < 0) {
      return aggregateBelowRange(aggr, node.left);
    } else if (cmp == 0) {
      switch (range.getLowerBoundType()) {

            

Reported by PMD.

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

Line: 209

                  }
    // The cast is safe because we call this method only if hasUpperBound().
    int cmp =
        comparator()
            .compare(uncheckedCastNullableTToT(range.getUpperEndpoint()), node.getElement());
    if (cmp > 0) {
      return aggregateAboveRange(aggr, node.right);
    } else if (cmp == 0) {
      switch (range.getUpperBoundType()) {

            

Reported by PMD.

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

Line: 252

                    if (!range.contains(e) || root == null) {
        return 0;
      }
      return root.count(comparator(), e);
    } catch (ClassCastException | NullPointerException e) {
      return 0;
    }
  }


            

Reported by PMD.

Avoid catching NullPointerException; consider removing the cause of the NPE.
Error

Line: 253

                      return 0;
      }
      return root.count(comparator(), e);
    } catch (ClassCastException | NullPointerException e) {
      return 0;
    }
  }

  @CanIgnoreReturnValue

            

Reported by PMD.

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

Line: 253

                      return 0;
      }
      return root.count(comparator(), e);
    } catch (ClassCastException | NullPointerException e) {
      return 0;
    }
  }

  @CanIgnoreReturnValue

            

Reported by PMD.

guava/src/com/google/common/util/concurrent/ClosingFuture.java
96 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.util.concurrent;

import static com.google.common.base.Functions.constant;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.util.concurrent;

import static com.google.common.base.Functions.constant;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 197

              @DoNotMock("Use ClosingFuture.from(Futures.immediate*Future)")
@ElementTypesAreNonnullByDefault
// TODO(dpb): GWT compatibility.
public final class ClosingFuture<V extends @Nullable Object> {

  private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());

  /**
   * An object that can capture objects to be closed later, when a {@link ClosingFuture} pipeline is

            

Reported by PMD.

Possible God Class (WMC=63, ATFD=6, TCC=7.018%)
Design

Line: 197

              @DoNotMock("Use ClosingFuture.from(Futures.immediate*Future)")
@ElementTypesAreNonnullByDefault
// TODO(dpb): GWT compatibility.
public final class ClosingFuture<V extends @Nullable Object> {

  private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());

  /**
   * An object that can capture objects to be closed later, when a {@link ClosingFuture} pipeline is

            

Reported by PMD.

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

Line: 197

              @DoNotMock("Use ClosingFuture.from(Futures.immediate*Future)")
@ElementTypesAreNonnullByDefault
// TODO(dpb): GWT compatibility.
public final class ClosingFuture<V extends @Nullable Object> {

  private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());

  /**
   * An object that can capture objects to be closed later, when a {@link ClosingFuture} pipeline is

            

Reported by PMD.

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

Line: 206

                 * done.
   */
  public static final class DeferredCloser {
    @RetainedWith private final CloseableList list;

    DeferredCloser(CloseableList list) {
      this.list = list;
    }


            

Reported by PMD.

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

Line: 262

                   * not before this method completes), even if this method throws or the pipeline is cancelled.
     */
    @ParametricNullness
    V call(DeferredCloser closer) throws Exception;
  }

  /**
   * An operation that computes a {@link ClosingFuture} of a result.
   *

            

Reported by PMD.

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

Line: 280

                   * closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
     * not before this method completes), even if this method throws or the pipeline is cancelled.
     */
    ClosingFuture<V> call(DeferredCloser closer) throws Exception;
  }

  /**
   * A function from an input to a result.
   *

            

Reported by PMD.

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

Line: 300

                   * not before this method completes), even if this method throws or the pipeline is cancelled.
     */
    @ParametricNullness
    U apply(DeferredCloser closer, @ParametricNullness T input) throws Exception;
  }

  /**
   * A function from an input to a {@link ClosingFuture} of a result.
   *

            

Reported by PMD.

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

Line: 318

                   * closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
     * not before this method completes), even if this method throws or the pipeline is cancelled.
     */
    ClosingFuture<U> apply(DeferredCloser closer, @ParametricNullness T input) throws Exception;
  }

  /**
   * An object that holds the final result of an asynchronous {@link ClosingFuture} operation and
   * allows the user to close all the closeable objects that were captured during it for later

            

Reported by PMD.

android/guava/src/com/google/common/util/concurrent/ClosingFuture.java
96 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.util.concurrent;

import static com.google.common.base.Functions.constant;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.util.concurrent;

import static com.google.common.base.Functions.constant;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 198

              @DoNotMock("Use ClosingFuture.from(Futures.immediate*Future)")
@ElementTypesAreNonnullByDefault
// TODO(dpb): GWT compatibility.
public final class ClosingFuture<V extends @Nullable Object> {

  private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());

  /**
   * An object that can capture objects to be closed later, when a {@link ClosingFuture} pipeline is

            

Reported by PMD.

Possible God Class (WMC=63, ATFD=6, TCC=7.018%)
Design

Line: 198

              @DoNotMock("Use ClosingFuture.from(Futures.immediate*Future)")
@ElementTypesAreNonnullByDefault
// TODO(dpb): GWT compatibility.
public final class ClosingFuture<V extends @Nullable Object> {

  private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());

  /**
   * An object that can capture objects to be closed later, when a {@link ClosingFuture} pipeline is

            

Reported by PMD.

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

Line: 198

              @DoNotMock("Use ClosingFuture.from(Futures.immediate*Future)")
@ElementTypesAreNonnullByDefault
// TODO(dpb): GWT compatibility.
public final class ClosingFuture<V extends @Nullable Object> {

  private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());

  /**
   * An object that can capture objects to be closed later, when a {@link ClosingFuture} pipeline is

            

Reported by PMD.

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

Line: 207

                 * done.
   */
  public static final class DeferredCloser {
    @RetainedWith private final CloseableList list;

    DeferredCloser(CloseableList list) {
      this.list = list;
    }


            

Reported by PMD.

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

Line: 263

                   * not before this method completes), even if this method throws or the pipeline is cancelled.
     */
    @ParametricNullness
    V call(DeferredCloser closer) throws Exception;
  }

  /**
   * An operation that computes a {@link ClosingFuture} of a result.
   *

            

Reported by PMD.

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

Line: 280

                   * closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
     * not before this method completes), even if this method throws or the pipeline is cancelled.
     */
    ClosingFuture<V> call(DeferredCloser closer) throws Exception;
  }

  /**
   * A function from an input to a result.
   *

            

Reported by PMD.

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

Line: 299

                   * not before this method completes), even if this method throws or the pipeline is cancelled.
     */
    @ParametricNullness
    U apply(DeferredCloser closer, @ParametricNullness T input) throws Exception;
  }

  /**
   * A function from an input to a {@link ClosingFuture} of a result.
   *

            

Reported by PMD.

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

Line: 316

                   * closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
     * not before this method completes), even if this method throws or the pipeline is cancelled.
     */
    ClosingFuture<U> apply(DeferredCloser closer, @ParametricNullness T input) throws Exception;
  }

  /**
   * An object that holds the final result of an asynchronous {@link ClosingFuture} operation and
   * allows the user to close all the closeable objects that were captured during it for later

            

Reported by PMD.