The following issues were found

guava-tests/test/com/google/common/math/StatsTesting.java
110 issues
This class has too many methods, consider refactoring it.
Design

Line: 42

               *
 * @author Pete Gillin
 */
class StatsTesting {

  static final double ALLOWED_ERROR = 1e-10;

  // Inputs and their statistics:


            

Reported by PMD.

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

Line: 77

                 */
  static class ManyValues {

    private final ImmutableList<Double> values;

    ManyValues(double[] values) {
      this.values = ImmutableList.copyOf(Doubles.asList(values));
    }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 123

                        values[3] = 555.555;
          for (double fifth : ImmutableList.of(-2.2, POSITIVE_INFINITY, NEGATIVE_INFINITY, NaN)) {
            values[4] = fifth;
            builder.add(new ManyValues(values));
          }
        }
      }
      return builder.build();
    }

            

Reported by PMD.

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

Line: 221

                 * supplier and accumulator.
   */
  static DoubleStream megaPrimitiveDoubleStream() {
    return DoubleStream.iterate(0.0, x -> x + 1.0).limit(MEGA_STREAM_COUNT).parallel();
  }

  /** Returns a stream containing half the values from {@link #megaPrimitiveDoubleStream}. */
  static DoubleStream megaPrimitiveDoubleStreamPart1() {
    return DoubleStream.iterate(0.0, x -> x + 2.0).limit(MEGA_STREAM_COUNT / 2).parallel();

            

Reported by PMD.

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

Line: 221

                 * supplier and accumulator.
   */
  static DoubleStream megaPrimitiveDoubleStream() {
    return DoubleStream.iterate(0.0, x -> x + 1.0).limit(MEGA_STREAM_COUNT).parallel();
  }

  /** Returns a stream containing half the values from {@link #megaPrimitiveDoubleStream}. */
  static DoubleStream megaPrimitiveDoubleStreamPart1() {
    return DoubleStream.iterate(0.0, x -> x + 2.0).limit(MEGA_STREAM_COUNT / 2).parallel();

            

Reported by PMD.

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

Line: 226

              
  /** Returns a stream containing half the values from {@link #megaPrimitiveDoubleStream}. */
  static DoubleStream megaPrimitiveDoubleStreamPart1() {
    return DoubleStream.iterate(0.0, x -> x + 2.0).limit(MEGA_STREAM_COUNT / 2).parallel();
  }

  /**
   * Returns a stream containing the values from {@link #megaPrimitiveDoubleStream} not in {@link
   * #megaPrimitiveDoubleStreamPart1()}.

            

Reported by PMD.

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

Line: 226

              
  /** Returns a stream containing half the values from {@link #megaPrimitiveDoubleStream}. */
  static DoubleStream megaPrimitiveDoubleStreamPart1() {
    return DoubleStream.iterate(0.0, x -> x + 2.0).limit(MEGA_STREAM_COUNT / 2).parallel();
  }

  /**
   * Returns a stream containing the values from {@link #megaPrimitiveDoubleStream} not in {@link
   * #megaPrimitiveDoubleStreamPart1()}.

            

Reported by PMD.

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

Line: 234

                 * #megaPrimitiveDoubleStreamPart1()}.
   */
  static DoubleStream megaPrimitiveDoubleStreamPart2() {
    return DoubleStream.iterate(999_999.0, x -> x - 2.0).limit(MEGA_STREAM_COUNT / 2).parallel();
  }

  static final long MEGA_STREAM_COUNT = 1_000_000;
  static final double MEGA_STREAM_MEAN = 999_999.0 / 2;
  static final double MEGA_STREAM_POPULATION_VARIANCE = 999_999.0 * 1_000_001.0 / 12;

            

Reported by PMD.

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

Line: 234

                 * #megaPrimitiveDoubleStreamPart1()}.
   */
  static DoubleStream megaPrimitiveDoubleStreamPart2() {
    return DoubleStream.iterate(999_999.0, x -> x - 2.0).limit(MEGA_STREAM_COUNT / 2).parallel();
  }

  static final long MEGA_STREAM_COUNT = 1_000_000;
  static final double MEGA_STREAM_MEAN = 999_999.0 / 2;
  static final double MEGA_STREAM_POPULATION_VARIANCE = 999_999.0 * 1_000_001.0 / 12;

            

Reported by PMD.

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

Line: 318

                private static PairedStats buildManyValuesPairedStats() {
    PairedStatsAccumulator accumulator =
        createFilledPairedStatsAccumulator(MANY_VALUES, OTHER_MANY_VALUES);
    PairedStats stats = accumulator.snapshot();
    accumulator.add(99.99, 9999.9999); // should do nothing to the snapshot
    return stats;
  }

  private static PairedStats buildHorizontalValuesPairedStats() {

            

Reported by PMD.

android/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
110 issues
Avoid reassigning parameters such as 'input'
Design

Line: 315

                  testSort(new byte[] {2, GREATEST, 1, LEAST}, new byte[] {LEAST, 1, 2, GREATEST});
  }

  static void testSort(byte[] input, byte[] expected) {
    input = Arrays.copyOf(input, input.length);
    UnsignedBytes.sort(input);
    assertTrue(Arrays.equals(expected, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 321

                  assertTrue(Arrays.equals(expected, input));
  }

  static void testSort(byte[] input, int from, int to, byte[] expected) {
    input = Arrays.copyOf(input, input.length);
    UnsignedBytes.sort(input, from, to);
    assertTrue(Arrays.equals(expected, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 344

                      new byte[] {GREATEST - 1, GREATEST - 2, 2, 1});
  }

  private static void testSortDescending(byte[] input, byte[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    UnsignedBytes.sortDescending(input);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 351

                }

  private static void testSortDescending(
      byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    UnsignedBytes.sortDescending(input, fromIndex, toIndex);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Possible God Class (WMC=54, ATFD=24, TCC=6.250%)
Design

Line: 34

               * @author Kevin Bourrillion
 * @author Louis Wasserman
 */
public class UnsignedBytesTest extends TestCase {
  private static final byte LEAST = 0;
  private static final byte GREATEST = (byte) 255;

  // Only in this class, VALUES must be strictly ascending
  private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

            

Reported by PMD.

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

Line: 34

               * @author Kevin Bourrillion
 * @author Louis Wasserman
 */
public class UnsignedBytesTest extends TestCase {
  private static final byte LEAST = 0;
  private static final byte GREATEST = (byte) 255;

  // Only in this class, VALUES must be strictly ascending
  private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

            

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

                // Only in this class, VALUES must be strictly ascending
  private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

  public void testToInt() {
    assertEquals(0, UnsignedBytes.toInt((byte) 0));
    assertEquals(1, UnsignedBytes.toInt((byte) 1));
    assertEquals(127, UnsignedBytes.toInt((byte) 127));
    assertEquals(128, UnsignedBytes.toInt((byte) -128));
    assertEquals(129, UnsignedBytes.toInt((byte) -127));

            

Reported by PMD.

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

Line: 41

                // Only in this class, VALUES must be strictly ascending
  private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

  public void testToInt() {
    assertEquals(0, UnsignedBytes.toInt((byte) 0));
    assertEquals(1, UnsignedBytes.toInt((byte) 1));
    assertEquals(127, UnsignedBytes.toInt((byte) 127));
    assertEquals(128, UnsignedBytes.toInt((byte) -128));
    assertEquals(129, UnsignedBytes.toInt((byte) -127));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

                private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

  public void testToInt() {
    assertEquals(0, UnsignedBytes.toInt((byte) 0));
    assertEquals(1, UnsignedBytes.toInt((byte) 1));
    assertEquals(127, UnsignedBytes.toInt((byte) 127));
    assertEquals(128, UnsignedBytes.toInt((byte) -128));
    assertEquals(129, UnsignedBytes.toInt((byte) -127));
    assertEquals(255, UnsignedBytes.toInt((byte) -1));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

              
  public void testToInt() {
    assertEquals(0, UnsignedBytes.toInt((byte) 0));
    assertEquals(1, UnsignedBytes.toInt((byte) 1));
    assertEquals(127, UnsignedBytes.toInt((byte) 127));
    assertEquals(128, UnsignedBytes.toInt((byte) -128));
    assertEquals(129, UnsignedBytes.toInt((byte) -127));
    assertEquals(255, UnsignedBytes.toInt((byte) -1));
  }

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
110 issues
Avoid reassigning parameters such as 'input'
Design

Line: 315

                  testSort(new byte[] {2, GREATEST, 1, LEAST}, new byte[] {LEAST, 1, 2, GREATEST});
  }

  static void testSort(byte[] input, byte[] expected) {
    input = Arrays.copyOf(input, input.length);
    UnsignedBytes.sort(input);
    assertTrue(Arrays.equals(expected, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 321

                  assertTrue(Arrays.equals(expected, input));
  }

  static void testSort(byte[] input, int from, int to, byte[] expected) {
    input = Arrays.copyOf(input, input.length);
    UnsignedBytes.sort(input, from, to);
    assertTrue(Arrays.equals(expected, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 344

                      new byte[] {GREATEST - 1, GREATEST - 2, 2, 1});
  }

  private static void testSortDescending(byte[] input, byte[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    UnsignedBytes.sortDescending(input);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 351

                }

  private static void testSortDescending(
      byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    UnsignedBytes.sortDescending(input, fromIndex, toIndex);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Possible God Class (WMC=54, ATFD=24, TCC=6.250%)
Design

Line: 34

               * @author Kevin Bourrillion
 * @author Louis Wasserman
 */
public class UnsignedBytesTest extends TestCase {
  private static final byte LEAST = 0;
  private static final byte GREATEST = (byte) 255;

  // Only in this class, VALUES must be strictly ascending
  private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

            

Reported by PMD.

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

Line: 34

               * @author Kevin Bourrillion
 * @author Louis Wasserman
 */
public class UnsignedBytesTest extends TestCase {
  private static final byte LEAST = 0;
  private static final byte GREATEST = (byte) 255;

  // Only in this class, VALUES must be strictly ascending
  private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

            

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

                // Only in this class, VALUES must be strictly ascending
  private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

  public void testToInt() {
    assertEquals(0, UnsignedBytes.toInt((byte) 0));
    assertEquals(1, UnsignedBytes.toInt((byte) 1));
    assertEquals(127, UnsignedBytes.toInt((byte) 127));
    assertEquals(128, UnsignedBytes.toInt((byte) -128));
    assertEquals(129, UnsignedBytes.toInt((byte) -127));

            

Reported by PMD.

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

Line: 41

                // Only in this class, VALUES must be strictly ascending
  private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

  public void testToInt() {
    assertEquals(0, UnsignedBytes.toInt((byte) 0));
    assertEquals(1, UnsignedBytes.toInt((byte) 1));
    assertEquals(127, UnsignedBytes.toInt((byte) 127));
    assertEquals(128, UnsignedBytes.toInt((byte) -128));
    assertEquals(129, UnsignedBytes.toInt((byte) -127));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

                private static final byte[] VALUES = {LEAST, 127, (byte) 128, (byte) 129, GREATEST};

  public void testToInt() {
    assertEquals(0, UnsignedBytes.toInt((byte) 0));
    assertEquals(1, UnsignedBytes.toInt((byte) 1));
    assertEquals(127, UnsignedBytes.toInt((byte) 127));
    assertEquals(128, UnsignedBytes.toInt((byte) -128));
    assertEquals(129, UnsignedBytes.toInt((byte) -127));
    assertEquals(255, UnsignedBytes.toInt((byte) -1));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

              
  public void testToInt() {
    assertEquals(0, UnsignedBytes.toInt((byte) 0));
    assertEquals(1, UnsignedBytes.toInt((byte) 1));
    assertEquals(127, UnsignedBytes.toInt((byte) 127));
    assertEquals(128, UnsignedBytes.toInt((byte) -128));
    assertEquals(129, UnsignedBytes.toInt((byte) -127));
    assertEquals(255, UnsignedBytes.toInt((byte) -1));
  }

            

Reported by PMD.

guava-tests/test/com/google/common/collect/HashingTest.java
110 issues
Avoid really long methods.
Design

Line: 25

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

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

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

Reported by PMD.

The method 'testSmear()' has a NCSS line count of 106.
Design

Line: 25

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

Reported by PMD.

The method testSmear() has an NCSS line count of 106
Design

Line: 25

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

Reported by PMD.

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

Line: 25

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

              @GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

              public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));
    assertEquals(-1645495900, smear(-723955400));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));
    assertEquals(-1645495900, smear(-723955400));
    assertEquals(766424523, smear(1033096058));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                  assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));
    assertEquals(-1645495900, smear(-723955400));
    assertEquals(766424523, smear(1033096058));
    assertEquals(-757003149, smear(-1690734402));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                  assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));
    assertEquals(-1645495900, smear(-723955400));
    assertEquals(766424523, smear(1033096058));
    assertEquals(-757003149, smear(-1690734402));
    assertEquals(-245078984, smear(-1557280266));

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/CacheStatsTest.java
109 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 28

               */
public class CacheStatsTest extends TestCase {

  public void testEmpty() {
    CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());

            

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

               */
public class CacheStatsTest extends TestCase {

  public void testEmpty() {
    CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

              
  public void testEmpty() {
    CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                public void testEmpty() {
    CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

                  CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                  assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                  assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());
    assertEquals(0, stats.totalLoadTime());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

                  assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());
    assertEquals(0, stats.totalLoadTime());
    assertEquals(0.0, stats.averageLoadPenalty());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

                  assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());
    assertEquals(0, stats.totalLoadTime());
    assertEquals(0.0, stats.averageLoadPenalty());
    assertEquals(0, stats.evictionCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                  assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());
    assertEquals(0, stats.totalLoadTime());
    assertEquals(0.0, stats.averageLoadPenalty());
    assertEquals(0, stats.evictionCount());
  }

            

Reported by PMD.

guava-tests/test/com/google/common/cache/CacheStatsTest.java
109 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: 28

               */
public class CacheStatsTest extends TestCase {

  public void testEmpty() {
    CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());

            

Reported by PMD.

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

Line: 28

               */
public class CacheStatsTest extends TestCase {

  public void testEmpty() {
    CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

              
  public void testEmpty() {
    CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                public void testEmpty() {
    CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

                  CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0);
    assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                  assertEquals(0, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                  assertEquals(0, stats.hitCount());
    assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());
    assertEquals(0, stats.totalLoadTime());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

                  assertEquals(1.0, stats.hitRate());
    assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());
    assertEquals(0, stats.totalLoadTime());
    assertEquals(0.0, stats.averageLoadPenalty());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

                  assertEquals(0, stats.missCount());
    assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());
    assertEquals(0, stats.totalLoadTime());
    assertEquals(0.0, stats.averageLoadPenalty());
    assertEquals(0, stats.evictionCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                  assertEquals(0.0, stats.missRate());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0.0, stats.loadExceptionRate());
    assertEquals(0, stats.loadCount());
    assertEquals(0, stats.totalLoadTime());
    assertEquals(0.0, stats.averageLoadPenalty());
    assertEquals(0, stats.evictionCount());
  }

            

Reported by PMD.

android/guava-testlib/test/com/google/common/testing/FreshValueGeneratorTest.java
108 issues
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 com.google.common.base.CharMatcher;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Joiner;

            

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 com.google.common.base.CharMatcher;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Joiner;

            

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 com.google.common.base.CharMatcher;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Joiner;

            

Reported by PMD.

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

Line: 115

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

  @AndroidIncompatible // problem with equality of Type objects?
  public void testFreshInstance() {
    assertFreshInstances(
        String.class,

            

Reported by PMD.

Possible God Class (WMC=70, ATFD=99, TCC=0.000%)
Design

Line: 115

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

  @AndroidIncompatible // problem with equality of Type objects?
  public void testFreshInstance() {
    assertFreshInstances(
        String.class,

            

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

               */
public class FreshValueGeneratorTest extends TestCase {

  @AndroidIncompatible // problem with equality of Type objects?
  public void testFreshInstance() {
    assertFreshInstances(
        String.class,
        CharSequence.class,
        Appendable.class,

            

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

                      int[].class);
  }

  public void testStringArray() {
    FreshValueGenerator generator = new FreshValueGenerator();
    String[] a1 = generator.generateFresh(String[].class);
    String[] a2 = generator.generateFresh(String[].class);
    assertFalse(a1[0].equals(a2[0]));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 197

                  FreshValueGenerator generator = new FreshValueGenerator();
    String[] a1 = generator.generateFresh(String[].class);
    String[] a2 = generator.generateFresh(String[].class);
    assertFalse(a1[0].equals(a2[0]));
  }

  public void testPrimitiveArray() {
    FreshValueGenerator generator = new FreshValueGenerator();
    int[] a1 = generator.generateFresh(int[].class);

            

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

                  assertFalse(a1[0].equals(a2[0]));
  }

  public void testPrimitiveArray() {
    FreshValueGenerator generator = new FreshValueGenerator();
    int[] a1 = generator.generateFresh(int[].class);
    int[] a2 = generator.generateFresh(int[].class);
    assertTrue(a1[0] != a2[0]);
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 204

                  FreshValueGenerator generator = new FreshValueGenerator();
    int[] a1 = generator.generateFresh(int[].class);
    int[] a2 = generator.generateFresh(int[].class);
    assertTrue(a1[0] != a2[0]);
  }

  public void testRange() {
    assertFreshInstance(new TypeToken<Range<String>>() {});
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
106 issues
This class has too many methods, consider refactoring it.
Design

Line: 34

               * @author Kurt Alfred Kluever
 * @author Martin Buchholz
 */
public class ThreadFactoryBuilderTest extends TestCase {
  private final Runnable monitoredRunnable =
      new Runnable() {
        @Override
        public void run() {
          completed = true;

            

Reported by PMD.

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

Line: 35

               * @author Martin Buchholz
 */
public class ThreadFactoryBuilderTest extends TestCase {
  private final Runnable monitoredRunnable =
      new Runnable() {
        @Override
        public void run() {
          completed = true;
        }

            

Reported by PMD.

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

Line: 51

                      }
      };

  private ThreadFactoryBuilder builder;
  private volatile boolean completed = false;

  @Override
  public void setUp() {
    builder = new ThreadFactoryBuilder();

            

Reported by PMD.

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

Line: 52

                    };

  private ThreadFactoryBuilder builder;
  private volatile boolean completed = false;

  @Override
  public void setUp() {
    builder = new ThreadFactoryBuilder();
  }

            

Reported by PMD.

Avoid using redundant field initializer for 'completed'
Performance

Line: 52

                    };

  private ThreadFactoryBuilder builder;
  private volatile boolean completed = false;

  @Override
  public void setUp() {
    builder = new ThreadFactoryBuilder();
  }

            

Reported by PMD.

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

Line: 54

                private ThreadFactoryBuilder builder;
  private volatile boolean completed = false;

  @Override
  public void setUp() {
    builder = new ThreadFactoryBuilder();
  }



            

Reported by PMD.

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

Line: 60

                }


  public void testThreadFactoryBuilder_defaults() throws InterruptedException {
    ThreadFactory threadFactory = builder.build();
    Thread thread = threadFactory.newThread(monitoredRunnable);
    checkThreadPoolName(thread, 1);

    Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);

            

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

                }


  public void testThreadFactoryBuilder_defaults() throws InterruptedException {
    ThreadFactory threadFactory = builder.build();
    Thread thread = threadFactory.newThread(monitoredRunnable);
    checkThreadPoolName(thread, 1);

    Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);

            

Reported by PMD.

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

Line: 62

              
  public void testThreadFactoryBuilder_defaults() throws InterruptedException {
    ThreadFactory threadFactory = builder.build();
    Thread thread = threadFactory.newThread(monitoredRunnable);
    checkThreadPoolName(thread, 1);

    Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);
    assertEquals(defaultThread.isDaemon(), thread.isDaemon());
    assertEquals(defaultThread.getPriority(), thread.getPriority());

            

Reported by PMD.

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

Line: 65

                  Thread thread = threadFactory.newThread(monitoredRunnable);
    checkThreadPoolName(thread, 1);

    Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);
    assertEquals(defaultThread.isDaemon(), thread.isDaemon());
    assertEquals(defaultThread.getPriority(), thread.getPriority());
    assertSame(defaultThread.getThreadGroup(), thread.getThreadGroup());
    assertSame(defaultThread.getUncaughtExceptionHandler(), thread.getUncaughtExceptionHandler());


            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
106 issues
This class has too many methods, consider refactoring it.
Design

Line: 34

               * @author Kurt Alfred Kluever
 * @author Martin Buchholz
 */
public class ThreadFactoryBuilderTest extends TestCase {
  private final Runnable monitoredRunnable =
      new Runnable() {
        @Override
        public void run() {
          completed = true;

            

Reported by PMD.

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

Line: 35

               * @author Martin Buchholz
 */
public class ThreadFactoryBuilderTest extends TestCase {
  private final Runnable monitoredRunnable =
      new Runnable() {
        @Override
        public void run() {
          completed = true;
        }

            

Reported by PMD.

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

Line: 51

                      }
      };

  private ThreadFactoryBuilder builder;
  private volatile boolean completed = false;

  @Override
  public void setUp() {
    builder = new ThreadFactoryBuilder();

            

Reported by PMD.

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

Line: 52

                    };

  private ThreadFactoryBuilder builder;
  private volatile boolean completed = false;

  @Override
  public void setUp() {
    builder = new ThreadFactoryBuilder();
  }

            

Reported by PMD.

Avoid using redundant field initializer for 'completed'
Performance

Line: 52

                    };

  private ThreadFactoryBuilder builder;
  private volatile boolean completed = false;

  @Override
  public void setUp() {
    builder = new ThreadFactoryBuilder();
  }

            

Reported by PMD.

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

Line: 54

                private ThreadFactoryBuilder builder;
  private volatile boolean completed = false;

  @Override
  public void setUp() {
    builder = new ThreadFactoryBuilder();
  }



            

Reported by PMD.

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

Line: 60

                }


  public void testThreadFactoryBuilder_defaults() throws InterruptedException {
    ThreadFactory threadFactory = builder.build();
    Thread thread = threadFactory.newThread(monitoredRunnable);
    checkThreadPoolName(thread, 1);

    Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);

            

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

                }


  public void testThreadFactoryBuilder_defaults() throws InterruptedException {
    ThreadFactory threadFactory = builder.build();
    Thread thread = threadFactory.newThread(monitoredRunnable);
    checkThreadPoolName(thread, 1);

    Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);

            

Reported by PMD.

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

Line: 62

              
  public void testThreadFactoryBuilder_defaults() throws InterruptedException {
    ThreadFactory threadFactory = builder.build();
    Thread thread = threadFactory.newThread(monitoredRunnable);
    checkThreadPoolName(thread, 1);

    Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);
    assertEquals(defaultThread.isDaemon(), thread.isDaemon());
    assertEquals(defaultThread.getPriority(), thread.getPriority());

            

Reported by PMD.

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

Line: 65

                  Thread thread = threadFactory.newThread(monitoredRunnable);
    checkThreadPoolName(thread, 1);

    Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);
    assertEquals(defaultThread.isDaemon(), thread.isDaemon());
    assertEquals(defaultThread.getPriority(), thread.getPriority());
    assertSame(defaultThread.getThreadGroup(), thread.getThreadGroup());
    assertSame(defaultThread.getUncaughtExceptionHandler(), thread.getUncaughtExceptionHandler());


            

Reported by PMD.

android/guava/src/com/google/common/collect/Sets.java
105 issues
Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 1411

                    int adjust = size() - 1;
      for (int i = 0; i < axes.size(); i++) {
        adjust *= 31;
        adjust = ~~adjust;
        // in GWT, we have to deal with integer overflow carefully
      }
      int hash = 1;
      for (Set<E> axis : axes) {
        hash = 31 * hash + (size() / axis.size() * axis.hashCode());

            

Reported by PMD.

Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 1418

                    for (Set<E> axis : axes) {
        hash = 31 * hash + (size() / axis.size() * axis.hashCode());

        hash = ~~hash;
      }
      hash += adjust;
      return ~~hash;
    }
  }

            

Reported by PMD.

Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 1421

                      hash = ~~hash;
      }
      hash += adjust;
      return ~~hash;
    }
  }

  /**
   * Returns the set of all possible subsets of {@code set}. For example, {@code

            

Reported by PMD.

Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 1691

                  for (Object o : s) {
      hashCode += o != null ? o.hashCode() : 0;

      hashCode = ~~hashCode;
      // Needed to deal with unusual integer overflow in GWT.
    }
    return hashCode;
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'collection'
Design

Line: 1886

                  return changed;
  }

  static boolean removeAllImpl(Set<?> set, Collection<?> collection) {
    checkNotNull(collection); // for GWT
    if (collection instanceof Multiset) {
      collection = ((Multiset<?>) collection).elementSet();
    }
    /*

            

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.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;


            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;


            

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.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;


            

Reported by PMD.

Avoid really long classes.
Design

Line: 68

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Sets {
  private Sets() {}

  /**
   * {@link AbstractSet} substitute without the potentially-quadratic {@code removeAll}
   * implementation.

            

Reported by PMD.

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

Line: 68

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Sets {
  private Sets() {}

  /**
   * {@link AbstractSet} substitute without the potentially-quadratic {@code removeAll}
   * implementation.

            

Reported by PMD.