The following issues were found

guava-testlib/src/com/google/common/collect/testing/google/ListMultimapAsMapTester.java
27 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: 47

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapAsMapTester<K, V> extends AbstractListMultimapTester<K, V> {
  public void testAsMapValuesImplementList() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof List);
    }
  }


            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapAsMapTester<K, V> extends AbstractListMultimapTester<K, V> {
  public void testAsMapValuesImplementList() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof List);
    }
  }

  public void testAsMapGetImplementsList() {

            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapAsMapTester<K, V> extends AbstractListMultimapTester<K, V> {
  public void testAsMapValuesImplementList() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof List);
    }
  }

  public void testAsMapGetImplementsList() {

            

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

                  }
  }

  public void testAsMapGetImplementsList() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof List);
    }
  }


            

Reported by PMD.

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

Line: 54

                }

  public void testAsMapGetImplementsList() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof List);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 55

              
  public void testAsMapGetImplementsList() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof List);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsList() {

            

Reported by PMD.

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

Line: 55

              
  public void testAsMapGetImplementsList() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof List);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsList() {

            

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

                  }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsList() {
    List<K> keys = new ArrayList<>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof List);

            

Reported by PMD.

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

Line: 61

              
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsList() {
    List<K> keys = new ArrayList<>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof List);
    }
  }

            

Reported by PMD.

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

Line: 64

                  List<K> keys = new ArrayList<>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof List);
    }
  }

  @CollectionSize.Require(SEVERAL)
  public void testEquals() {

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java
27 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: 32

              
  private static final Object OBJECT = new Object();

  public void testNewReference() throws Exception {
    assertEquals(null, Atomics.newReference().get());
  }

  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                private static final Object OBJECT = new Object();

  public void testNewReference() throws Exception {
    assertEquals(null, Atomics.newReference().get());
  }

  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());
    assertEquals(OBJECT, Atomics.newReference(OBJECT).get());

            

Reported by PMD.

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

Line: 33

                private static final Object OBJECT = new Object();

  public void testNewReference() throws Exception {
    assertEquals(null, Atomics.newReference().get());
  }

  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());
    assertEquals(OBJECT, Atomics.newReference(OBJECT).get());

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 36

                  assertEquals(null, Atomics.newReference().get());
  }

  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());
    assertEquals(OBJECT, Atomics.newReference(OBJECT).get());
  }

  public void testNewReferenceArray_withLength() throws Exception {

            

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

                  assertEquals(null, Atomics.newReference().get());
  }

  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());
    assertEquals(OBJECT, Atomics.newReference(OBJECT).get());
  }

  public void testNewReferenceArray_withLength() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                }

  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());
    assertEquals(OBJECT, Atomics.newReference(OBJECT).get());
  }

  public void testNewReferenceArray_withLength() throws Exception {
    int length = 42;

            

Reported by PMD.

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

Line: 37

                }

  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());
    assertEquals(OBJECT, Atomics.newReference(OBJECT).get());
  }

  public void testNewReferenceArray_withLength() throws Exception {
    int length = 42;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 38

              
  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());
    assertEquals(OBJECT, Atomics.newReference(OBJECT).get());
  }

  public void testNewReferenceArray_withLength() throws Exception {
    int length = 42;
    AtomicReferenceArray<String> refArray = Atomics.newReferenceArray(length);

            

Reported by PMD.

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

Line: 38

              
  public void testNewReference_withInitialValue() throws Exception {
    assertEquals(null, Atomics.newReference(null).get());
    assertEquals(OBJECT, Atomics.newReference(OBJECT).get());
  }

  public void testNewReferenceArray_withLength() throws Exception {
    int length = 42;
    AtomicReferenceArray<String> refArray = Atomics.newReferenceArray(length);

            

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

                  assertEquals(OBJECT, Atomics.newReference(OBJECT).get());
  }

  public void testNewReferenceArray_withLength() throws Exception {
    int length = 42;
    AtomicReferenceArray<String> refArray = Atomics.newReferenceArray(length);
    for (int i = 0; i < length; ++i) {
      assertEquals(null, refArray.get(i));
    }

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java
27 issues
JUnit tests should include assert() or fail()
Design

Line: 45

                      public void run() {}
      };

  public void testSchedule() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);

    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError = testExecutor.schedule(DO_NOTHING, 10, TimeUnit.MINUTES);

            

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

                      public void run() {}
      };

  public void testSchedule() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);

    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError = testExecutor.schedule(DO_NOTHING, 10, TimeUnit.MINUTES);

            

