The following issues were found

android/guava-tests/test/com/google/common/math/MathPreconditionsTest.java
125 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.math;

import static com.google.common.truth.Truth.assertThat;

import com.google.common.annotations.GwtCompatible;
import java.math.BigInteger;

            

Reported by PMD.

Possible God Class (WMC=65, ATFD=20, TCC=0.000%)
Design

Line: 32

               * @author Ben Yu
 */
@GwtCompatible
public class MathPreconditionsTest extends TestCase {

  public void testCheckPositive_zeroInt() {
    try {
      MathPreconditions.checkPositive("int", 0);
      fail();

            

Reported by PMD.

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

Line: 32

               * @author Ben Yu
 */
@GwtCompatible
public class MathPreconditionsTest extends TestCase {

  public void testCheckPositive_zeroInt() {
    try {
      MathPreconditions.checkPositive("int", 0);
      fail();

            

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

              @GwtCompatible
public class MathPreconditionsTest extends TestCase {

  public void testCheckPositive_zeroInt() {
    try {
      MathPreconditions.checkPositive("int", 0);
      fail();
    } catch (IllegalArgumentException expected) {
    }

            

Reported by PMD.

The String literal 'int' appears 12 times in this file; the first occurrence is on line 36
Error

Line: 36

              
  public void testCheckPositive_zeroInt() {
    try {
      MathPreconditions.checkPositive("int", 0);
      fail();
    } catch (IllegalArgumentException expected) {
    }
  }


            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 37

                public void testCheckPositive_zeroInt() {
    try {
      MathPreconditions.checkPositive("int", 0);
      fail();
    } catch (IllegalArgumentException expected) {
    }
  }

  public void testCheckPositive_maxInt() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                public void testCheckPositive_zeroInt() {
    try {
      MathPreconditions.checkPositive("int", 0);
      fail();
    } catch (IllegalArgumentException expected) {
    }
  }

  public void testCheckPositive_maxInt() {

            

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

                  }
  }

  public void testCheckPositive_maxInt() {
    MathPreconditions.checkPositive("int", Integer.MAX_VALUE);
  }

  public void testCheckPositive_minInt() {
    try {

            

Reported by PMD.

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

Line: 42

                  }
  }

  public void testCheckPositive_maxInt() {
    MathPreconditions.checkPositive("int", Integer.MAX_VALUE);
  }

  public void testCheckPositive_minInt() {
    try {

            

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

                  MathPreconditions.checkPositive("int", Integer.MAX_VALUE);
  }

  public void testCheckPositive_minInt() {
    try {
      MathPreconditions.checkPositive("int", Integer.MIN_VALUE);
      fail();
    } catch (IllegalArgumentException expected) {
    }

            

Reported by PMD.

guava-tests/test/com/google/common/cache/CacheExpirationTest.java
125 issues
This class has too many methods, consider refactoring it.
Design

Line: 43

               * @author mike nonemacher
 */
@SuppressWarnings("deprecation") // tests of deprecated method
public class CacheExpirationTest extends TestCase {

  private static final long EXPIRING_TIME = 1000;
  private static final int VALUE_PREFIX = 12345;
  private static final String KEY_PREFIX = "key prefix:";


            

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

                private static final int VALUE_PREFIX = 12345;
  private static final String KEY_PREFIX = "key prefix:";

  public void testExpiration_expireAfterWrite() {
    FakeTicker ticker = new FakeTicker();
    CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
    WatchedCreatorLoader loader = new WatchedCreatorLoader();
    LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder()

            

Reported by PMD.

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

Line: 49

                private static final int VALUE_PREFIX = 12345;
  private static final String KEY_PREFIX = "key prefix:";

  public void testExpiration_expireAfterWrite() {
    FakeTicker ticker = new FakeTicker();
    CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
    WatchedCreatorLoader loader = new WatchedCreatorLoader();
    LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder()

            

Reported by PMD.

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

Line: 62

                  checkExpiration(cache, loader, ticker, removalListener);
  }

  public void testExpiration_expireAfterAccess() {
    FakeTicker ticker = new FakeTicker();
    CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
    WatchedCreatorLoader loader = new WatchedCreatorLoader();
    LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder()

            

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

                  checkExpiration(cache, loader, ticker, removalListener);
  }

  public void testExpiration_expireAfterAccess() {
    FakeTicker ticker = new FakeTicker();
    CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
    WatchedCreatorLoader loader = new WatchedCreatorLoader();
    LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder()

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 82

                    CountingRemovalListener<String, Integer> removalListener) {

    for (int i = 0; i < 10; i++) {
      assertEquals(Integer.valueOf(VALUE_PREFIX + i), cache.getUnchecked(KEY_PREFIX + i));
    }

    for (int i = 0; i < 10; i++) {
      loader.reset();
      assertEquals(Integer.valueOf(VALUE_PREFIX + i), cache.getUnchecked(KEY_PREFIX + i));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 87

              
    for (int i = 0; i < 10; i++) {
      loader.reset();
      assertEquals(Integer.valueOf(VALUE_PREFIX + i), cache.getUnchecked(KEY_PREFIX + i));
      assertFalse("Creator should not have been called @#" + i, loader.wasCalled());
    }

    CacheTesting.expireEntries((LoadingCache<?, ?>) cache, EXPIRING_TIME, ticker);


            

Reported by PMD.

The String literal 'Eviction notifications must be received' appears 4 times in this file; the first occurrence is on line 94
Error

Line: 94

                  CacheTesting.expireEntries((LoadingCache<?, ?>) cache, EXPIRING_TIME, ticker);

    assertEquals("Map must be empty by now", 0, cache.size());
    assertEquals("Eviction notifications must be received", 10, removalListener.getCount());

    CacheTesting.expireEntries((LoadingCache<?, ?>) cache, EXPIRING_TIME, ticker);
    // ensure that no new notifications are sent
    assertEquals("Eviction notifications must be received", 10, removalListener.getCount());
  }

            

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

                  assertEquals("Eviction notifications must be received", 10, removalListener.getCount());
  }

  public void testExpiringGet_expireAfterWrite() {
    FakeTicker ticker = new FakeTicker();
    CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
    WatchedCreatorLoader loader = new WatchedCreatorLoader();
    LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder()

            

Reported by PMD.

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

Line: 101

                  assertEquals("Eviction notifications must be received", 10, removalListener.getCount());
  }

  public void testExpiringGet_expireAfterWrite() {
    FakeTicker ticker = new FakeTicker();
    CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
    WatchedCreatorLoader loader = new WatchedCreatorLoader();
    LoadingCache<String, Integer> cache =
        CacheBuilder.newBuilder()

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/EnumBiMapTest.java
123 issues
This class has too many methods, consider refactoring it.
Design

Line: 51

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class EnumBiMapTest extends TestCase {
  private enum Currency {
    DOLLAR,
    FRANC,
    PESO,
    POUND,

            

Reported by PMD.

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

Line: 75

                    BiMap<Country, Currency> result = EnumBiMap.create(Country.class, Currency.class);
      for (Object object : entries) {
        Entry<Country, Currency> entry = (Entry<Country, Currency>) object;
        result.put(entry.getKey(), entry.getValue());
      }
      return result;
    }

    @Override

            

Reported by PMD.

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

Line: 75

                    BiMap<Country, Currency> result = EnumBiMap.create(Country.class, Currency.class);
      for (Object object : entries) {
        Entry<Country, Currency> entry = (Entry<Country, Currency>) object;
        result.put(entry.getKey(), entry.getValue());
      }
      return result;
    }

    @Override

            

Reported by PMD.

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

Line: 112

                  }
  }

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        BiMapTestSuiteBuilder.using(new EnumBiMapGenerator())
            .named("EnumBiMap")

            

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

                  return suite;
  }

  public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);

            

Reported by PMD.

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

Line: 129

                  return suite;
  }

  public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 131

              
  public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);
    assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
    assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));

            

Reported by PMD.

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

Line: 131

              
  public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);
    assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
    assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 132

                public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);
    assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
    assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
  }

            

Reported by PMD.

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

Line: 132

