The following issues were found

android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
250 issues
Avoid throwing raw exception types.
Design

Line: 229

                      new AbstractScheduledService() {
          @Override
          protected void startUp() throws Exception {
            throw new Exception("Failed");
          }

          @Override
          protected void runOneIteration() throws Exception {}


            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 515

                                secondBarrier.await();
                }
              } catch (Exception e) {
                throw new RuntimeException(e);
              }
            }
          };
      TestCustomScheduler scheduler = new TestCustomScheduler();
      Cancellable future = scheduler.schedule(null, Executors.newScheduledThreadPool(10), task);

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 563

                                  if (state() != State.STARTING) {
                      inGetNextSchedule.await();
                      Thread.yield();
                      throw new RuntimeException("boom");
                    }
                    return new Schedule(0, TimeUnit.NANOSECONDS);
                  }
                };
              }

            

Reported by PMD.

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

Line: 51

               * @author Luke Sandberg
 */

public class AbstractScheduledServiceTest extends TestCase {

  volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;

            

Reported by PMD.

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

Line: 53

              
public class AbstractScheduledServiceTest extends TestCase {

  volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;

            

Reported by PMD.

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

Line: 54

              public class AbstractScheduledServiceTest extends TestCase {

  volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;


            

Reported by PMD.

Avoid using redundant field initializer for 'future'
Performance

Line: 54

              public class AbstractScheduledServiceTest extends TestCase {

  volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;


            

Reported by PMD.

Avoid using redundant field initializer for 'atFixedRateCalled'
Performance

Line: 56

                volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;

  final ScheduledExecutorService executor =
      new ScheduledThreadPoolExecutor(10) {

            

Reported by PMD.

Avoid using redundant field initializer for 'withFixedDelayCalled'
Performance

Line: 57

                volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;

  final ScheduledExecutorService executor =
      new ScheduledThreadPoolExecutor(10) {
        @Override

            

Reported by PMD.

Avoid using redundant field initializer for 'scheduleCalled'
Performance

Line: 58

              
  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;

  final ScheduledExecutorService executor =
      new ScheduledThreadPoolExecutor(10) {
        @Override
        public ScheduledFuture<?> scheduleWithFixedDelay(

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
250 issues
Avoid throwing raw exception types.
Design

Line: 229

                      new AbstractScheduledService() {
          @Override
          protected void startUp() throws Exception {
            throw new Exception("Failed");
          }

          @Override
          protected void runOneIteration() throws Exception {}


            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 515

                                secondBarrier.await();
                }
              } catch (Exception e) {
                throw new RuntimeException(e);
              }
            }
          };
      TestCustomScheduler scheduler = new TestCustomScheduler();
      Cancellable future = scheduler.schedule(null, Executors.newScheduledThreadPool(10), task);

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 563

                                  if (state() != State.STARTING) {
                      inGetNextSchedule.await();
                      Thread.yield();
                      throw new RuntimeException("boom");
                    }
                    return new Schedule(0, TimeUnit.NANOSECONDS);
                  }
                };
              }

            

Reported by PMD.

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

Line: 51

               * @author Luke Sandberg
 */

public class AbstractScheduledServiceTest extends TestCase {

  volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;

            

Reported by PMD.

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

Line: 53

              
public class AbstractScheduledServiceTest extends TestCase {

  volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;

            

Reported by PMD.

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

Line: 54

              public class AbstractScheduledServiceTest extends TestCase {

  volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;


            

Reported by PMD.

Avoid using redundant field initializer for 'future'
Performance

Line: 54

              public class AbstractScheduledServiceTest extends TestCase {

  volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;


            

Reported by PMD.

Avoid using redundant field initializer for 'atFixedRateCalled'
Performance

Line: 56

                volatile Scheduler configuration = newFixedDelaySchedule(0, 10, TimeUnit.MILLISECONDS);
  volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;