Reported by PMD.

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

Line: 49

                  MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);

    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError = testExecutor.schedule(DO_NOTHING, 10, TimeUnit.MINUTES);
    mock.assertLastMethodCalled("scheduleRunnable", 10, TimeUnit.MINUTES);

    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError1 =

            

Reported by PMD.

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

Line: 59

                  mock.assertLastMethodCalled("scheduleCallable", 5, TimeUnit.SECONDS);
  }

  public void testSchedule_repeating() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError =
        testExecutor.scheduleWithFixedDelay(DO_NOTHING, 100, 10, TimeUnit.MINUTES);

            

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

                  mock.assertLastMethodCalled("scheduleCallable", 5, TimeUnit.SECONDS);
  }

  public void testSchedule_repeating() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError =
        testExecutor.scheduleWithFixedDelay(DO_NOTHING, 100, 10, TimeUnit.MINUTES);

            

Reported by PMD.

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

Line: 74

                }

  private static final class WrappedCallable<T> implements Callable<T> {
    private final Callable<T> delegate;

    public WrappedCallable(Callable<T> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

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

Line: 87

                }

  private static final class WrappedRunnable implements Runnable {
    private final Runnable delegate;

    public WrappedRunnable(Runnable delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

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

Line: 115

                  }
  }

  private static final class MockExecutor implements ScheduledExecutorService {
    String lastMethodCalled = "";
    long lastInitialDelay;
    long lastDelay;
    TimeUnit lastUnit;


            

Reported by PMD.

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

Line: 116

                }

  private static final class MockExecutor implements ScheduledExecutorService {
    String lastMethodCalled = "";
    long lastInitialDelay;
    long lastDelay;
    TimeUnit lastUnit;

    void assertLastMethodCalled(String method, long delay, TimeUnit unit) {

            

Reported by PMD.

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

Line: 117

              
  private static final class MockExecutor implements ScheduledExecutorService {
    String lastMethodCalled = "";
    long lastInitialDelay;
    long lastDelay;
    TimeUnit lastUnit;

    void assertLastMethodCalled(String method, long delay, TimeUnit unit) {
      assertEquals(method, lastMethodCalled);

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/BiMapRemoveTester.java
27 issues
The String literal 'unchecked' appears 6 times in this file; the first occurrence is on line 38
Error

Line: 38

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapRemoveTester<K, V> extends AbstractBiMapTester<K, V> {
  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyRemovesFromInverse() {
    getMap().remove(k0());
    expectMissing(e0());

            

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

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapRemoveTester<K, V> extends AbstractBiMapTester<K, V> {
  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyRemovesFromInverse() {
    getMap().remove(k0());
    expectMissing(e0());

            

Reported by PMD.

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

Line: 42

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyRemovesFromInverse() {
    getMap().remove(k0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyFromKeySetRemovesFromInverse() {
    getMap().keySet().remove(k0());
    expectMissing(e0());

            

Reported by PMD.

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

Line: 50

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyFromKeySetRemovesFromInverse() {
    getMap().keySet().remove(k0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 50

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyFromKeySetRemovesFromInverse() {
    getMap().keySet().remove(k0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveFromValuesRemovesFromInverse() {
    getMap().values().remove(v0());
    expectMissing(e0());

            

Reported by PMD.

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

Line: 58

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveFromValuesRemovesFromInverse() {
    getMap().values().remove(v0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 58

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveFromValuesRemovesFromInverse() {
    getMap().values().remove(v0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveFromInverseRemovesFromForward() {
    getMap().inverse().remove(v0());
    expectMissing(e0());

            

Reported by PMD.

android/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
27 issues
Avoid using a branching statement as the last in a loop.
Error

Line: 431

                      continue;
      }

      return oldValue;
    }
  }

  /**
   * If {@code (key, expectedOldValue)} is currently in the map, this method replaces {@code

            

Reported by PMD.

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

Line: 58

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class AtomicLongMap<K> implements Serializable {
  private final ConcurrentHashMap<K, AtomicLong> map;

  private AtomicLongMap(ConcurrentHashMap<K, AtomicLong> map) {
    this.map = checkNotNull(map);
  }

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 58

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class AtomicLongMap<K> implements Serializable {
  private final ConcurrentHashMap<K, AtomicLong> map;

  private AtomicLongMap(ConcurrentHashMap<K, AtomicLong> map) {
    this.map = checkNotNull(map);
  }

            

Reported by PMD.

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

Line: 59

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public final class AtomicLongMap<K> implements Serializable {
  private final ConcurrentHashMap<K, AtomicLong> map;

  private AtomicLongMap(ConcurrentHashMap<K, AtomicLong> map) {
    this.map = checkNotNull(map);
  }


            

Reported by PMD.

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

Line: 73

                /** Creates an {@code AtomicLongMap} with the same mappings as the specified {@code Map}. */
  public static <K> AtomicLongMap<K> create(Map<? extends K, ? extends Long> m) {
    AtomicLongMap<K> result = create();
    result.putAll(m);
    return result;
  }

  /**
   * Returns the value associated with {@code key}, or zero if there is no value associated with

            

Reported by PMD.

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

Line: 83

                 */
  public long get(K key) {
    AtomicLong atomic = map.get(key);
    return atomic == null ? 0L : atomic.get();
  }

  /**
   * Increments by one the value currently associated with {@code key}, and returns the new value.
   */

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 112

                  while (true) {
      AtomicLong atomic = map.get(key);
      if (atomic == null) {
        atomic = map.putIfAbsent(key, new AtomicLong(delta));
        if (atomic == null) {
          return delta;
        }
        // atomic is now non-null; fall through
      }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 121

              
      while (true) {
        long oldValue = atomic.get();
        if (oldValue == 0L) {
          // don't compareAndSet a zero
          if (map.replace(key, atomic, new AtomicLong(delta))) {
            return delta;
          }
          // atomic replaced

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 123

                      long oldValue = atomic.get();
        if (oldValue == 0L) {
          // don't compareAndSet a zero
          if (map.replace(key, atomic, new AtomicLong(delta))) {
            return delta;
          }
          // atomic replaced
          continue outer;
        }

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 165

                  while (true) {
      AtomicLong atomic = map.get(key);
      if (atomic == null) {
        atomic = map.putIfAbsent(key, new AtomicLong(delta));
        if (atomic == null) {
          return 0L;
        }
        // atomic is now non-null; fall through
      }

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/BiMapRemoveTester.java
27 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: 38

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapRemoveTester<K, V> extends AbstractBiMapTester<K, V> {
  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyRemovesFromInverse() {
    getMap().remove(k0());
    expectMissing(e0());

            

Reported by PMD.

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

Line: 38

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapRemoveTester<K, V> extends AbstractBiMapTester<K, V> {
  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyRemovesFromInverse() {
    getMap().remove(k0());
    expectMissing(e0());

            

Reported by PMD.

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

Line: 42

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyRemovesFromInverse() {
    getMap().remove(k0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyFromKeySetRemovesFromInverse() {
    getMap().keySet().remove(k0());
    expectMissing(e0());

            

Reported by PMD.

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

Line: 50

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyFromKeySetRemovesFromInverse() {
    getMap().keySet().remove(k0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 50

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveKeyFromKeySetRemovesFromInverse() {
    getMap().keySet().remove(k0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveFromValuesRemovesFromInverse() {
    getMap().values().remove(v0());
    expectMissing(e0());

            

Reported by PMD.

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

Line: 58

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveFromValuesRemovesFromInverse() {
    getMap().values().remove(v0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 58

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveFromValuesRemovesFromInverse() {
    getMap().values().remove(v0());
    expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)

            

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

                  expectMissing(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemoveFromInverseRemovesFromForward() {
    getMap().inverse().remove(v0());
    expectMissing(e0());

            

Reported by PMD.

android/guava-testlib/src/com/google/common/testing/AbstractPackageSanityTests.java
27 issues
The Logger variable declaration does not contain the static and final modifiers
Error

Line: 151

                private static final Chopper TEST_SUFFIX =
      suffix("Test").or(suffix("Tests")).or(suffix("TestCase")).or(suffix("TestSuite"));

  private final Logger logger = Logger.getLogger(getClass().getName());
  private final ClassSanityTester tester = new ClassSanityTester();
  private Visibility visibility = Visibility.PACKAGE;
  private Predicate<Class<?>> classFilter =
      new Predicate<Class<?>>() {
        @Override

            

Reported by PMD.

Logger calls should be surrounded by log level guards.
Design

Line: 386

                      cls = classInfo.load();
      } catch (NoClassDefFoundError e) {
        // In case there were linking problems, this is probably not a class we care to test anyway.
        logger.log(Level.SEVERE, "Cannot load class " + classInfo + ", skipping...", e);
        continue;
      }
      if (!cls.isInterface()) {
        classes.add(cls);
      }

            

Reported by PMD.

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

Line: 122

                    new Predicate<Class<?>>() {
        @Override
        public boolean apply(Class<?> c) {
          return c.getSimpleName().contains("_");
        }
      };

  /* The names of the expected method that tests null checks. */
  private static final ImmutableList<String> NULL_TEST_METHOD_NAMES =

            

Reported by PMD.

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

Line: 151

                private static final Chopper TEST_SUFFIX =
      suffix("Test").or(suffix("Tests")).or(suffix("TestCase")).or(suffix("TestSuite"));

  private final Logger logger = Logger.getLogger(getClass().getName());
  private final ClassSanityTester tester = new ClassSanityTester();
  private Visibility visibility = Visibility.PACKAGE;
  private Predicate<Class<?>> classFilter =
      new Predicate<Class<?>>() {
        @Override

            

Reported by PMD.

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

Line: 152

                    suffix("Test").or(suffix("Tests")).or(suffix("TestCase")).or(suffix("TestSuite"));

  private final Logger logger = Logger.getLogger(getClass().getName());
  private final ClassSanityTester tester = new ClassSanityTester();
  private Visibility visibility = Visibility.PACKAGE;
  private Predicate<Class<?>> classFilter =
      new Predicate<Class<?>>() {
        @Override
        public boolean apply(Class<?> cls) {

            

Reported by PMD.

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

Line: 153

              
  private final Logger logger = Logger.getLogger(getClass().getName());
  private final ClassSanityTester tester = new ClassSanityTester();
  private Visibility visibility = Visibility.PACKAGE;
  private Predicate<Class<?>> classFilter =
      new Predicate<Class<?>>() {
        @Override
        public boolean apply(Class<?> cls) {
          return visibility.isVisible(cls.getModifiers());

            

Reported by PMD.

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

Line: 154

                private final Logger logger = Logger.getLogger(getClass().getName());
  private final ClassSanityTester tester = new ClassSanityTester();
  private Visibility visibility = Visibility.PACKAGE;
  private Predicate<Class<?>> classFilter =
      new Predicate<Class<?>>() {
        @Override
        public boolean apply(Class<?> cls) {
          return visibility.isVisible(cls.getModifiers());
        }

            

Reported by PMD.

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

Line: 199

                 * C} will be excluded from automated serialization test performed by this method.
   */
  @Test
  public void testSerializable() throws Exception {
    // TODO: when we use @BeforeClass, we can pay the cost of class path scanning only once.
    for (Class<?> classToTest :
        findClassesToTest(loadClassesInPackage(), SERIALIZABLE_TEST_METHOD_NAMES)) {
      if (Serializable.class.isAssignableFrom(classToTest)) {
        try {

            

Reported by PMD.

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

Line: 213

                            SerializableTester.reserialize(instance);
            }
          }
        } catch (Throwable e) {
          throw sanityError(classToTest, SERIALIZABLE_TEST_METHOD_NAMES, "serializable test", e);
        }
      }
    }
  }

            

Reported by PMD.

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

Line: 244

                 * excluded from the automated null tests performed by this method.
   */
  @Test
  public void testNulls() throws Exception {
    for (Class<?> classToTest : findClassesToTest(loadClassesInPackage(), NULL_TEST_METHOD_NAMES)) {
      try {
        tester.doTestNulls(classToTest, visibility);
      } catch (Throwable e) {
        throw sanityError(classToTest, NULL_TEST_METHOD_NAMES, "nulls test", e);

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/ListMultimapAsMapTester.java
27 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: 47

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapAsMapTester<K, V> extends AbstractListMultimapTester<K, V> {
  public void testAsMapValuesImplementList() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof List);
    }
  }


            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapAsMapTester<K, V> extends AbstractListMultimapTester<K, V> {
  public void testAsMapValuesImplementList() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof List);
    }
  }

  public void testAsMapGetImplementsList() {

            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapAsMapTester<K, V> extends AbstractListMultimapTester<K, V> {
  public void testAsMapValuesImplementList() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof List);
    }
  }

  public void testAsMapGetImplementsList() {

            

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

                  }
  }

  public void testAsMapGetImplementsList() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof List);
    }
  }


            

Reported by PMD.

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

Line: 54

                }

  public void testAsMapGetImplementsList() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof List);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 55

              
  public void testAsMapGetImplementsList() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof List);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsList() {

            

Reported by PMD.

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

Line: 55

              
  public void testAsMapGetImplementsList() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof List);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsList() {

            

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

                  }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsList() {
    List<K> keys = new ArrayList<>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof List);

            

Reported by PMD.

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

Line: 61

              
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsList() {
    List<K> keys = new ArrayList<>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof List);
    }
  }

            

Reported by PMD.

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

Line: 64

                  List<K> keys = new ArrayList<>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof List);
    }
  }

  @CollectionSize.Require(SEVERAL)
  public void testEquals() {

            

Reported by PMD.

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

Line: 34

               * @author Charles Fry
 */
public class ForwardingCacheTest extends TestCase {
  private Cache<String, Boolean> forward;
  private Cache<String, Boolean> mock;

  @SuppressWarnings({"unchecked", "DoNotMock"}) // mock
  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 35

               */
public class ForwardingCacheTest extends TestCase {
  private Cache<String, Boolean> forward;
  private Cache<String, Boolean> mock;

  @SuppressWarnings({"unchecked", "DoNotMock"}) // mock
  @Override
  public void setUp() throws Exception {
    super.setUp();

            

Reported by PMD.

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

Line: 37

                private Cache<String, Boolean> forward;
  private Cache<String, Boolean> mock;

  @SuppressWarnings({"unchecked", "DoNotMock"}) // mock
  @Override
  public void setUp() throws Exception {
    super.setUp();
    /*
     * Class parameters must be raw, so we can't create a proxy with generic

            

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

                      };
  }

  public void testGetIfPresent() throws ExecutionException {
    when(mock.getIfPresent("key")).thenReturn(Boolean.TRUE);
    assertSame(Boolean.TRUE, forward.getIfPresent("key"));
  }

  public void testGetAllPresent() throws ExecutionException {

            

Reported by PMD.

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

Line: 57

                }

  public void testGetIfPresent() throws ExecutionException {
    when(mock.getIfPresent("key")).thenReturn(Boolean.TRUE);
    assertSame(Boolean.TRUE, forward.getIfPresent("key"));
  }

  public void testGetAllPresent() throws ExecutionException {
    when(mock.getAllPresent(ImmutableList.of("key")))

            

Reported by PMD.

The String literal 'key' appears 10 times in this file; the first occurrence is on line 57
Error

Line: 57

                }

  public void testGetIfPresent() throws ExecutionException {
    when(mock.getIfPresent("key")).thenReturn(Boolean.TRUE);
    assertSame(Boolean.TRUE, forward.getIfPresent("key"));
  }

  public void testGetAllPresent() throws ExecutionException {
    when(mock.getAllPresent(ImmutableList.of("key")))

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 58

              
  public void testGetIfPresent() throws ExecutionException {
    when(mock.getIfPresent("key")).thenReturn(Boolean.TRUE);
    assertSame(Boolean.TRUE, forward.getIfPresent("key"));
  }

  public void testGetAllPresent() throws ExecutionException {
    when(mock.getAllPresent(ImmutableList.of("key")))
        .thenReturn(ImmutableMap.of("key", Boolean.TRUE));

            

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

                  assertSame(Boolean.TRUE, forward.getIfPresent("key"));
  }

  public void testGetAllPresent() throws ExecutionException {
    when(mock.getAllPresent(ImmutableList.of("key")))
        .thenReturn(ImmutableMap.of("key", Boolean.TRUE));
    assertEquals(
        ImmutableMap.of("key", Boolean.TRUE), forward.getAllPresent(ImmutableList.of("key")));
  }

            

Reported by PMD.

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

Line: 62

                }

  public void testGetAllPresent() throws ExecutionException {
    when(mock.getAllPresent(ImmutableList.of("key")))
        .thenReturn(ImmutableMap.of("key", Boolean.TRUE));
    assertEquals(
        ImmutableMap.of("key", Boolean.TRUE), forward.getAllPresent(ImmutableList.of("key")));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 64

                public void testGetAllPresent() throws ExecutionException {
    when(mock.getAllPresent(ImmutableList.of("key")))
        .thenReturn(ImmutableMap.of("key", Boolean.TRUE));
    assertEquals(
        ImmutableMap.of("key", Boolean.TRUE), forward.getAllPresent(ImmutableList.of("key")));
  }

  public void testInvalidate() {
    forward.invalidate("key");

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/SetMultimapAsMapTester.java
27 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: 47

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
  public void testAsMapValuesImplementSet() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof Set);
    }
  }


            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
  public void testAsMapValuesImplementSet() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof Set);
    }
  }

  public void testAsMapGetImplementsSet() {

            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
  public void testAsMapValuesImplementSet() {
    for (Collection<V> valueCollection : multimap().asMap().values()) {
      assertTrue(valueCollection instanceof Set);
    }
  }

  public void testAsMapGetImplementsSet() {

            

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

                  }
  }

  public void testAsMapGetImplementsSet() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof Set);
    }
  }


            

Reported by PMD.

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

Line: 54

                }

  public void testAsMapGetImplementsSet() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof Set);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 55

              
  public void testAsMapGetImplementsSet() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof Set);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsSet() {

            

Reported by PMD.

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

Line: 55

              
  public void testAsMapGetImplementsSet() {
    for (K key : multimap().keySet()) {
      assertTrue(multimap().asMap().get(key) instanceof Set);
    }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsSet() {

            

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

                  }
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsSet() {
    List<K> keys = new ArrayList<K>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof Set);

            

Reported by PMD.

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

Line: 61

              
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testAsMapRemoveImplementsSet() {
    List<K> keys = new ArrayList<K>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof Set);
    }
  }

            

Reported by PMD.

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

Line: 64

                  List<K> keys = new ArrayList<K>(multimap().keySet());
    for (K key : keys) {
      resetCollection();
      assertTrue(multimap().asMap().remove(key) instanceof Set);
    }
  }

  @CollectionSize.Require(SEVERAL)
  public void testEquals() {

            

Reported by PMD.