                public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);
    assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
    assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
  }

            

Reported by PMD.

guava-tests/test/com/google/common/math/PairedStatsTest.java
123 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.math;

import static com.google.common.math.StatsTesting.ALLOWED_ERROR;
import static com.google.common.math.StatsTesting.ALL_MANY_VALUES;
import static com.google.common.math.StatsTesting.ALL_PAIRED_STATS;
import static com.google.common.math.StatsTesting.CONSTANT_VALUES_PAIRED_STATS;

            

Reported by PMD.

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

Line: 66

               *
 * @author Pete Gillin
 */
public class PairedStatsTest extends TestCase {

  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);

            

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

               */
public class PairedStatsTest extends TestCase {

  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

            

Reported by PMD.

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

Line: 68

               */
public class PairedStatsTest extends TestCase {

  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

            

Reported by PMD.

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

Line: 69

              public class PairedStatsTest extends TestCase {

  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }


            

Reported by PMD.

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

Line: 70

              
  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {

            

Reported by PMD.

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

Line: 71

                public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {
    assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());

            

Reported by PMD.

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

Line: 72

                  assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {
    assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
    assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());

            

Reported by PMD.

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

Line: 75

                  assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {
    assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
    assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
    assertStatsApproxEqual(TWO_VALUES_STATS, TWO_VALUES_PAIRED_STATS.xStats());
    assertStatsApproxEqual(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_PAIRED_STATS.xStats());
  }

            

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

                  assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {
    assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
    assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
    assertStatsApproxEqual(TWO_VALUES_STATS, TWO_VALUES_PAIRED_STATS.xStats());
    assertStatsApproxEqual(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_PAIRED_STATS.xStats());
  }

            

Reported by PMD.

guava-tests/test/com/google/common/collect/EnumBiMapTest.java
123 issues
This class has too many methods, consider refactoring it.
Design

Line: 51

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class EnumBiMapTest extends TestCase {
  private enum Currency {
    DOLLAR,
    FRANC,
    PESO,
    POUND,

            

Reported by PMD.

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

Line: 75

                    BiMap<Country, Currency> result = EnumBiMap.create(Country.class, Currency.class);
      for (Object object : entries) {
        Entry<Country, Currency> entry = (Entry<Country, Currency>) object;
        result.put(entry.getKey(), entry.getValue());
      }
      return result;
    }

    @Override

            

Reported by PMD.

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

Line: 75

                    BiMap<Country, Currency> result = EnumBiMap.create(Country.class, Currency.class);
      for (Object object : entries) {
        Entry<Country, Currency> entry = (Entry<Country, Currency>) object;
        result.put(entry.getKey(), entry.getValue());
      }
      return result;
    }

    @Override

            

Reported by PMD.

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

Line: 112

                  }
  }

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        BiMapTestSuiteBuilder.using(new EnumBiMapGenerator())
            .named("EnumBiMap")

            

Reported by PMD.

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

Line: 129

