The following issues were found

android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java
4 issues
JUnit 4 indicates test suites via annotations, not the suite method.
Design

Line: 48

               * under JDK7
 */
public class OpenJdk6MapTests extends TestsForMapsInJavaUtil {
  public static Test suite() {
    return new OpenJdk6MapTests().allTests();
  }

  @Override
  protected Collection<Method> suppressForTreeMapNatural() {

            

Reported by PMD.

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

Line: 85

                @Override
  protected Collection<Method> suppressForConcurrentSkipListMap() {
    List<Method> methods = newArrayList();
    methods.addAll(super.suppressForConcurrentSkipListMap());
    methods.add(getContainsEntryWithIncomparableKeyMethod());
    methods.add(getContainsEntryWithIncomparableValueMethod());
    return methods;
  }
}

            

Reported by PMD.

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

Line: 86

                protected Collection<Method> suppressForConcurrentSkipListMap() {
    List<Method> methods = newArrayList();
    methods.addAll(super.suppressForConcurrentSkipListMap());
    methods.add(getContainsEntryWithIncomparableKeyMethod());
    methods.add(getContainsEntryWithIncomparableValueMethod());
    return methods;
  }
}

            

Reported by PMD.

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

Line: 87

                  List<Method> methods = newArrayList();
    methods.addAll(super.suppressForConcurrentSkipListMap());
    methods.add(getContainsEntryWithIncomparableKeyMethod());
    methods.add(getContainsEntryWithIncomparableValueMethod());
    return methods;
  }
}

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/TestUnhashableCollectionGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 51

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

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

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '39'-'42').
Error

Line: 39

              
  @Override
  public T create(Object... elements) {
    UnhashableObject[] array = createArray(elements.length);
    int i = 0;
    for (Object e : elements) {
      array[i++] = (UnhashableObject) e;
    }
    return create(array);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '40'-'45').
Error

Line: 40

                @Override
  public T create(Object... elements) {
    UnhashableObject[] array = createArray(elements.length);
    int i = 0;
    for (Object e : elements) {
      array[i++] = (UnhashableObject) e;
    }
    return create(array);
  }

            

Reported by PMD.

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

Line: 42

                  UnhashableObject[] array = createArray(elements.length);
    int i = 0;
    for (Object e : elements) {
      array[i++] = (UnhashableObject) e;
    }
    return create(array);
  }

  /**

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/TestStringSetGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 46

                  return create(array);
  }

  protected abstract Set<String> create(String[] elements);

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

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '38'-'41').
Error

Line: 38

              
  @Override
  public Set<String> create(Object... elements) {
    String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '39'-'44').
Error

Line: 39

                @Override
  public Set<String> create(Object... elements) {
    String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);
  }

            

Reported by PMD.

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

Line: 41

                  String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);
  }

  protected abstract Set<String> create(String[] elements);

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/TestStringQueueGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 46

                  return create(array);
  }

  protected abstract Queue<String> create(String[] elements);

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

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '38'-'41').
Error

Line: 38

              
  @Override
  public Queue<String> create(Object... elements) {
    String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '39'-'44').
Error

Line: 39

                @Override
  public Queue<String> create(Object... elements) {
    String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);
  }

            

Reported by PMD.

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

Line: 41

                  String[] array = new String[elements.length];
    int i = 0;
    for (Object e : elements) {
      array[i++] = (String) e;
    }
    return create(array);
  }

  protected abstract Queue<String> create(String[] elements);

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/TestStringMapGenerator.java
4 issues
Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 57

                  return create(array);
  }

  protected abstract Map<String, String> create(Entry<String, String>[] entries);

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

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '47'-'52').
Error

Line: 47

                @Override
  public Map<String, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'i' (lines '48'-'55').
Error

Line: 48

                public Map<String, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;
    }

            

Reported by PMD.

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

Line: 52

                  for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<String, String> e = (Entry<String, String>) o;
      array[i++] = e;
    }
    return create(array);
  }

  protected abstract Map<String, String> create(Entry<String, String>[] entries);

            

Reported by PMD.

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

Line: 68

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractIterator<T extends @Nullable Object> extends UnmodifiableIterator<T> {
  private State state = State.NOT_READY;

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

  private enum State {

            

Reported by PMD.

Field next has the same name as a method
Error

Line: 87

                  FAILED,
  }

  @CheckForNull private T next;

  /**
   * Returns the next element. <b>Note:</b> the implementation must call {@link #endOfData()} when
   * there are no elements left in the iteration. Failure to do so could result in an infinite loop.
   *

            

Reported by PMD.

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

Line: 87

                  FAILED,
  }

  @CheckForNull private T next;

  /**
   * Returns the next element. <b>Note:</b> the implementation must call {@link #endOfData()} when
   * there are no elements left in the iteration. Failure to do so could result in an infinite loop.
   *

            

Reported by PMD.

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

Line: 164

                  state = State.NOT_READY;
    // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
    T result = uncheckedCastNullableTToT(next);
    next = null;
    return result;
  }

  /**
   * Returns the next element in the iteration without advancing the iteration, according to the

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTesterTest.java
4 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 29

               */