  final ScheduledExecutorService executor =
      new ScheduledThreadPoolExecutor(10) {

            

Reported by PMD.

Avoid using redundant field initializer for 'withFixedDelayCalled'
Performance

Line: 57

                volatile ScheduledFuture<?> future = null;

  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;

  final ScheduledExecutorService executor =
      new ScheduledThreadPoolExecutor(10) {
        @Override

            

Reported by PMD.

Avoid using redundant field initializer for 'scheduleCalled'
Performance

Line: 58

              
  volatile boolean atFixedRateCalled = false;
  volatile boolean withFixedDelayCalled = false;
  volatile boolean scheduleCalled = false;

  final ScheduledExecutorService executor =
      new ScheduledThreadPoolExecutor(10) {
        @Override
        public ScheduledFuture<?> scheduleWithFixedDelay(

            

Reported by PMD.

guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
248 issues
Avoid throwing raw exception types.
Design

Line: 199

              
  private static class ThrowsSomethingElse {
    public static void christenPoodle(String name) {
      throw new RuntimeException();
    }
  }

  private interface InterfaceStaticMethodFailsToCheckNull {
    static String create(String s) {

            

Reported by PMD.

Avoid throwing null pointer exceptions.
Design

Line: 360

                    THROW_A_NPE {
        @Override
        public void act() {
          throw new NullPointerException();
        }
      },
      THROW_OTHER {
        @Override
        public void act() {

            

Reported by PMD.

The method name and parameter number are suspiciously close to equals(Object)
Error

Line: 1453

                }

  static class DoesNotOverrideEquals {
    public boolean equals(Object a, Object b) {
      return true;
    }
  }

  public void testEqualsMethod() {

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;


            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;


            

Reported by PMD.

The class 'NullPointerTesterTest' has a total cyclomatic complexity of 109 (highest 5).
Design

Line: 58

               * @author Mick Killianey
 */
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {

  /** Non-NPE RuntimeException. */
  public static class FooException extends RuntimeException {
    private static final long serialVersionUID = 1L;
  }

            

Reported by PMD.

Possible God Class (WMC=109, ATFD=51, TCC=0.000%)
Design

Line: 58

               * @author Mick Killianey
 */
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {

  /** Non-NPE RuntimeException. */
  public static class FooException extends RuntimeException {
    private static final long serialVersionUID = 1L;
  }

            

Reported by PMD.

Avoid really long classes.
Design

Line: 58

               * @author Mick Killianey
 */
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {

  /** Non-NPE RuntimeException. */
  public static class FooException extends RuntimeException {
    private static final long serialVersionUID = 1L;
  }

            

Reported by PMD.

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

Line: 58

               * @author Mick Killianey
 */
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {

  /** Non-NPE RuntimeException. */
  public static class FooException extends RuntimeException {
    private static final long serialVersionUID = 1L;
  }

            

Reported by PMD.

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

Line: 69

                 * Class for testing all permutations of static/non-static one-argument methods using
   * methodParameter().
   */
  @SuppressWarnings("unused") // used by reflection
  public static class OneArg {

    public static void staticOneArgCorrectlyThrowsNpe(String s) {
      checkNotNull(s); // expect NPE here on null
    }

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
246 issues
Avoid throwing raw exception types.
Design

Line: 576

                          int behavior = random.nextInt(4);
            if (behavior == 0) { // throw an exception
              exceptionCount.incrementAndGet();
              throw new RuntimeException("fake exception for test");
            } else if (behavior == 1) { // return null
              computeNullCount.incrementAndGet();
              return null;
            } else if (behavior == 2) { // slight delay before returning
              Thread.sleep(5);

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.cache;

import static com.google.common.cache.TestingCacheLoaders.constantLoader;
import static com.google.common.cache.TestingCacheLoaders.identityLoader;
import static com.google.common.cache.TestingRemovalListeners.countingRemovalListener;
import static com.google.common.cache.TestingRemovalListeners.nullRemovalListener;

            

Reported by PMD.

The class 'CacheBuilderTest' has a Modified Cyclomatic Complexity of 2 (Highest = 10).
Design

Line: 51

              
/** Unit tests for CacheBuilder. */
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {

  public void testNewBuilder() {
    CacheLoader<Object, Integer> loader = constantLoader(1);

    LoadingCache<String, Integer> cache =

            

Reported by PMD.

Possible God Class (WMC=73, ATFD=35, TCC=0.000%)
Design

Line: 51

              
/** Unit tests for CacheBuilder. */
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {

  public void testNewBuilder() {
    CacheLoader<Object, Integer> loader = constantLoader(1);

    LoadingCache<String, Integer> cache =

            

Reported by PMD.

The class 'CacheBuilderTest' has a Standard Cyclomatic Complexity of 2 (Highest = 10).
Design

Line: 51

              
/** Unit tests for CacheBuilder. */
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {

  public void testNewBuilder() {
    CacheLoader<Object, Integer> loader = constantLoader(1);

    LoadingCache<String, Integer> cache =

            

Reported by PMD.

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

Line: 51

              
/** Unit tests for CacheBuilder. */
@GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {

  public void testNewBuilder() {
    CacheLoader<Object, Integer> loader = constantLoader(1);

    LoadingCache<String, Integer> 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: 53

              @GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {

  public void testNewBuilder() {
    CacheLoader<Object, Integer> loader = constantLoader(1);

    LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);


            

Reported by PMD.

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

Line: 53

              @GwtCompatible(emulated = true)
public class CacheBuilderTest extends TestCase {

  public void testNewBuilder() {
    CacheLoader<Object, Integer> loader = constantLoader(1);

    LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 59

                  LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);

    assertEquals(Integer.valueOf(1), cache.getUnchecked("one"));
    assertEquals(1, cache.size());
  }

  public void testInitialCapacity_negative() {
    CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();

            

Reported by PMD.

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

Line: 59

                  LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);

    assertEquals(Integer.valueOf(1), cache.getUnchecked("one"));
    assertEquals(1, cache.size());
  }

  public void testInitialCapacity_negative() {
    CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
243 issues
Possible God Class (WMC=65, ATFD=42, TCC=12.562%)
Design

Line: 41

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

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

Line: 41

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

The class 'TreeRangeMapTest' has a Standard Cyclomatic Complexity of 4 (Highest = 29).
Design

Line: 41

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

The class 'TreeRangeMapTest' has a Modified Cyclomatic Complexity of 4 (Highest = 29).
Design

Line: 41

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

Avoid really long methods.
Design

Line: 42

               */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(
                new TestMapGenerator<Range<Integer>, String>() {

            

Reported by PMD.

The method 'suite' has a Standard Cyclomatic Complexity of 29.
Design

Line: 42

               */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(
                new TestMapGenerator<Range<Integer>, String>() {

            

Reported by PMD.

The method 'suite' has a Modified Cyclomatic Complexity of 29.
Design

Line: 42

               */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(
                new TestMapGenerator<Range<Integer>, String>() {

            

Reported by PMD.

JUnit 4 indicates test suites via annotations, not the suite method.
Design

Line: 42

               */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(
                new TestMapGenerator<Range<Integer>, String>() {

            

Reported by PMD.

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

Line: 51

                                @Override
                  public SampleElements<Entry<Range<Integer>, String>> samples() {
                    return new SampleElements<>(
                        mapEntry(Range.singleton(0), "banana"),
                        mapEntry(Range.closedOpen(3, 5), "frisbee"),
                        mapEntry(Range.atMost(-1), "fruitcake"),
                        mapEntry(Range.open(10, 15), "elephant"),
                        mapEntry(Range.closed(20, 22), "umbrella"));
                  }

            

Reported by PMD.

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

Line: 52

                                public SampleElements<Entry<Range<Integer>, String>> samples() {
                    return new SampleElements<>(
                        mapEntry(Range.singleton(0), "banana"),
                        mapEntry(Range.closedOpen(3, 5), "frisbee"),
                        mapEntry(Range.atMost(-1), "fruitcake"),
                        mapEntry(Range.open(10, 15), "elephant"),
                        mapEntry(Range.closed(20, 22), "umbrella"));
                  }


            

Reported by PMD.

guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
243 issues
Avoid throwing raw exception types.
Design

Line: 751

                  // keep trying
    @SuppressWarnings("unused")
    static GoodEquals create(int a, int b) {
      throw new RuntimeException();
    }

    // Good!
    static GoodEquals create(String a, int b) {
      return new GoodEquals(a, b);

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 1316

              
  static class ConstructorThrows {
    public ConstructorThrows() {
      throw new RuntimeException();
    }
  }

  static class FactoryMethodThrows {
    private FactoryMethodThrows() {}

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 1324

                  private FactoryMethodThrows() {}

    public static FactoryMethodThrows create() {
      throw new RuntimeException();
    }
  }

  static class NotInstantiable {
    private NotInstantiable() {}

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Functions;

            

Reported by PMD.

High amount of different objects as members denotes a high coupling
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Functions;

            

Reported by PMD.

The class 'ClassSanityTesterTest' has a total cyclomatic complexity of 102 (highest 2).
Design

Line: 48

               *
 * @author Ben Yu
 */
public class ClassSanityTesterTest extends TestCase {

  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();

            

Reported by PMD.

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

Line: 48

               *
 * @author Ben Yu
 */
public class ClassSanityTesterTest extends TestCase {

  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();

            

Reported by PMD.

Avoid really long classes.
Design

Line: 48

               *
 * @author Ben Yu
 */
public class ClassSanityTesterTest extends TestCase {

  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();

            

Reported by PMD.

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

Line: 50

               */
public class ClassSanityTesterTest extends TestCase {

  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
  }


            

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

              
  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
  }

  public static class GoodEqualsFactory {
    public static Object good(

            

Reported by PMD.

android/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java
243 issues
Possible God Class (WMC=47, ATFD=25, TCC=0.000%)
Design

Line: 45

              
/** @author Kevin Bourrillion */
@GwtCompatible(emulated = true)
public class ImmutableDoubleArrayTest extends TestCase {
  // Test all creation paths very lazily: by assuming asList() works

  public void testOf0() {
    assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
  }

            

Reported by PMD.

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

Line: 45

              
/** @author Kevin Bourrillion */
@GwtCompatible(emulated = true)
public class ImmutableDoubleArrayTest extends TestCase {
  // Test all creation paths very lazily: by assuming asList() works

  public void testOf0() {
    assertThat(ImmutableDoubleArray.of().asList()).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: 48

              public class ImmutableDoubleArrayTest extends TestCase {
  // Test all creation paths very lazily: by assuming asList() works

  public void testOf0() {
    assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
  }

  public void testOf1() {
    assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);

            

Reported by PMD.

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

Line: 49

                // Test all creation paths very lazily: by assuming asList() works

  public void testOf0() {
    assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
  }

  public void testOf1() {
    assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
  }

            

Reported by PMD.

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

Line: 49

                // Test all creation paths very lazily: by assuming asList() works

  public void testOf0() {
    assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
  }

  public void testOf1() {
    assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
  }

            

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

                  assertThat(ImmutableDoubleArray.of().asList()).isEmpty();
  }

  public void testOf1() {
    assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
  }

  public void testOf2() {
    assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();

            

Reported by PMD.

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

Line: 53

                }

  public void testOf1() {
    assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
  }

  public void testOf2() {
    assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
  }

            

Reported by PMD.

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

Line: 53

                }

  public void testOf1() {
    assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
  }

  public void testOf2() {
    assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
  }

            

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(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
  }

  public void testOf2() {
    assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
  }

  public void testOf3() {
    assertThat(ImmutableDoubleArray.of(0, 1, 3).asList()).containsExactly(0.0, 1.0, 3.0).inOrder();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 57

                }

  public void testOf2() {
    assertThat(ImmutableDoubleArray.of(0, 1).asList()).containsExactly(0.0, 1.0).inOrder();
  }

  public void testOf3() {
    assertThat(ImmutableDoubleArray.of(0, 1, 3).asList()).containsExactly(0.0, 1.0, 3.0).inOrder();
  }

            

Reported by PMD.

android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
241 issues
Avoid throwing raw exception types.
Design

Line: 198

              
  private static class ThrowsSomethingElse {
    public static void christenPoodle(String name) {
      throw new RuntimeException();
    }
  }

  public void testDontAcceptIae() {
    NullPointerTester tester = new NullPointerTester();

            

Reported by PMD.

Avoid throwing null pointer exceptions.
Design

Line: 307

                    THROW_A_NPE {
        @Override
        public void act() {
          throw new NullPointerException();
        }
      },
      THROW_OTHER {
        @Override
        public void act() {

            

Reported by PMD.

The method name and parameter number are suspiciously close to equals(Object)
Error

Line: 1400

                }

  static class DoesNotOverrideEquals {
    public boolean equals(Object a, Object b) {
      return true;
    }
  }

  public void testEqualsMethod() {

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;


            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;


            

Reported by PMD.

Avoid really long classes.
Design

Line: 58

               * @author Mick Killianey
 */
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {

  /** Non-NPE RuntimeException. */
  public static class FooException extends RuntimeException {
    private static final long serialVersionUID = 1L;
  }

            

Reported by PMD.

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

Line: 58

               * @author Mick Killianey
 */
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {

  /** Non-NPE RuntimeException. */
  public static class FooException extends RuntimeException {
    private static final long serialVersionUID = 1L;
  }

            

Reported by PMD.

The class 'NullPointerTesterTest' has a total cyclomatic complexity of 104 (highest 5).
Design

Line: 58

               * @author Mick Killianey
 */
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {

  /** Non-NPE RuntimeException. */
  public static class FooException extends RuntimeException {
    private static final long serialVersionUID = 1L;
  }

            

Reported by PMD.

Possible God Class (WMC=104, ATFD=48, TCC=0.000%)
Design

Line: 58

               * @author Mick Killianey
 */
@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {

  /** Non-NPE RuntimeException. */
  public static class FooException extends RuntimeException {
    private static final long serialVersionUID = 1L;
  }

            

Reported by PMD.

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

Line: 69

                 * Class for testing all permutations of static/non-static one-argument methods using
   * methodParameter().
   */
  @SuppressWarnings("unused") // used by reflection
  public static class OneArg {

    public static void staticOneArgCorrectlyThrowsNpe(String s) {
      checkNotNull(s); // expect NPE here on null
    }

            

Reported by PMD.

android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
240 issues
Avoid throwing raw exception types.
Design

Line: 746

                  // keep trying
    @SuppressWarnings("unused")
    static GoodEquals create(int a, int b) {
      throw new RuntimeException();
    }

    // Good!
    static GoodEquals create(String a, int b) {
      return new GoodEquals(a, b);

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 1303

              
  static class ConstructorThrows {
    public ConstructorThrows() {
      throw new RuntimeException();
    }
  }

  static class FactoryMethodThrows {
    private FactoryMethodThrows() {}

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 1311

                  private FactoryMethodThrows() {}

    public static FactoryMethodThrows create() {
      throw new RuntimeException();
    }
  }

  static class NotInstantiable {
    private NotInstantiable() {}

            

Reported by PMD.

High amount of different objects as members denotes a high coupling
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Functions;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Functions;

            

Reported by PMD.

The class 'ClassSanityTesterTest' has a total cyclomatic complexity of 101 (highest 2).
Design

Line: 46

               *
 * @author Ben Yu
 */
public class ClassSanityTesterTest extends TestCase {

  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();

            

Reported by PMD.

Avoid really long classes.
Design

Line: 46

               *
 * @author Ben Yu
 */
public class ClassSanityTesterTest extends TestCase {

  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();

            

Reported by PMD.

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

Line: 46

               *
 * @author Ben Yu
 */
public class ClassSanityTesterTest extends TestCase {

  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();

            

Reported by PMD.

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

Line: 48

               */
public class ClassSanityTesterTest extends TestCase {

  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
  }


            

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

              
  private final ClassSanityTester tester = new ClassSanityTester();

  public void testEqualsOnReturnValues_good() throws Exception {
    tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
  }

  public static class GoodEqualsFactory {
    public static Object good(

            

Reported by PMD.

android/guava-tests/test/com/google/common/primitives/BooleansTest.java
239 issues
Avoid using equals() to compare against null
Error

Line: 296

                  assertEquals(Booleans.asList(EMPTY), Collections.emptyList());
    assertEquals(Booleans.asList(ARRAY_FALSE), Booleans.asList(ARRAY_FALSE));
    assertFalse(Booleans.asList(ARRAY_FALSE).equals(ARRAY_FALSE));
    assertFalse(Booleans.asList(ARRAY_FALSE).equals(null));
    assertFalse(Booleans.asList(ARRAY_FALSE).equals(Booleans.asList(ARRAY_FALSE_TRUE)));
    assertFalse(Booleans.asList(ARRAY_FALSE_FALSE).equals(Booleans.asList(ARRAY_FALSE_TRUE)));
    assertEquals(1, Booleans.asList(ARRAY_FALSE_TRUE).lastIndexOf(true));
    List<Boolean> reference = Booleans.asList(ARRAY_FALSE);
    assertEquals(Booleans.asList(ARRAY_FALSE), reference);

            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 189

                  testReverse(new boolean[] {true, true, false, false}, new boolean[] {false, false, true, true});
  }

  private static void testReverse(boolean[] input, boolean[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    Booleans.reverse(input);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 196

                }

  private static void testReverse(
      boolean[] input, int fromIndex, int toIndex, boolean[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    Booleans.reverse(input, fromIndex, toIndex);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

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

Line: 37

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class BooleansTest extends TestCase {
  private static final boolean[] EMPTY = {};
  private static final boolean[] ARRAY_FALSE = {false};
  private static final boolean[] ARRAY_TRUE = {true};
  private static final boolean[] ARRAY_FALSE_FALSE = {false, false};
  private static final boolean[] ARRAY_FALSE_TRUE = {false, 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: 46

              
  private static final boolean[] VALUES = {false, true};

  public void testHashCode() {
    assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
    assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
  }

  public void testTrueFirst() {

            

Reported by PMD.

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

Line: 46

              
  private static final boolean[] VALUES = {false, true};

  public void testHashCode() {
    assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
    assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
  }

  public void testTrueFirst() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

                private static final boolean[] VALUES = {false, true};

  public void testHashCode() {
    assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
    assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
  }

  public void testTrueFirst() {
    assertEquals(0, Booleans.trueFirst().compare(true, true));

            

Reported by PMD.

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

Line: 47

                private static final boolean[] VALUES = {false, true};

  public void testHashCode() {
    assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
    assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
  }

  public void testTrueFirst() {
    assertEquals(0, Booleans.trueFirst().compare(true, true));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 48

              
  public void testHashCode() {
    assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
    assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
  }

  public void testTrueFirst() {
    assertEquals(0, Booleans.trueFirst().compare(true, true));
    assertEquals(0, Booleans.trueFirst().compare(false, false));

            

Reported by PMD.

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

Line: 48

              
  public void testHashCode() {
    assertEquals(Boolean.TRUE.hashCode(), Booleans.hashCode(true));
    assertEquals(Boolean.FALSE.hashCode(), Booleans.hashCode(false));
  }

  public void testTrueFirst() {
    assertEquals(0, Booleans.trueFirst().compare(true, true));
    assertEquals(0, Booleans.trueFirst().compare(false, false));

            

Reported by PMD.