                  return suite;
  }

  public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);

            

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

                  return suite;
  }

  public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 131

              
  public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);
    assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
    assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));

            

Reported by PMD.

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

Line: 131

              
  public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);
    assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
    assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 132

                public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);
    assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
    assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
  }

            

Reported by PMD.

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

Line: 132

                public void testCreate() {
    EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
    assertTrue(bimap.isEmpty());
    assertEquals("{}", bimap.toString());
    assertEquals(HashBiMap.create(), bimap);
    bimap.put(Currency.DOLLAR, Country.CANADA);
    assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
    assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/math/PairedStatsTest.java
123 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.math;

import static com.google.common.math.StatsTesting.ALLOWED_ERROR;
import static com.google.common.math.StatsTesting.ALL_MANY_VALUES;
import static com.google.common.math.StatsTesting.ALL_PAIRED_STATS;
import static com.google.common.math.StatsTesting.CONSTANT_VALUES_PAIRED_STATS;

            

Reported by PMD.

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

Line: 66

               *
 * @author Pete Gillin
 */
public class PairedStatsTest extends TestCase {

  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);

            

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

               */
public class PairedStatsTest extends TestCase {

  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

            

Reported by PMD.

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

Line: 68

               */
public class PairedStatsTest extends TestCase {

  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

            

Reported by PMD.

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

Line: 69

              public class PairedStatsTest extends TestCase {

  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }


            

Reported by PMD.

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

Line: 70

              
  public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {

            

Reported by PMD.

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

Line: 71

                public void testCount() {
    assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {
    assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());

            

Reported by PMD.

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

Line: 72

                  assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
    assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
    assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
    assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {
    assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
    assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());

            

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

                  assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {
    assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
    assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
    assertStatsApproxEqual(TWO_VALUES_STATS, TWO_VALUES_PAIRED_STATS.xStats());
    assertStatsApproxEqual(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_PAIRED_STATS.xStats());
  }

            

Reported by PMD.

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

Line: 75

                  assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
  }

  public void testXStats() {
    assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
    assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
    assertStatsApproxEqual(TWO_VALUES_STATS, TWO_VALUES_PAIRED_STATS.xStats());
    assertStatsApproxEqual(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_PAIRED_STATS.xStats());
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/FilteredCollectionsTest.java
123 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: 73

              
    abstract C filter(C elements, Predicate<? super Integer> predicate);

    public void testIterationOrderPreserved() {
      for (List<Integer> contents : SAMPLE_INPUTS) {
        C unfiltered = createUnfiltered(contents);
        C filtered = filter(unfiltered, EVEN);

        Iterator<Integer> filteredItr = filtered.iterator();

            

Reported by PMD.

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

Line: 73

              
    abstract C filter(C elements, Predicate<? super Integer> predicate);

    public void testIterationOrderPreserved() {
      for (List<Integer> contents : SAMPLE_INPUTS) {
        C unfiltered = createUnfiltered(contents);
        C filtered = filter(unfiltered, EVEN);

        Iterator<Integer> filteredItr = filtered.iterator();

            

Reported by PMD.

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

Line: 78

                      C unfiltered = createUnfiltered(contents);
        C filtered = filter(unfiltered, EVEN);

        Iterator<Integer> filteredItr = filtered.iterator();
        for (Integer i : unfiltered) {
          if (EVEN.apply(i)) {
            assertTrue(filteredItr.hasNext());
            assertEquals(i, filteredItr.next());
          }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 81

                      Iterator<Integer> filteredItr = filtered.iterator();
        for (Integer i : unfiltered) {
          if (EVEN.apply(i)) {
            assertTrue(filteredItr.hasNext());
            assertEquals(i, filteredItr.next());
          }
        }
        assertFalse(filteredItr.hasNext());
      }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 82

                      for (Integer i : unfiltered) {
          if (EVEN.apply(i)) {
            assertTrue(filteredItr.hasNext());
            assertEquals(i, filteredItr.next());
          }
        }
        assertFalse(filteredItr.hasNext());
      }
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 85

                          assertEquals(i, filteredItr.next());
          }
        }
        assertFalse(filteredItr.hasNext());
      }
    }
  }

  public abstract static class AbstractFilteredCollectionTest<C extends Collection<Integer>>

            

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

                public abstract static class AbstractFilteredCollectionTest<C extends Collection<Integer>>
      extends AbstractFilteredIterableTest<C> {

    public void testReadsThroughAdd() {
      for (List<Integer> contents : SAMPLE_INPUTS) {
        C unfiltered = createUnfiltered(contents);
        C filterThenAdd = filter(unfiltered, EVEN);
        unfiltered.add(4);


            

Reported by PMD.

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

Line: 97

                    for (List<Integer> contents : SAMPLE_INPUTS) {
        C unfiltered = createUnfiltered(contents);
        C filterThenAdd = filter(unfiltered, EVEN);
        unfiltered.add(4);

        List<Integer> target = Lists.newArrayList(contents);
        target.add(4);
        C addThenFilter = filter(createUnfiltered(target), EVEN);


            

Reported by PMD.

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

Line: 100

                      unfiltered.add(4);

        List<Integer> target = Lists.newArrayList(contents);
        target.add(4);
        C addThenFilter = filter(createUnfiltered(target), EVEN);

        assertThat(filterThenAdd).containsExactlyElementsIn(addThenFilter);
      }
    }

            

Reported by PMD.

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

Line: 103

                      target.add(4);
        C addThenFilter = filter(createUnfiltered(target), EVEN);

        assertThat(filterThenAdd).containsExactlyElementsIn(addThenFilter);
      }
    }

    public void testAdd() {
      for (List<Integer> contents : SAMPLE_INPUTS) {

            

Reported by PMD.

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

Line: 168

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

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 174

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

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 196

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

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 203

                }

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


            

Reported by PMD.

Possible God Class (WMC=62, ATFD=17, TCC=12.903%)
Design

Line: 35

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class UnsignedIntsTest extends TestCase {
  private static final long[] UNSIGNED_INTS = {
    0L,
    1L,
    2L,
    3L,

            

Reported by PMD.

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

Line: 35

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class UnsignedIntsTest extends TestCase {
  private static final long[] UNSIGNED_INTS = {
    0L,
    1L,
    2L,
    3L,

            

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

                private static final int LEAST = (int) 0L;
  private static final int GREATEST = (int) 0xffffffffL;

  public void testCheckedCast() {
    for (long value : UNSIGNED_INTS) {
      assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
    }
    assertCastFails(1L << 32);
    assertCastFails(-1L);

            

Reported by PMD.

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

Line: 53

                private static final int LEAST = (int) 0L;
  private static final int GREATEST = (int) 0xffffffffL;

  public void testCheckedCast() {
    for (long value : UNSIGNED_INTS) {
      assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
    }
    assertCastFails(1L << 32);
    assertCastFails(-1L);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 55

              
  public void testCheckedCast() {
    for (long value : UNSIGNED_INTS) {
      assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
    }
    assertCastFails(1L << 32);
    assertCastFails(-1L);
    assertCastFails(Long.MAX_VALUE);
    assertCastFails(Long.MIN_VALUE);

            

Reported by PMD.

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

Line: 68

                    UnsignedInts.checkedCast(value);
      fail("Cast to int should have failed: " + value);
    } catch (IllegalArgumentException ex) {
      assertThat(ex.getMessage()).contains(String.valueOf(value));
    }
  }

  public void testSaturatedCast() {
    for (long value : UNSIGNED_INTS) {

            

Reported by PMD.

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

Line: 168

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

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 174

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

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 196

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

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 203

                }

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


            

Reported by PMD.

Possible God Class (WMC=62, ATFD=17, TCC=12.903%)
Design

Line: 35

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class UnsignedIntsTest extends TestCase {
  private static final long[] UNSIGNED_INTS = {
    0L,
    1L,
    2L,
    3L,

            

Reported by PMD.

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

Line: 35

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class UnsignedIntsTest extends TestCase {
  private static final long[] UNSIGNED_INTS = {
    0L,
    1L,
    2L,
    3L,

            

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

                private static final int LEAST = (int) 0L;
  private static final int GREATEST = (int) 0xffffffffL;

  public void testCheckedCast() {
    for (long value : UNSIGNED_INTS) {
      assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
    }
    assertCastFails(1L << 32);
    assertCastFails(-1L);

            

Reported by PMD.

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

Line: 53

                private static final int LEAST = (int) 0L;
  private static final int GREATEST = (int) 0xffffffffL;

  public void testCheckedCast() {
    for (long value : UNSIGNED_INTS) {
      assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
    }
    assertCastFails(1L << 32);
    assertCastFails(-1L);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 55

              
  public void testCheckedCast() {
    for (long value : UNSIGNED_INTS) {
      assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
    }
    assertCastFails(1L << 32);
    assertCastFails(-1L);
    assertCastFails(Long.MAX_VALUE);
    assertCastFails(Long.MIN_VALUE);

            

Reported by PMD.

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

Line: 68

                    UnsignedInts.checkedCast(value);
      fail("Cast to int should have failed: " + value);
    } catch (IllegalArgumentException ex) {
      assertThat(ex.getMessage()).contains(String.valueOf(value));
    }
  }

  public void testSaturatedCast() {
    for (long value : UNSIGNED_INTS) {

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/MapsTransformValuesUnmodifiableIteratorTest.java
122 issues
This class has too many methods, consider refactoring it.
Design

Line: 37

               * @author Jared Levy
 */
@GwtCompatible
public class MapsTransformValuesUnmodifiableIteratorTest extends MapInterfaceTest<String, String> {
  // TODO(jlevy): Move shared code of this class and MapsTransformValuesTest
  // to a superclass.

  public MapsTransformValuesUnmodifiableIteratorTest() {
    super(true, true, false /*supportsPut*/, true, true, false);

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 46

                }

  private static class UnmodifiableIteratorMap<K, V> extends ForwardingMap<K, V> {
    final Map<K, V> delegate;

    UnmodifiableIteratorMap(Map<K, V> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

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

Line: 46

                }

  private static class UnmodifiableIteratorMap<K, V> extends ForwardingMap<K, V> {
    final Map<K, V> delegate;

    UnmodifiableIteratorMap(Map<K, V> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

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

Line: 67

              
        @Override
        public Iterator<K> iterator() {
          return Iterators.unmodifiableIterator(delegate.keySet().iterator());
        }

        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.keySet().removeAll(c);

            

Reported by PMD.

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

Line: 72

              
        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.keySet().removeAll(c);
        }

        @Override
        public boolean retainAll(Collection<?> c) {
          return delegate.keySet().retainAll(c);

            

Reported by PMD.

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

Line: 77

              
        @Override
        public boolean retainAll(Collection<?> c) {
          return delegate.keySet().retainAll(c);
        }
      };
    }

    @Override

            

Reported by PMD.

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

Line: 92

              
        @Override
        public Iterator<V> iterator() {
          return Iterators.unmodifiableIterator(delegate.values().iterator());
        }

        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.values().removeAll(c);

            

Reported by PMD.

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

Line: 97

              
        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.values().removeAll(c);
        }

        @Override
        public boolean retainAll(Collection<?> c) {
          return delegate.values().retainAll(c);

            

Reported by PMD.

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

Line: 102

              
        @Override
        public boolean retainAll(Collection<?> c) {
          return delegate.values().retainAll(c);
        }
      };
    }

    @Override

            

Reported by PMD.

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

Line: 117

              
        @Override
        public Iterator<Entry<K, V>> iterator() {
          return Iterators.unmodifiableIterator(delegate.entrySet().iterator());
        }

        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.entrySet().removeAll(c);

            

Reported by PMD.