public class ForwardingObjectTesterTest extends TestCase {

  public void testFailsToForward() {
    try {
      ForwardingObjectTester.testForwardingObject(FailToForward.class);
    } catch (AssertionError | UnsupportedOperationException expected) {
      // UnsupportedOperationException is what we see on Android.
      return;

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 39

                  fail("Should have thrown");
  }

  @AndroidIncompatible // TODO(cpovirk): java.lang.IllegalAccessError: superclass not accessible
  public void testSuccessfulForwarding() {
    ForwardingObjectTester.testForwardingObject(ForwardToDelegate.class);
  }

  private abstract static class FailToForward extends ForwardingObject implements Runnable {

            

Reported by PMD.

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

Line: 40

                }

  @AndroidIncompatible // TODO(cpovirk): java.lang.IllegalAccessError: superclass not accessible
  public void testSuccessfulForwarding() {
    ForwardingObjectTester.testForwardingObject(ForwardToDelegate.class);
  }

  private abstract static class FailToForward extends ForwardingObject implements Runnable {
    @Override

            

Reported by PMD.

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

Line: 52

                private abstract static class ForwardToDelegate extends ForwardingObject implements Runnable {
    @Override
    public void run() {
      delegate().run();
    }

    @Override
    protected abstract Runnable delegate();
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/UncaughtExceptionHandlersTest.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 29

              
public class UncaughtExceptionHandlersTest extends TestCase {

  private Runtime runtimeMock;

  @Override
  protected void setUp() {
    runtimeMock = mock(Runtime.class);
  }

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 31

              
  private Runtime runtimeMock;

  @Override
  protected void setUp() {
    runtimeMock = mock(Runtime.class);
  }

  public void testExiter() {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 36

                  runtimeMock = mock(Runtime.class);
  }

  public void testExiter() {
    new Exiter(runtimeMock).uncaughtException(new Thread(), new Exception());
    verify(runtimeMock).exit(1);
  }
}

            

Reported by PMD.

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

Line: 38

              
  public void testExiter() {
    new Exiter(runtimeMock).uncaughtException(new Thread(), new Exception());
    verify(runtimeMock).exit(1);
  }
}

            

Reported by PMD.

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

Line: 34

              @GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractIterator<T extends @Nullable Object> implements Iterator<T> {
  private State state = State.NOT_READY;

  protected AbstractIterator() {}

  private enum State {
    READY,

            

Reported by PMD.

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

Line: 45

                  FAILED,
  }

  @CheckForNull private T next;

  @CheckForNull
  protected abstract T computeNext();

  @CanIgnoreReturnValue

            

Reported by PMD.

Field next has the same name as a method
Error

Line: 45

                  FAILED,
  }

  @CheckForNull private T next;

  @CheckForNull
  protected abstract T computeNext();

  @CanIgnoreReturnValue

            

Reported by PMD.

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

Line: 89

                  state = State.NOT_READY;
    // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
    T result = uncheckedCastNullableTToT(next);
    next = null;
    return result;
  }

  @Override
  public final void remove() {

            

Reported by PMD.

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

Line: 33

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class Platform {
  private static final Logger logger = Logger.getLogger(Platform.class.getName());
  private static final PatternCompiler patternCompiler = loadPatternCompiler();

  private Platform() {}


            

Reported by PMD.

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

Line: 50

                }

  static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
    WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
    return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
  }

  static String formatCompact4Digits(double value) {
    return String.format(Locale.ROOT, "%.4g", value);

            

Reported by PMD.

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

Line: 51

              
  static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
    WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
    return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
  }

  static String formatCompact4Digits(double value) {
    return String.format(Locale.ROOT, "%.4g", value);
  }

            

Reported by PMD.

Avoid unused private methods such as 'logPatternCompilerError(ServiceConfigurationError)'.
Design

Line: 101

                  return new JdkPatternCompiler();
  }

  private static void logPatternCompilerError(ServiceConfigurationError e) {
    logger.log(Level.WARNING, "Error loading regex compiler, falling back to next option", e);
  }

  private static final class JdkPatternCompiler implements PatternCompiler {
    @Override

            

Reported by PMD.