The following issues were found

android/guava-tests/test/com/google/common/hash/BloomFilterTest.java
174 issues
Possible God Class (WMC=81, ATFD=26, TCC=0.672%)
Design

Line: 47

               *
 * @author Dimitris Andreou
 */
public class BloomFilterTest extends TestCase {
  private static final int NUM_PUTS = 100_000;
  private static final ThreadLocal<Random> random =
      new ThreadLocal<Random>() {
        @Override
        protected Random initialValue() {

            

Reported by PMD.

The class 'BloomFilterTest' has a total cyclomatic complexity of 81 (highest 7).
Design

Line: 47

               *
 * @author Dimitris Andreou
 */
public class BloomFilterTest extends TestCase {
  private static final int NUM_PUTS = 100_000;
  private static final ThreadLocal<Random> random =
      new ThreadLocal<Random>() {
        @Override
        protected Random initialValue() {

            

Reported by PMD.

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

Line: 47

               *
 * @author Dimitris Andreou
 */
public class BloomFilterTest extends TestCase {
  private static final int NUM_PUTS = 100_000;
  private static final ThreadLocal<Random> random =
      new ThreadLocal<Random>() {
        @Override
        protected Random initialValue() {

            

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

              
  private static final int GOLDEN_PRESENT_KEY = random.get().nextInt();

  @AndroidIncompatible // OutOfMemoryError
  public void testLargeBloomFilterDoesntOverflow() {
    long numBits = Integer.MAX_VALUE;
    numBits++;

    LockFreeBitArray bitArray = new LockFreeBitArray(numBits);

            

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

                  assertThat(bf.approximateElementCount()).isAtMost((long) (sizeGuess * 1.01));
  }

  public void testCreateAndCheckMitz32BloomFilterWithKnownFalsePositives() {
    int numInsertions = 1000000;
    BloomFilter<String> bf =
        BloomFilter.create(
            Funnels.unencodedCharsFunnel(),
            numInsertions,

            

Reported by PMD.

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

Line: 82

                  assertThat(bf.approximateElementCount()).isAtMost((long) (sizeGuess * 1.01));
  }

  public void testCreateAndCheckMitz32BloomFilterWithKnownFalsePositives() {
    int numInsertions = 1000000;
    BloomFilter<String> bf =
        BloomFilter.create(
            Funnels.unencodedCharsFunnel(),
            numInsertions,

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 99

              
    // Assert that the BF "might" have all of the even numbers.
    for (int i = 0; i < numInsertions * 2; i += 2) {
      assertTrue(bf.mightContain(Integer.toString(i)));
    }

    // Now we check for known false positives using a set of known false positives.
    // (These are all of the false positives under 900.)
    ImmutableSet<Integer> falsePositives =

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 121

                      numFpp++;
      }
    }
    assertEquals(knownNumberOfFalsePositives, numFpp);
    double expectedReportedFpp = (double) knownNumberOfFalsePositives / numInsertions;
    double actualReportedFpp = bf.expectedFpp();
    assertEquals(expectedReportedFpp, actualReportedFpp, 0.00015);
  }


            

Reported by PMD.

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

Line: 123

                  }
    assertEquals(knownNumberOfFalsePositives, numFpp);
    double expectedReportedFpp = (double) knownNumberOfFalsePositives / numInsertions;
    double actualReportedFpp = bf.expectedFpp();
    assertEquals(expectedReportedFpp, actualReportedFpp, 0.00015);
  }

  public void testCreateAndCheckBloomFilterWithKnownFalsePositives64() {
    int numInsertions = 1000000;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 124

                  assertEquals(knownNumberOfFalsePositives, numFpp);
    double expectedReportedFpp = (double) knownNumberOfFalsePositives / numInsertions;
    double actualReportedFpp = bf.expectedFpp();
    assertEquals(expectedReportedFpp, actualReportedFpp, 0.00015);
  }

  public void testCreateAndCheckBloomFilterWithKnownFalsePositives64() {
    int numInsertions = 1000000;
    BloomFilter<String> bf =

            

Reported by PMD.

android/guava-tests/test/com/google/common/io/CloserTest.java
174 issues
This class has too many methods, consider refactoring it.
Design

Line: 42

               *
 * @author Colin Decker
 */
public class CloserTest extends TestCase {

  private TestSuppressor suppressor;

  @Override
  protected void setUp() throws Exception {

            

Reported by PMD.

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

Line: 44

               */
public class CloserTest extends TestCase {

  private TestSuppressor suppressor;

  @Override
  protected void setUp() throws Exception {
    suppressor = new TestSuppressor();
  }

            

Reported by PMD.

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

Line: 46

              
  private TestSuppressor suppressor;

  @Override
  protected void setUp() throws Exception {
    suppressor = new TestSuppressor();
  }

  @AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.

            

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

                  suppressor = new TestSuppressor();
  }

  @AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.
  public void testCreate() {
    assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {

            

Reported by PMD.

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

Line: 53

              
  @AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.
  public void testCreate() {
    assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);


            

Reported by PMD.

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

Line: 53

              
  @AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.
  public void testCreate() {
    assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);


            

Reported by PMD.

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

Line: 56

                  assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);

    TestCloseable c1 = closer.register(TestCloseable.normal());
    TestCloseable c2 = closer.register(TestCloseable.normal());
    TestCloseable c3 = closer.register(TestCloseable.normal());

            

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

                  assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);

    TestCloseable c1 = closer.register(TestCloseable.normal());
    TestCloseable c2 = closer.register(TestCloseable.normal());
    TestCloseable c3 = closer.register(TestCloseable.normal());

            

Reported by PMD.

Ensure that resources like this Closer object are closed after use
Error

Line: 57

                }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);

    TestCloseable c1 = closer.register(TestCloseable.normal());
    TestCloseable c2 = closer.register(TestCloseable.normal());
    TestCloseable c3 = closer.register(TestCloseable.normal());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                  TestCloseable c2 = closer.register(TestCloseable.normal());
    TestCloseable c3 = closer.register(TestCloseable.normal());

    assertFalse(c1.isClosed());
    assertFalse(c2.isClosed());
    assertFalse(c3.isClosed());

    closer.close();


            

Reported by PMD.

guava-tests/test/com/google/common/io/CloserTest.java
174 issues
This class has too many methods, consider refactoring it.
Design

Line: 42

               *
 * @author Colin Decker
 */
public class CloserTest extends TestCase {

  private TestSuppressor suppressor;

  @Override
  protected void setUp() throws Exception {

            

Reported by PMD.

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

Line: 44

               */
public class CloserTest extends TestCase {

  private TestSuppressor suppressor;

  @Override
  protected void setUp() throws Exception {
    suppressor = new TestSuppressor();
  }

            

Reported by PMD.

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

Line: 46

              
  private TestSuppressor suppressor;

  @Override
  protected void setUp() throws Exception {
    suppressor = new TestSuppressor();
  }

  @AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.

            

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

                  suppressor = new TestSuppressor();
  }

  @AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.
  public void testCreate() {
    assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {

            

Reported by PMD.

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

Line: 53

              
  @AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.
  public void testCreate() {
    assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);


            

Reported by PMD.

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

Line: 53

              
  @AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.
  public void testCreate() {
    assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);


            

Reported by PMD.

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

Line: 56

                  assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);

    TestCloseable c1 = closer.register(TestCloseable.normal());
    TestCloseable c2 = closer.register(TestCloseable.normal());
    TestCloseable c3 = closer.register(TestCloseable.normal());

            

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

                  assertThat(Closer.create().suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);

    TestCloseable c1 = closer.register(TestCloseable.normal());
    TestCloseable c2 = closer.register(TestCloseable.normal());
    TestCloseable c3 = closer.register(TestCloseable.normal());

            

Reported by PMD.

Ensure that resources like this Closer object are closed after use
Error

Line: 57

                }

  public void testNoExceptionsThrown() throws IOException {
    Closer closer = new Closer(suppressor);

    TestCloseable c1 = closer.register(TestCloseable.normal());
    TestCloseable c2 = closer.register(TestCloseable.normal());
    TestCloseable c3 = closer.register(TestCloseable.normal());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                  TestCloseable c2 = closer.register(TestCloseable.normal());
    TestCloseable c3 = closer.register(TestCloseable.normal());

    assertFalse(c1.isClosed());
    assertFalse(c2.isClosed());
    assertFalse(c3.isClosed());

    closer.close();


            

Reported by PMD.

guava-tests/test/com/google/common/base/OptionalTest.java
173 issues
Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 230

                public void testEqualsAndHashCode() {
    new EqualsTester()
        .addEqualityGroup(Optional.absent(), reserialize(Optional.absent()))
        .addEqualityGroup(Optional.of(new Long(5)), reserialize(Optional.of(new Long(5))))
        .addEqualityGroup(Optional.of(new Long(42)), reserialize(Optional.of(new Long(42))))
        .testEquals();
  }

  public void testToString_absent() {

            

Reported by PMD.

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

Line: 230

                public void testEqualsAndHashCode() {
    new EqualsTester()
        .addEqualityGroup(Optional.absent(), reserialize(Optional.absent()))
        .addEqualityGroup(Optional.of(new Long(5)), reserialize(Optional.of(new Long(5))))
        .addEqualityGroup(Optional.of(new Long(42)), reserialize(Optional.of(new Long(42))))
        .testEquals();
  }

  public void testToString_absent() {

            

Reported by PMD.

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

Line: 231

                  new EqualsTester()
        .addEqualityGroup(Optional.absent(), reserialize(Optional.absent()))
        .addEqualityGroup(Optional.of(new Long(5)), reserialize(Optional.of(new Long(5))))
        .addEqualityGroup(Optional.of(new Long(42)), reserialize(Optional.of(new Long(42))))
        .testEquals();
  }

  public void testToString_absent() {
    assertEquals("Optional.absent()", Optional.absent().toString());

            

Reported by PMD.

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

Line: 231

                  new EqualsTester()
        .addEqualityGroup(Optional.absent(), reserialize(Optional.absent()))
        .addEqualityGroup(Optional.of(new Long(5)), reserialize(Optional.of(new Long(5))))
        .addEqualityGroup(Optional.of(new Long(42)), reserialize(Optional.of(new Long(42))))
        .testEquals();
  }

  public void testToString_absent() {
    assertEquals("Optional.absent()", Optional.absent().toString());

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.base;

import static com.google.common.testing.SerializableTester.reserialize;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.annotations.GwtCompatible;

            

Reported by PMD.

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

Line: 39

               * @author Kurt Alfred Kluever
 */
@GwtCompatible(emulated = true)
public final class OptionalTest extends TestCase {
  public void testToJavaUtil_static() {
    assertNull(Optional.toJavaUtil(null));
    assertEquals(java.util.Optional.empty(), Optional.toJavaUtil(Optional.absent()));
    assertEquals(java.util.Optional.of("abc"), Optional.toJavaUtil(Optional.of("abc")));
  }

            

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

               */
@GwtCompatible(emulated = true)
public final class OptionalTest extends TestCase {
  public void testToJavaUtil_static() {
    assertNull(Optional.toJavaUtil(null));
    assertEquals(java.util.Optional.empty(), Optional.toJavaUtil(Optional.absent()));
    assertEquals(java.util.Optional.of("abc"), Optional.toJavaUtil(Optional.of("abc")));
  }


            

Reported by PMD.

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

Line: 40

               */
@GwtCompatible(emulated = true)
public final class OptionalTest extends TestCase {
  public void testToJavaUtil_static() {
    assertNull(Optional.toJavaUtil(null));
    assertEquals(java.util.Optional.empty(), Optional.toJavaUtil(Optional.absent()));
    assertEquals(java.util.Optional.of("abc"), Optional.toJavaUtil(Optional.of("abc")));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

              @GwtCompatible(emulated = true)
public final class OptionalTest extends TestCase {
  public void testToJavaUtil_static() {
    assertNull(Optional.toJavaUtil(null));
    assertEquals(java.util.Optional.empty(), Optional.toJavaUtil(Optional.absent()));
    assertEquals(java.util.Optional.of("abc"), Optional.toJavaUtil(Optional.of("abc")));
  }

  public void testToJavaUtil_instance() {

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 42

              public final class OptionalTest extends TestCase {
  public void testToJavaUtil_static() {
    assertNull(Optional.toJavaUtil(null));
    assertEquals(java.util.Optional.empty(), Optional.toJavaUtil(Optional.absent()));
    assertEquals(java.util.Optional.of("abc"), Optional.toJavaUtil(Optional.of("abc")));
  }

  public void testToJavaUtil_instance() {
    assertEquals(java.util.Optional.empty(), Optional.absent().toJavaUtil());

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/UninterruptiblesTest.java
171 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * the License.
 */

package com.google.common.util.concurrent;

import static com.google.common.util.concurrent.InterruptionUtil.repeatedlyInterruptTestThread;
import static com.google.common.util.concurrent.Uninterruptibles.awaitTerminationUninterruptibly;
import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly;
import static com.google.common.util.concurrent.Uninterruptibles.joinUninterruptibly;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * the License.
 */

package com.google.common.util.concurrent;

import static com.google.common.util.concurrent.InterruptionUtil.repeatedlyInterruptTestThread;
import static com.google.common.util.concurrent.Uninterruptibles.awaitTerminationUninterruptibly;
import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly;
import static com.google.common.util.concurrent.Uninterruptibles.joinUninterruptibly;

            

Reported by PMD.

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

Line: 58

               * @author Anthony Zana
 */

public class UninterruptiblesTest extends TestCase {
  private static final String EXPECTED_TAKE = "expectedTake";

  /** Timeout to use when we don't expect the timeout to expire. */
  private static final long LONG_DELAY_MS = 2500;


            

Reported by PMD.

Possible God Class (WMC=59, ATFD=8, TCC=28.634%)
Design

Line: 58

               * @author Anthony Zana
 */

public class UninterruptiblesTest extends TestCase {
  private static final String EXPECTED_TAKE = "expectedTake";

  /** Timeout to use when we don't expect the timeout to expire. */
  private static final long LONG_DELAY_MS = 2500;


            

Reported by PMD.

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

Line: 66

              
  private static final long SLEEP_SLACK = 2;

  private final TearDownStack tearDownStack = new TearDownStack();

  // NOTE: All durations in these tests are expressed in milliseconds
  @Override
  protected void setUp() {
    // Clear any previous interrupt before running the test.

            

Reported by PMD.

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

Line: 69

                private final TearDownStack tearDownStack = new TearDownStack();

  // NOTE: All durations in these tests are expressed in milliseconds
  @Override
  protected void setUp() {
    // Clear any previous interrupt before running the test.
    if (Thread.currentThread().isInterrupted()) {
      throw new AssertionError(
          "Thread interrupted on test entry. "

            

Reported by PMD.

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

Line: 72

                @Override
  protected void setUp() {
    // Clear any previous interrupt before running the test.
    if (Thread.currentThread().isInterrupted()) {
      throw new AssertionError(
          "Thread interrupted on test entry. "
              + "Some test probably didn't clear the interrupt state");
    }


            

Reported by PMD.

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

Line: 80

              
    tearDownStack.addTearDown(
        new TearDown() {
          @Override
          public void tearDown() {
            Thread.interrupted();
          }
        });
  }

            

Reported by PMD.

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

Line: 87

                      });
  }

  @Override
  protected void tearDown() {
    tearDownStack.runTearDown();
  }

  public void testNull() throws Exception {

            

Reported by PMD.

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

Line: 92

                  tearDownStack.runTearDown();
  }

  public void testNull() throws Exception {
    new NullPointerTester()
        .setDefault(CountDownLatch.class, new CountDownLatch(0))
        .setDefault(Semaphore.class, new Semaphore(999))
        .testAllPublicStaticMethods(Uninterruptibles.class);
  }

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
171 issues
Class contains more than one logger.
Error

Line: 53

               * @author Luke Sandberg
 * @author Chris Nokleberg
 */
public class ServiceManagerTest extends TestCase {

  private static class NoOpService extends AbstractService {
    @Override
    protected void doStart() {
      notifyStarted();

            

Reported by PMD.

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

Line: 53

               * @author Luke Sandberg
 * @author Chris Nokleberg
 */
public class ServiceManagerTest extends TestCase {

  private static class NoOpService extends AbstractService {
    @Override
    protected void doStart() {
      notifyStarted();

            

Reported by PMD.

The class 'ServiceManagerTest' has a Modified Cyclomatic Complexity of 3 (Highest = 12).
Design

Line: 53

               * @author Luke Sandberg
 * @author Chris Nokleberg
 */
public class ServiceManagerTest extends TestCase {

  private static class NoOpService extends AbstractService {
    @Override
    protected void doStart() {
      notifyStarted();

            

Reported by PMD.

The class 'ServiceManagerTest' has a Standard Cyclomatic Complexity of 3 (Highest = 12).
Design

Line: 53

               * @author Luke Sandberg
 * @author Chris Nokleberg
 */
public class ServiceManagerTest extends TestCase {

  private static class NoOpService extends AbstractService {
    @Override
    protected void doStart() {
      notifyStarted();

            

Reported by PMD.

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

Line: 72

                 * of time.
   */
  private static class NoOpDelayedService extends NoOpService {
    private long delay;

    public NoOpDelayedService(long delay) {
      this.delay = delay;
    }


            

Reported by PMD.

Private field 'delay' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 72

                 * of time.
   */
  private static class NoOpDelayedService extends NoOpService {
    private long delay;

    public NoOpDelayedService(long delay) {
      this.delay = delay;
    }


            

Reported by PMD.

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

Line: 124

                }


  public void testServiceStartupTimes() {
    Service a = new NoOpDelayedService(150);
    Service b = new NoOpDelayedService(353);
    ServiceManager serviceManager = new ServiceManager(asList(a, b));
    serviceManager.startAsync().awaitHealthy();
    ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();

            

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

                }


  public void testServiceStartupTimes() {
    Service a = new NoOpDelayedService(150);
    Service b = new NoOpDelayedService(353);
    ServiceManager serviceManager = new ServiceManager(asList(a, b));
    serviceManager.startAsync().awaitHealthy();
    ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();

            

Reported by PMD.

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

Line: 128

                  Service a = new NoOpDelayedService(150);
    Service b = new NoOpDelayedService(353);
    ServiceManager serviceManager = new ServiceManager(asList(a, b));
    serviceManager.startAsync().awaitHealthy();
    ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();
    assertThat(startupTimes).hasSize(2);
    assertThat(startupTimes.get(a)).isAtLeast(150);
    assertThat(startupTimes.get(b)).isAtLeast(353);
  }

            

Reported by PMD.

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

Line: 130

                  ServiceManager serviceManager = new ServiceManager(asList(a, b));
    serviceManager.startAsync().awaitHealthy();
    ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();
    assertThat(startupTimes).hasSize(2);
    assertThat(startupTimes.get(a)).isAtLeast(150);
    assertThat(startupTimes.get(b)).isAtLeast(353);
  }



            

Reported by PMD.

android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java
167 issues
This class has too many methods, consider refactoring it.
Design

Line: 32

              /**
 * Abstract base class for testing undirected {@link Graph} implementations defined in this package.
 */
public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphTest {

  @After
  public void validateUndirectedEdges() {
    for (Integer node : graph.nodes()) {
      new EqualsTester()

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 37

                @After
  public void validateUndirectedEdges() {
    for (Integer node : graph.nodes()) {
      new EqualsTester()
          .addEqualityGroup(
              graph.predecessors(node), graph.successors(node), graph.adjacentNodes(node))
          .testEquals();
    }
  }

            

Reported by PMD.

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

Line: 47

                @Override
  @Test
  public void nodes_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    Set<Integer> nodes = graph.nodes();
    try {
      nodes.add(N2);
      fail(ERROR_MODIFIABLE_SET);

            

Reported by PMD.

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

Line: 47

                @Override
  @Test
  public void nodes_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    Set<Integer> nodes = graph.nodes();
    try {
      nodes.add(N2);
      fail(ERROR_MODIFIABLE_SET);

            

Reported by PMD.

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

Line: 55

                    fail(ERROR_MODIFIABLE_SET);
    } catch (UnsupportedOperationException e) {
      addNode(N1);
      assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
    }
  }

  @Override
  @Test

            

Reported by PMD.

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

Line: 62

                @Override
  @Test
  public void adjacentNodes_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    addNode(N1);
    Set<Integer> adjacentNodes = graph.adjacentNodes(N1);
    try {
      adjacentNodes.add(N2);

            

Reported by PMD.

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

Line: 62

                @Override
  @Test
  public void adjacentNodes_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    addNode(N1);
    Set<Integer> adjacentNodes = graph.adjacentNodes(N1);
    try {
      adjacentNodes.add(N2);

            

Reported by PMD.

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

Line: 71

                    fail(ERROR_MODIFIABLE_SET);
    } catch (UnsupportedOperationException e) {
      putEdge(N1, N2);
      assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
    }
  }

  @Override
  @Test

            

Reported by PMD.

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

Line: 78

                @Override
  @Test
  public void predecessors_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    addNode(N2);
    Set<Integer> predecessors = graph.predecessors(N2);
    try {
      predecessors.add(N1);

            

Reported by PMD.

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

Line: 78

                @Override
  @Test
  public void predecessors_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    addNode(N2);
    Set<Integer> predecessors = graph.predecessors(N2);
    try {
      predecessors.add(N1);

            

Reported by PMD.

guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java
167 issues
This class has too many methods, consider refactoring it.
Design

Line: 32

              /**
 * Abstract base class for testing undirected {@link Graph} implementations defined in this package.
 */
public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphTest {

  @After
  public void validateUndirectedEdges() {
    for (Integer node : graph.nodes()) {
      new EqualsTester()

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 37

                @After
  public void validateUndirectedEdges() {
    for (Integer node : graph.nodes()) {
      new EqualsTester()
          .addEqualityGroup(
              graph.predecessors(node), graph.successors(node), graph.adjacentNodes(node))
          .testEquals();
    }
  }

            

Reported by PMD.

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

Line: 47

                @Override
  @Test
  public void nodes_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    Set<Integer> nodes = graph.nodes();
    try {
      nodes.add(N2);
      fail(ERROR_MODIFIABLE_SET);

            

Reported by PMD.

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

Line: 47

                @Override
  @Test
  public void nodes_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    Set<Integer> nodes = graph.nodes();
    try {
      nodes.add(N2);
      fail(ERROR_MODIFIABLE_SET);

            

Reported by PMD.

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

Line: 55

                    fail(ERROR_MODIFIABLE_SET);
    } catch (UnsupportedOperationException e) {
      addNode(N1);
      assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
    }
  }

  @Override
  @Test

            

Reported by PMD.

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

Line: 62

                @Override
  @Test
  public void adjacentNodes_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    addNode(N1);
    Set<Integer> adjacentNodes = graph.adjacentNodes(N1);
    try {
      adjacentNodes.add(N2);

            

Reported by PMD.

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

Line: 62

                @Override
  @Test
  public void adjacentNodes_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    addNode(N1);
    Set<Integer> adjacentNodes = graph.adjacentNodes(N1);
    try {
      adjacentNodes.add(N2);

            

Reported by PMD.

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

Line: 71

                    fail(ERROR_MODIFIABLE_SET);
    } catch (UnsupportedOperationException e) {
      putEdge(N1, N2);
      assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
    }
  }

  @Override
  @Test

            

Reported by PMD.

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

Line: 78

                @Override
  @Test
  public void predecessors_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    addNode(N2);
    Set<Integer> predecessors = graph.predecessors(N2);
    try {
      predecessors.add(N1);

            

Reported by PMD.

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

Line: 78

                @Override
  @Test
  public void predecessors_checkReturnedSetMutability() {
    assume().that(graphIsMutable()).isTrue();

    addNode(N2);
    Set<Integer> predecessors = graph.predecessors(N2);
    try {
      predecessors.add(N1);

            

Reported by PMD.

guava-tests/test/com/google/common/cache/EmptyCachesTest.java
167 issues
Avoid using equals() to compare against null
Error

Line: 75

              
  public void testEquals_null() {
    for (LoadingCache<Object, Object> cache : caches()) {
      assertFalse(cache.equals(null));
    }
  }

  public void testEqualsAndHashCode_different() {
    for (CacheBuilder<Object, Object> builder : cacheFactory().buildAllPermutations()) {

            

Reported by PMD.

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

Line: 42

               * @author mike nonemacher
 */

public class EmptyCachesTest extends TestCase {

  public void testEmpty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      checkEmpty(cache);
    }

            

Reported by PMD.

Possible God Class (WMC=60, ATFD=16, TCC=0.000%)
Design

Line: 42

               * @author mike nonemacher
 */

public class EmptyCachesTest extends TestCase {

  public void testEmpty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      checkEmpty(cache);
    }

            

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

              
public class EmptyCachesTest extends TestCase {

  public void testEmpty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      checkEmpty(cache);
    }
  }


            

Reported by PMD.

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

Line: 44

              
public class EmptyCachesTest extends TestCase {

  public void testEmpty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      checkEmpty(cache);
    }
  }


            

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

                }


  public void testInvalidate_empty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      cache.getUnchecked("a");
      cache.getUnchecked("b");
      cache.invalidate("a");
      cache.invalidate("b");

            

Reported by PMD.

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

Line: 51

                }


  public void testInvalidate_empty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      cache.getUnchecked("a");
      cache.getUnchecked("b");
      cache.invalidate("a");
      cache.invalidate("b");

            

Reported by PMD.

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

Line: 62

                  }
  }

  public void testInvalidateAll_empty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      cache.getUnchecked("a");
      cache.getUnchecked("b");
      cache.getUnchecked("c");
      cache.invalidateAll();

            

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

                  }
  }

  public void testInvalidateAll_empty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      cache.getUnchecked("a");
      cache.getUnchecked("b");
      cache.getUnchecked("c");
      cache.invalidateAll();

            

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

                }


  public void testEquals_null() {
    for (LoadingCache<Object, Object> cache : caches()) {
      assertFalse(cache.equals(null));
    }
  }


            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
167 issues
Avoid using equals() to compare against null
Error

Line: 75

              
  public void testEquals_null() {
    for (LoadingCache<Object, Object> cache : caches()) {
      assertFalse(cache.equals(null));
    }
  }

  public void testEqualsAndHashCode_different() {
    for (CacheBuilder<Object, Object> builder : cacheFactory().buildAllPermutations()) {

            

Reported by PMD.

Possible God Class (WMC=60, ATFD=16, TCC=0.000%)
Design

Line: 42

               * @author mike nonemacher
 */

public class EmptyCachesTest extends TestCase {

  public void testEmpty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      checkEmpty(cache);
    }

            

Reported by PMD.

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

Line: 42

               * @author mike nonemacher
 */

public class EmptyCachesTest extends TestCase {

  public void testEmpty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      checkEmpty(cache);
    }

            

Reported by PMD.

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

Line: 44

              
public class EmptyCachesTest extends TestCase {

  public void testEmpty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      checkEmpty(cache);
    }
  }


            

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

              
public class EmptyCachesTest extends TestCase {

  public void testEmpty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      checkEmpty(cache);
    }
  }


            

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

                }


  public void testInvalidate_empty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      cache.getUnchecked("a");
      cache.getUnchecked("b");
      cache.invalidate("a");
      cache.invalidate("b");

            

Reported by PMD.

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

Line: 51

                }


  public void testInvalidate_empty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      cache.getUnchecked("a");
      cache.getUnchecked("b");
      cache.invalidate("a");
      cache.invalidate("b");

            

Reported by PMD.

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

Line: 62

                  }
  }

  public void testInvalidateAll_empty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      cache.getUnchecked("a");
      cache.getUnchecked("b");
      cache.getUnchecked("c");
      cache.invalidateAll();

            

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

                  }
  }

  public void testInvalidateAll_empty() {
    for (LoadingCache<Object, Object> cache : caches()) {
      cache.getUnchecked("a");
      cache.getUnchecked("b");
      cache.getUnchecked("c");
      cache.invalidateAll();

            

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

                }


  public void testEquals_null() {
    for (LoadingCache<Object, Object> cache : caches()) {
      assertFalse(cache.equals(null));
    }
  }


            

Reported by PMD.