The following issues were found

android/guava-testlib/src/com/google/common/collect/testing/TestIntegerSetGenerator.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<Integer> create(Integer[] elements);

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

            

Reported by PMD.

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

Line: 38

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

            

Reported by PMD.

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

Line: 39

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

            

Reported by PMD.

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

Line: 41

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

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

            

Reported by PMD.

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

Line: 47

                  return create(array);
  }

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

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

            

Reported by PMD.

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

Line: 39

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

            

Reported by PMD.

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

Line: 40

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

            

Reported by PMD.

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

Line: 42

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

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

            

Reported by PMD.

android/guava-testlib/src/com/google/common/util/concurrent/testing/MockFutureListener.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 38

              @Beta
@GwtIncompatible
public class MockFutureListener implements Runnable {
  private final CountDownLatch countDownLatch;
  private final ListenableFuture<?> future;

  public MockFutureListener(ListenableFuture<?> future) {
    this.countDownLatch = new CountDownLatch(1);
    this.future = future;

            

Reported by PMD.

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

Line: 39

              @GwtIncompatible
public class MockFutureListener implements Runnable {
  private final CountDownLatch countDownLatch;
  private final ListenableFuture<?> future;

  public MockFutureListener(ListenableFuture<?> future) {
    this.countDownLatch = new CountDownLatch(1);
    this.future = future;


            

Reported by PMD.

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

Line: 76

                 * throws an {@code ExecutableException} and that the cause of the {@code ExecutableException} is
   * {@code expectedCause}.
   */
  public void assertException(Throwable expectedCause) throws Exception {
    // Verify that the listener executed in a reasonable amount of time.
    Assert.assertTrue(countDownLatch.await(1L, TimeUnit.SECONDS));

    try {
      future.get();

            

Reported by PMD.

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

Line: 88

                  }
  }

  public void assertTimeout() throws Exception {
    // Verify that the listener does not get called in a reasonable amount of
    // time.
    Assert.assertFalse(countDownLatch.await(1L, TimeUnit.SECONDS));
  }
}

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/TestingCacheLoaders.java
4 issues
All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 34

               * @author mike nonemacher
 */
@GwtCompatible(emulated = true)
class TestingCacheLoaders {

  /**
   * Returns a {@link CacheLoader} that implements a naive {@link CacheLoader#loadAll}, delegating
   * {@link CacheLoader#load} calls to {@code loader}.
   */

            

Reported by PMD.

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

Line: 115

                }

  static final class ConstantLoader<K, V> extends CacheLoader<K, V> {
    private final V constant;

    ConstantLoader(V constant) {
      this.constant = constant;
    }


            

Reported by PMD.

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

Line: 134

                 * and {@link #getReloadCount}.
   */
  static class IncrementingLoader extends CacheLoader<Integer, Integer> {
    private final AtomicInteger countLoad = new AtomicInteger();
    private final AtomicInteger countReload = new AtomicInteger();

    @Override
    public Integer load(Integer key) {
      countLoad.incrementAndGet();

            

Reported by PMD.

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

Line: 135

                 */
  static class IncrementingLoader extends CacheLoader<Integer, Integer> {
    private final AtomicInteger countLoad = new AtomicInteger();
    private final AtomicInteger countReload = new AtomicInteger();

    @Override
    public Integer load(Integer key) {
      countLoad.incrementAndGet();
      return key;

            

Reported by PMD.

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

Line: 34

               */
public final class TestByteSource extends ByteSource implements TestStreamSupplier {

  private final byte[] bytes;
  private final ImmutableSet<TestOption> options;

  private boolean inputStreamOpened;
  private boolean inputStreamClosed;


            

Reported by PMD.

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

Line: 35

              public final class TestByteSource extends ByteSource implements TestStreamSupplier {

  private final byte[] bytes;
  private final ImmutableSet<TestOption> options;

  private boolean inputStreamOpened;
  private boolean inputStreamClosed;

  TestByteSource(byte[] bytes, TestOption... options) {

            

Reported by PMD.

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

Line: 37

                private final byte[] bytes;
  private final ImmutableSet<TestOption> options;

  private boolean inputStreamOpened;
  private boolean inputStreamClosed;

  TestByteSource(byte[] bytes, TestOption... options) {
    this.bytes = checkNotNull(bytes);
    this.options = ImmutableSet.copyOf(options);

            

Reported by PMD.

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

Line: 38

                private final ImmutableSet<TestOption> options;

  private boolean inputStreamOpened;
  private boolean inputStreamClosed;

  TestByteSource(byte[] bytes, TestOption... options) {
    this.bytes = checkNotNull(bytes);
    this.options = ImmutableSet.copyOf(options);
  }

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/MapIsEmptyTester.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: 35

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapIsEmptyTester<K, V> extends AbstractMapTester<K, V> {
  @CollectionSize.Require(ZERO)
  public void testIsEmpty_yes() {
    assertTrue("isEmpty() should return true", getMap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 37

              public class MapIsEmptyTester<K, V> extends AbstractMapTester<K, V> {
  @CollectionSize.Require(ZERO)
  public void testIsEmpty_yes() {
    assertTrue("isEmpty() should return true", getMap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testIsEmpty_no() {
    assertFalse("isEmpty() should return false", getMap().isEmpty());

            

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: 40

                  assertTrue("isEmpty() should return true", getMap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testIsEmpty_no() {
    assertFalse("isEmpty() should return false", getMap().isEmpty());
  }
}

            

Reported by PMD.

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

Line: 42

              
  @CollectionSize.Require(absent = ZERO)
  public void testIsEmpty_no() {
    assertFalse("isEmpty() should return false", getMap().isEmpty());
  }
}

            

Reported by PMD.

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

Line: 73

                  return create(array);
  }

  protected abstract SetMultimap<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 '63'-'68').
Error

Line: 63

                @Override
  public final SetMultimap<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 '64'-'71').
Error

Line: 64

                public final SetMultimap<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 '68'-'68').
Error

Line: 68

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

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

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/TestEnumMapGenerator.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<AnEnum, String> create(Entry<AnEnum, String>[] entries);

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

            

Reported by PMD.

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

Line: 48

                public final Map<AnEnum, String> create(Object... entries) {
    @SuppressWarnings("unchecked")
    Entry<AnEnum, String>[] array = new Entry[entries.length];
    int i = 0;
    for (Object o : entries) {
      @SuppressWarnings("unchecked")
      Entry<AnEnum, String> e = (Entry<AnEnum, 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<AnEnum, String> e = (Entry<AnEnum, String>) o;
      array[i++] = e;
    }
    return create(array);
  }

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

            

Reported by PMD.

android/guava-testlib/src/com/google/common/testing/SloppyTearDown.java
4 issues
Logger calls should be surrounded by log level guards.
Design

Line: 43

                  try {
      sloppyTearDown();
    } catch (Throwable t) {
      logger.log(Level.INFO, "exception thrown during tearDown: " + t.getMessage(), t);
    }
  }

  public abstract void sloppyTearDown() throws Exception;
}

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 38

              public abstract class SloppyTearDown implements TearDown {
  private static final Logger logger = Logger.getLogger(SloppyTearDown.class.getName());

  @Override
  public final void tearDown() {
    try {
      sloppyTearDown();
    } catch (Throwable t) {
      logger.log(Level.INFO, "exception thrown during tearDown: " + t.getMessage(), t);

            

Reported by PMD.

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

Line: 42

                public final void tearDown() {
    try {
      sloppyTearDown();
    } catch (Throwable t) {
      logger.log(Level.INFO, "exception thrown during tearDown: " + t.getMessage(), t);
    }
  }

  public abstract void sloppyTearDown() throws Exception;

            

Reported by PMD.

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

Line: 47

                  }
  }

  public abstract void sloppyTearDown() throws Exception;
}

            

Reported by PMD.

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

Line: 47

                  return create(array);
  }

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

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

            

Reported by PMD.

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

Line: 39

              
  @Override
  public Multiset<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 '40'-'45').
Error

Line: 40

                @Override
  public Multiset<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 '42'-'42').
Error

Line: 42

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

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

            

Reported by PMD.