The following issues were found

guava/src/com/google/common/hash/HashCode.java
11 issues
Avoid reassigning parameters such as 'maxLength'
Design

Line: 85

                 * @throws IndexOutOfBoundsException if there is not enough room in {@code dest}
   */
  @CanIgnoreReturnValue
  public int writeBytesTo(byte[] dest, int offset, int maxLength) {
    maxLength = Ints.min(maxLength, bits() / 8);
    Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length);
    writeBytesToImpl(dest, offset, maxLength);
    return maxLength;
  }

            

Reported by PMD.

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

Line: 36

               * @since 11.0
 */
@ElementTypesAreNonnullByDefault
public abstract class HashCode {
  HashCode() {}

  /** Returns the number of bits in this hash code; a positive multiple of 8. */
  public abstract int bits();


            

Reported by PMD.

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

Line: 120

                }

  private static final class IntHashCode extends HashCode implements Serializable {
    final int hash;

    IntHashCode(int hash) {
      this.hash = hash;
    }


            

Reported by PMD.

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

Line: 177

                }

  private static final class LongHashCode extends HashCode implements Serializable {
    final long hash;

    LongHashCode(long hash) {
      this.hash = hash;
    }


            

Reported by PMD.

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

Line: 252

                }

  private static final class BytesHashCode extends HashCode implements Serializable {
    final byte[] bytes;

    BytesHashCode(byte[] bytes) {
      this.bytes = checkNotNull(bytes);
    }


            

Reported by PMD.

Returning 'bytes' may expose an internal array.
Design

Line: 305

              
    @Override
    byte[] getBytesInternal() {
      return bytes;
    }

    @Override
    boolean equalsSameBits(HashCode that) {
      // We don't use MessageDigest.isEqual() here because its contract does not guarantee

            

Reported by PMD.

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

Line: 312

                  boolean equalsSameBits(HashCode that) {
      // We don't use MessageDigest.isEqual() here because its contract does not guarantee
      // constant-time evaluation (no short-circuiting).
      if (this.bytes.length != that.getBytesInternal().length) {
        return false;
      }

      boolean areEqual = true;
      for (int i = 0; i < this.bytes.length; i++) {

            

Reported by PMD.

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

Line: 374

                public final boolean equals(@CheckForNull Object object) {
    if (object instanceof HashCode) {
      HashCode that = (HashCode) object;
      return bits() == that.bits() && equalsSameBits(that);
    }
    return false;
  }

  /**

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 388

                public final int hashCode() {
    // If we have at least 4 bytes (32 bits), just take the first 4 bytes. Since this is
    // already a (presumably) high-quality hash code, any four bytes of it will do.
    if (bits() >= 32) {
      return asInt();
    }
    // If we have less than 4 bytes, use them all.
    byte[] bytes = getBytesInternal();
    int val = (bytes[0] & 0xFF);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'bytes' (lines '344'-'348').
Error

Line: 344

                      "input string (%s) must have an even number of characters",
        string);

    byte[] bytes = new byte[string.length() / 2];
    for (int i = 0; i < string.length(); i += 2) {
      int ch1 = decode(string.charAt(i)) << 4;
      int ch2 = decode(string.charAt(i + 1));
      bytes[i / 2] = (byte) (ch1 + ch2);
    }

            

Reported by PMD.

guava/src/com/google/common/hash/MacHashFunction.java
11 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 37

              final class MacHashFunction extends AbstractHashFunction {

  @SuppressWarnings("Immutable") // cloned before each use
  private final Mac prototype;

  @SuppressWarnings("Immutable") // keys are immutable, but not provably so
  private final Key key;

  private final String toString;

            

Reported by PMD.

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

Line: 40

                private final Mac prototype;

  @SuppressWarnings("Immutable") // keys are immutable, but not provably so
  private final Key key;

  private final String toString;
  private final int bits;
  private final boolean supportsClone;


            

Reported by PMD.

Field toString has the same name as a method
Error

Line: 42

                @SuppressWarnings("Immutable") // keys are immutable, but not provably so
  private final Key key;

  private final String toString;
  private final int bits;
  private final boolean supportsClone;

  MacHashFunction(String algorithmName, Key key, String toString) {
    this.prototype = getMac(algorithmName, key);

            

Reported by PMD.

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

Line: 42

                @SuppressWarnings("Immutable") // keys are immutable, but not provably so
  private final Key key;

  private final String toString;
  private final int bits;
  private final boolean supportsClone;

  MacHashFunction(String algorithmName, Key key, String toString) {
    this.prototype = getMac(algorithmName, key);

            

Reported by PMD.

Field bits has the same name as a method
Error

Line: 43

                private final Key key;

  private final String toString;
  private final int bits;
  private final boolean supportsClone;

  MacHashFunction(String algorithmName, Key key, String toString) {
    this.prototype = getMac(algorithmName, key);
    this.key = checkNotNull(key);

            

Reported by PMD.

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

Line: 43

                private final Key key;

  private final String toString;
  private final int bits;
  private final boolean supportsClone;

  MacHashFunction(String algorithmName, Key key, String toString) {
    this.prototype = getMac(algorithmName, key);
    this.key = checkNotNull(key);

            

Reported by PMD.

Field supportsClone has the same name as a method
Error

Line: 44

              
  private final String toString;
  private final int bits;
  private final boolean supportsClone;

  MacHashFunction(String algorithmName, Key key, String toString) {
    this.prototype = getMac(algorithmName, key);
    this.key = checkNotNull(key);
    this.toString = checkNotNull(toString);

            

Reported by PMD.

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

Line: 44

              
  private final String toString;
  private final int bits;
  private final boolean supportsClone;

  MacHashFunction(String algorithmName, Key key, String toString) {
    this.prototype = getMac(algorithmName, key);
    this.key = checkNotNull(key);
    this.toString = checkNotNull(toString);

            

Reported by PMD.

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

Line: 71

                private static Mac getMac(String algorithmName, Key key) {
    try {
      Mac mac = Mac.getInstance(algorithmName);
      mac.init(key);
      return mac;
    } catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException(e);
    } catch (InvalidKeyException e) {
      throw new IllegalArgumentException(e);

            

Reported by PMD.

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

Line: 99

              
  /** Hasher that updates a {@link Mac} (message authentication code). */
  private static final class MacHasher extends AbstractByteHasher {
    private final Mac mac;
    private boolean done;

    private MacHasher(Mac mac) {
      this.mac = mac;
    }

            

Reported by PMD.

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

Line: 126

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

  /**

            

Reported by PMD.

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

Line: 48

              // javadoc?
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Bytes {
  private Bytes() {}

  /**
   * Returns a hash code for {@code value}; equal to the result of invoking {@code ((Byte)
   * value).hashCode()}.

            

Reported by PMD.

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

Line: 243

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

    ByteArrayAsList(byte[] array) {
      this(array, 0, array.length);

            

Reported by PMD.

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

Line: 244

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

    ByteArrayAsList(byte[] array) {
      this(array, 0, array.length);
    }

            

Reported by PMD.

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

Line: 245

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

    ByteArrayAsList(byte[] array) {
      this(array, 0, array.length);
    }


            

Reported by PMD.

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

Line: 251

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

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


            

Reported by PMD.

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

Line: 330

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

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 393

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

            

Reported by PMD.

Found 'DU'-anomaly for variable 'pos' (lines '166'-'172').
Error

Line: 166

                    length += array.length;
    }
    byte[] result = new byte[length];
    int pos = 0;
    for (byte[] array : arrays) {
      System.arraycopy(array, 0, result, pos, array.length);
      pos += array.length;
    }
    return result;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '213'-'216').
Error

Line: 213

              
    Object[] boxedArray = collection.toArray();
    int len = boxedArray.length;
    byte[] array = new byte[len];
    for (int i = 0; i < len; i++) {
      // checkNotNull for GWT (do not optimize)
      array[i] = ((Number) checkNotNull(boxedArray[i])).byteValue();
    }
    return array;

            

Reported by PMD.

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

Line: 35

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractIdleService implements Service {

  /* Thread names will look like {@code "MyService STARTING"}. */
  private final Supplier<String> threadNameSupplier = new ThreadNameSupplier();

  @WeakOuter

            

Reported by PMD.

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

Line: 38

              public abstract class AbstractIdleService implements Service {

  /* Thread names will look like {@code "MyService STARTING"}. */
  private final Supplier<String> threadNameSupplier = new ThreadNameSupplier();

  @WeakOuter
  private final class ThreadNameSupplier implements Supplier<String> {
    @Override
    public String get() {

            

Reported by PMD.

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

Line: 49

                }

  /* use AbstractService for state management */
  private final Service delegate = new DelegateService();

  @WeakOuter
  private final class DelegateService extends AbstractService {
    @Override
    protected final void doStart() {

            

Reported by PMD.

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

Line: 63

                                try {
                    startUp();
                    notifyStarted();
                  } catch (Throwable t) {
                    notifyFailed(t);
                  }
                }
              });
    }

            

Reported by PMD.

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

Line: 80

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

            

Reported by PMD.

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

Line: 89

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

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

            

Reported by PMD.

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

Line: 89

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

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

            

Reported by PMD.

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

Line: 97

                protected AbstractIdleService() {}

  /** Start the service. */
  protected abstract void startUp() throws Exception;

  /** Stop the service. */
  protected abstract void shutDown() throws Exception;

  /**

            

Reported by PMD.

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

Line: 100

                protected abstract void startUp() throws Exception;

  /** Stop the service. */
  protected abstract void shutDown() throws Exception;

  /**
   * Returns the {@link Executor} that will be used to run this service. Subclasses may override
   * this method to use a custom {@link Executor}, which may configure its worker thread with a
   * specific name, thread group or priority. The returned executor's {@link

            

Reported by PMD.

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

Line: 113

                  return new Executor() {
      @Override
      public void execute(Runnable command) {
        MoreExecutors.newThread(threadNameSupplier.get(), command).start();
      }
    };
  }

  @Override

            

Reported by PMD.

android/guava/src/com/google/common/hash/Crc32cHashFunction.java
11 issues
Avoid reassigning parameters such as 'csum'
Design

Line: 364

                        ^ STRIDE_TABLE[0][word >>> 24];
    }

    static int combine(int csum, int crc) {
      csum ^= crc;
      for (int i = 0; i < 4; i++) {
        csum = (csum >>> 8) ^ BYTE_TABLE[csum & 0xFF];
      }
      return csum;

            

Reported by PMD.

Avoid reassigning parameters such as 'csum'
Design

Line: 364

                        ^ STRIDE_TABLE[0][word >>> 24];
    }

    static int combine(int csum, int crc) {
      csum ^= crc;
      for (int i = 0; i < 4; i++) {
        csum = (csum >>> 8) ^ BYTE_TABLE[csum & 0xFF];
      }
      return csum;

            

Reported by PMD.

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

Line: 63

                    super(16);
    }

    private boolean finished = false;

    /*
     * This trick allows us to avoid having separate states for "first four ints" and "all other
     * four int chunks."  The state we want after the first four bytes is
     *

            

Reported by PMD.

Avoid using redundant field initializer for 'finished'
Performance

Line: 63

                    super(16);
    }

    private boolean finished = false;

    /*
     * This trick allows us to avoid having separate states for "first four ints" and "all other
     * four int chunks."  The state we want after the first four bytes is
     *

            

Reported by PMD.

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

Line: 77

                   * ...so we set crc0 so that computeForWord(crc0) = -1 and xoring it with the first int
     * gives us the desired result.  computeForWord(0) == 0, so all the others do the right thing.
     */
    private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
    private int crc1 = 0;
    private int crc2 = 0;
    private int crc3 = 0;

    @Override

            

Reported by PMD.

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

Line: 78

                   * gives us the desired result.  computeForWord(0) == 0, so all the others do the right thing.
     */
    private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
    private int crc1 = 0;
    private int crc2 = 0;
    private int crc3 = 0;

    @Override
    protected void process(ByteBuffer bb) {

            

Reported by PMD.

Avoid using redundant field initializer for 'crc1'
Performance

Line: 78

                   * gives us the desired result.  computeForWord(0) == 0, so all the others do the right thing.
     */
    private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
    private int crc1 = 0;
    private int crc2 = 0;
    private int crc3 = 0;

    @Override
    protected void process(ByteBuffer bb) {

            

Reported by PMD.

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

Line: 79

                   */
    private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
    private int crc1 = 0;
    private int crc2 = 0;
    private int crc3 = 0;

    @Override
    protected void process(ByteBuffer bb) {
      if (finished) {

            

Reported by PMD.

Avoid using redundant field initializer for 'crc2'
Performance

Line: 79

                   */
    private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
    private int crc1 = 0;
    private int crc2 = 0;
    private int crc3 = 0;

    @Override
    protected void process(ByteBuffer bb) {
      if (finished) {

            

Reported by PMD.

Avoid using redundant field initializer for 'crc3'
Performance

Line: 80

                  private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
    private int crc1 = 0;
    private int crc2 = 0;
    private int crc3 = 0;

    @Override
    protected void process(ByteBuffer bb) {
      if (finished) {
        throw new IllegalStateException(

            

Reported by PMD.

android/guava/src/com/google/common/hash/HashCode.java
11 issues
Avoid reassigning parameters such as 'maxLength'
Design

Line: 85

                 * @throws IndexOutOfBoundsException if there is not enough room in {@code dest}
   */
  @CanIgnoreReturnValue
  public int writeBytesTo(byte[] dest, int offset, int maxLength) {
    maxLength = Ints.min(maxLength, bits() / 8);
    Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length);
    writeBytesToImpl(dest, offset, maxLength);
    return maxLength;
  }

            

Reported by PMD.

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

Line: 36

               * @since 11.0
 */
@ElementTypesAreNonnullByDefault
public abstract class HashCode {
  HashCode() {}

  /** Returns the number of bits in this hash code; a positive multiple of 8. */
  public abstract int bits();


            

Reported by PMD.

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

Line: 120

                }

  private static final class IntHashCode extends HashCode implements Serializable {
    final int hash;

    IntHashCode(int hash) {
      this.hash = hash;
    }


            

Reported by PMD.

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

Line: 177

                }

  private static final class LongHashCode extends HashCode implements Serializable {
    final long hash;

    LongHashCode(long hash) {
      this.hash = hash;
    }


            

Reported by PMD.

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

Line: 252

                }

  private static final class BytesHashCode extends HashCode implements Serializable {
    final byte[] bytes;

    BytesHashCode(byte[] bytes) {
      this.bytes = checkNotNull(bytes);
    }


            

Reported by PMD.

Returning 'bytes' may expose an internal array.
Design

Line: 305

              
    @Override
    byte[] getBytesInternal() {
      return bytes;
    }

    @Override
    boolean equalsSameBits(HashCode that) {
      // We don't use MessageDigest.isEqual() here because its contract does not guarantee

            

Reported by PMD.

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

Line: 312

                  boolean equalsSameBits(HashCode that) {
      // We don't use MessageDigest.isEqual() here because its contract does not guarantee
      // constant-time evaluation (no short-circuiting).
      if (this.bytes.length != that.getBytesInternal().length) {
        return false;
      }

      boolean areEqual = true;
      for (int i = 0; i < this.bytes.length; i++) {

            

Reported by PMD.

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

Line: 374

                public final boolean equals(@CheckForNull Object object) {
    if (object instanceof HashCode) {
      HashCode that = (HashCode) object;
      return bits() == that.bits() && equalsSameBits(that);
    }
    return false;
  }

  /**

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 388

                public final int hashCode() {
    // If we have at least 4 bytes (32 bits), just take the first 4 bytes. Since this is
    // already a (presumably) high-quality hash code, any four bytes of it will do.
    if (bits() >= 32) {
      return asInt();
    }
    // If we have less than 4 bytes, use them all.
    byte[] bytes = getBytesInternal();
    int val = (bytes[0] & 0xFF);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'bytes' (lines '344'-'348').
Error

Line: 344

                      "input string (%s) must have an even number of characters",
        string);

    byte[] bytes = new byte[string.length() / 2];
    for (int i = 0; i < string.length(); i += 2) {
      int ch1 = decode(string.charAt(i)) << 4;
      int ch2 = decode(string.charAt(i + 1));
      bytes[i / 2] = (byte) (ch1 + ch2);
    }

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
11 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 50

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(SortedMapNavigationTester.class);
    return testers;
  }

  @Override
  public TestSuite createTestSuite() {

            

Reported by PMD.

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

Line: 56

              
  @Override
  public TestSuite createTestSuite() {
    if (!getFeatures().contains(KNOWN_ORDER)) {
      List<Feature<?>> features = Helpers.copyToList(getFeatures());
      features.add(KNOWN_ORDER);
      withFeatures(features);
    }
    return super.createTestSuite();

            

Reported by PMD.

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

Line: 58

                public TestSuite createTestSuite() {
    if (!getFeatures().contains(KNOWN_ORDER)) {
      List<Feature<?>> features = Helpers.copyToList(getFeatures());
      features.add(KNOWN_ORDER);
      withFeatures(features);
    }
    return super.createTestSuite();
  }


            

Reported by PMD.

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

Line: 71

                        parentBuilder) {
    List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);

    if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
    }


            

Reported by PMD.

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

Line: 114

                    final Bound from,
      final Bound to) {
    final TestSortedMapGenerator<K, V> delegate =
        (TestSortedMapGenerator<K, V>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());


            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 120

                  features.add(NoRecurse.SUBMAP);
    features.addAll(parentBuilder.getFeatures());

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subMap " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
11 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 45

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(SortedSetNavigationTester.class);
    return testers;
  }

  @Override
  public TestSuite createTestSuite() {

            

Reported by PMD.

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

Line: 51

              
  @Override
  public TestSuite createTestSuite() {
    if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
      List<Feature<?>> features = Helpers.copyToList(getFeatures());
      features.add(CollectionFeature.KNOWN_ORDER);
      withFeatures(features);
    }
    return super.createTestSuite();

            

Reported by PMD.

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

Line: 53

                public TestSuite createTestSuite() {
    if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
      List<Feature<?>> features = Helpers.copyToList(getFeatures());
      features.add(CollectionFeature.KNOWN_ORDER);
      withFeatures(features);
    }
    return super.createTestSuite();
  }


            

Reported by PMD.

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

Line: 65

                        parentBuilder) {
    List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);

    if (!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
    }


            

Reported by PMD.

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

Line: 87

                    final Bound from,
      final Bound to) {
    final TestSortedSetGenerator<E> delegate =
        (TestSortedSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>(parentBuilder.getFeatures());
    features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);


            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 93

                  features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
    features.add(CollectionFeature.SUBSET_VIEW);

    return newBuilderUsing(delegate, to, from)
        .named(parentBuilder.getName() + " subSet " + from + "-" + to)
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())

            

Reported by PMD.

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

Line: 54

                        parentBuilder) {
    List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));

    if (!parentBuilder.getFeatures().contains(SUBSET_VIEW)) {
      // Other combinations are inherited from SortedSetTestSuiteBuilder.
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));

            

Reported by PMD.

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

Line: 62

                    derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
      derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
    }
    if (!parentBuilder.getFeatures().contains(DESCENDING_VIEW)) {
      derivedSuites.add(createDescendingSuite(parentBuilder));
    }
    return derivedSuites;
  }


            

Reported by PMD.

The method 'createSubSet(SortedSet, E, E)' has a cyclomatic complexity of 11.
Design

Line: 76

                  }

    @Override
    NavigableSet<E> createSubSet(SortedSet<E> sortedSet, E firstExclusive, E lastExclusive) {
      NavigableSet<E> set = (NavigableSet<E>) sortedSet;
      if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) {
        return set.headSet(lastInclusive, true);
      } else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) {
        return set.tailSet(firstExclusive, false);

            

Reported by PMD.

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

Line: 106

                            ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());


            

Reported by PMD.

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

Line: 138

                            @Override
              public Set<E> create(Object... elements) {
                NavigableSet<E> navigableSet = (NavigableSet<E>) delegate.create(elements);
                return navigableSet.descendingSet();
              }
            })
        .named(parentBuilder.getName() + " descending")
        .withFeatures(features)
        .suppressing(parentBuilder.getSuppressedTests())

            

Reported by PMD.

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

Line: 150

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(NavigableSetNavigationTester.class);
    return testers;
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '105'-'145').
Error

Line: 105

                    final FeatureSpecificTestSuiteBuilder<
              ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '105'-'145').
Error

Line: 105

                    final FeatureSpecificTestSuiteBuilder<
              ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '105'-'145').
Error

Line: 105

                    final FeatureSpecificTestSuiteBuilder<
              ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '105'-'145').
Error

Line: 105

                    final FeatureSpecificTestSuiteBuilder<
              ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
          parentBuilder) {
    final TestSetGenerator<E> delegate =
        (TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(DESCENDING_VIEW);
    features.addAll(parentBuilder.getFeatures());

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/NavigableMapTestSuiteBuilder.java
11 issues
Avoid reassigning parameters such as 'insertionOrder'
Design

Line: 153

                  }

    @Override
    public Iterable<Entry<K, V>> order(List<Entry<K, V>> insertionOrder) {
      insertionOrder = castOrCopyToList(delegate.order(insertionOrder));
      reverse(insertionOrder);
      return insertionOrder;
    }


            

Reported by PMD.

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

Line: 52

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(NavigableMapNavigationTester.class);
    return testers;
  }

  @Override
  protected List<TestSuite> createDerivedSuites(

            

Reported by PMD.

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

Line: 63

                        parentBuilder) {
    List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);

    if (!parentBuilder.getFeatures().contains(NoRecurse.DESCENDING)) {
      derivedSuites.add(createDescendingSuite(parentBuilder));
    }

    if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
      // Other combinations are inherited from SortedMapTestSuiteBuilder.

            

Reported by PMD.

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

Line: 67

                    derivedSuites.add(createDescendingSuite(parentBuilder));
    }

    if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
      // Other combinations are inherited from SortedMapTestSuiteBuilder.
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
      derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));

            

Reported by PMD.

The method 'createSubMap(SortedMap, K, K)' has a cyclomatic complexity of 11.
Design

Line: 93

                  }

    @Override
    NavigableMap<K, V> createSubMap(SortedMap<K, V> sortedMap, K firstExclusive, K lastExclusive) {
      NavigableMap<K, V> map = (NavigableMap<K, V>) sortedMap;
      if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) {
        return map.headMap(lastInclusive, true);
      } else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) {
        return map.tailMap(firstExclusive, false);

            

Reported by PMD.

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

Line: 123

                            ?, ? extends OneSizeTestContainerGenerator<Map<K, V>, Entry<K, V>>>
          parentBuilder) {
    final TestSortedMapGenerator<K, V> delegate =
        (TestSortedMapGenerator<K, V>) parentBuilder.getSubjectGenerator().getInnerGenerator();

    List<Feature<?>> features = new ArrayList<>();
    features.add(NoRecurse.DESCENDING);
    features.addAll(parentBuilder.getFeatures());


            

Reported by PMD.

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

Line: 149

                  @Override
    public NavigableMap<K, V> create(Object... entries) {
      NavigableMap<K, V> map = (NavigableMap<K, V>) delegate.create(entries);
      return map.descendingMap();
    }

    @Override
    public Iterable<Entry<K, V>> order(List<Entry<K, V>> insertionOrder) {
      insertionOrder = castOrCopyToList(delegate.order(insertionOrder));

            

Reported by PMD.

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

Line: 165

              
    @Override
    public Entry<K, V> belowSamplesLesser() {
      return delegate().aboveSamplesGreater();
    }

    @Override
    public Entry<K, V> belowSamplesGreater() {
      return delegate().aboveSamplesLesser();

            

Reported by PMD.

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

Line: 170

              
    @Override
    public Entry<K, V> belowSamplesGreater() {
      return delegate().aboveSamplesLesser();
    }

    @Override
    public Entry<K, V> aboveSamplesLesser() {
      return delegate().belowSamplesGreater();

            

Reported by PMD.

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

Line: 175

              
    @Override
    public Entry<K, V> aboveSamplesLesser() {
      return delegate().belowSamplesGreater();
    }

    @Override
    public Entry<K, V> aboveSamplesGreater() {
      return delegate().belowSamplesLesser();

            

Reported by PMD.