The following issues were found

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

Line: 296

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

            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 189

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

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 196

                }

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


            

Reported by PMD.

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

Line: 37

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class BooleansTest extends TestCase {
  private static final boolean[] EMPTY = {};
  private static final boolean[] ARRAY_FALSE = {false};
  private static final boolean[] ARRAY_TRUE = {true};
  private static final boolean[] ARRAY_FALSE_FALSE = {false, false};
  private static final boolean[] ARRAY_FALSE_TRUE = {false, true};

            

Reported by PMD.

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

Line: 46

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

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

  public void testTrueFirst() {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 46

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

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

  public void testTrueFirst() {

            

Reported by PMD.

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

Line: 47

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

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

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

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

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

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

            

Reported by PMD.

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

Line: 48

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

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 48

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

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

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java
234 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList;


            

Reported by PMD.

Possible God Class (WMC=66, ATFD=21, TCC=0.000%)
Design

Line: 48

               *
 * @author Louis Wasserman
 */
public class ImmutableSortedMultisetTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableSortedMultisetTest.class);

    suite.addTest(

            

Reported by PMD.

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

Line: 48

               *
 * @author Louis Wasserman
 */
public class ImmutableSortedMultisetTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableSortedMultisetTest.class);

    suite.addTest(

            

Reported by PMD.

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

Line: 49

               * @author Louis Wasserman
 */
public class ImmutableSortedMultisetTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableSortedMultisetTest.class);

    suite.addTest(
        SortedMultisetTestSuiteBuilder.using(

            

Reported by PMD.

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

Line: 63

              
                  @Override
                  public List<String> order(List<String> insertionOrder) {
                    return Ordering.natural().sortedCopy(insertionOrder);
                  }
                })
            .named("ImmutableSortedMultiset")
            .withFeatures(
                CollectionSize.ANY,

            

Reported by PMD.

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

Line: 78

                              new TestStringListGenerator() {
                  @Override
                  protected List<String> create(String[] elements) {
                    return ImmutableSortedMultiset.copyOf(elements).asList();
                  }

                  @Override
                  public List<String> order(List<String> insertionOrder) {
                    return Ordering.natural().sortedCopy(insertionOrder);

            

Reported by PMD.

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

Line: 83

              
                  @Override
                  public List<String> order(List<String> insertionOrder) {
                    return Ordering.natural().sortedCopy(insertionOrder);
                  }
                })
            .named("ImmutableSortedMultiset.asList")
            .withFeatures(
                CollectionSize.ANY,

            

Reported by PMD.

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

Line: 105

                                    checkArgument(set.add(s));
                      builder.addCopies(s, 2);
                    }
                    return builder.build().elementSet().asList();
                  }

                  @Override
                  public List<String> order(List<String> insertionOrder) {
                    return Ordering.natural().sortedCopy(insertionOrder);

            

Reported by PMD.

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

Line: 105

                                    checkArgument(set.add(s));
                      builder.addCopies(s, 2);
                    }
                    return builder.build().elementSet().asList();
                  }

                  @Override
                  public List<String> order(List<String> insertionOrder) {
                    return Ordering.natural().sortedCopy(insertionOrder);

            

Reported by PMD.

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

Line: 110

              
                  @Override
                  public List<String> order(List<String> insertionOrder) {
                    return Ordering.natural().sortedCopy(insertionOrder);
                  }
                })
            .named("ImmutableSortedMultiset.elementSet.asList")
            .withFeatures(
                CollectionSize.ANY,

            

Reported by PMD.

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

Line: 31

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class ImmutableTableTest extends AbstractTableReadTest {
  @Override
  protected Table<String, Integer, Character> create(Object... data) {
    ImmutableTable.Builder<String, Integer, Character> builder = ImmutableTable.builder();
    for (int i = 0; i < data.length; i = i + 3) {
      builder.put((String) data[i], (Integer) data[i + 1], (Character) data[i + 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: 42

                }

  // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
  public void testToImmutableTable_java7_combine() {
    ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)

            

Reported by PMD.

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

Line: 44

                // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
  public void testToImmutableTable_java7_combine() {
    ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)
            .put("two", "twei", 2);
    ImmutableTable<String, String, Integer> table = zis.combine(zat).build();

            

Reported by PMD.

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

Line: 44

                // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
  public void testToImmutableTable_java7_combine() {
    ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)
            .put("two", "twei", 2);
    ImmutableTable<String, String, Integer> table = zis.combine(zat).build();

            

Reported by PMD.

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

Line: 44

                // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
  public void testToImmutableTable_java7_combine() {
    ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)
            .put("two", "twei", 2);
    ImmutableTable<String, String, Integer> table = zis.combine(zat).build();

            

Reported by PMD.

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

Line: 44

                // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
  public void testToImmutableTable_java7_combine() {
    ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)
            .put("two", "twei", 2);
    ImmutableTable<String, String, Integer> table = zis.combine(zat).build();

            

Reported by PMD.

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

Line: 44

                // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
  public void testToImmutableTable_java7_combine() {
    ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)
            .put("two", "twei", 2);
    ImmutableTable<String, String, Integer> table = zis.combine(zat).build();

            

Reported by PMD.

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

Line: 46

                  ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)
            .put("two", "twei", 2);
    ImmutableTable<String, String, Integer> table = zis.combine(zat).build();
    ImmutableTable<String, String, Integer> expected =
        ImmutableTable.<String, String, Integer>builder()

            

Reported by PMD.

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

Line: 46

                  ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)
            .put("two", "twei", 2);
    ImmutableTable<String, String, Integer> table = zis.combine(zat).build();
    ImmutableTable<String, String, Integer> expected =
        ImmutableTable.<String, String, Integer>builder()

            

Reported by PMD.

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

Line: 46

                  ImmutableTable.Builder<String, String, Integer> zis =
        ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
    ImmutableTable.Builder<String, String, Integer> zat =
        ImmutableTable.<String, String, Integer>builder()
            .put("one", "eins", 1)
            .put("two", "twei", 2);
    ImmutableTable<String, String, Integer> table = zis.combine(zat).build();
    ImmutableTable<String, String, Integer> expected =
        ImmutableTable.<String, String, Integer>builder()

            

Reported by PMD.

guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java
231 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.collect;

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

import com.google.common.annotations.GwtCompatible;

            

Reported by PMD.

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

Line: 60

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?

            

Reported by PMD.

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

Line: 60

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?

            

Reported by PMD.

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

Line: 60

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?

            

Reported by PMD.

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

Line: 62

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

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?
    suite.addTest(
        SortedSetMultimapTestSuiteBuilder.using(

            

Reported by PMD.

Avoid really long methods.
Design

Line: 63

              public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?
    suite.addTest(
        SortedSetMultimapTestSuiteBuilder.using(
                new TestStringSetMultimapGenerator() {

            

Reported by PMD.

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

Line: 63

              public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?
    suite.addTest(
        SortedSetMultimapTestSuiteBuilder.using(
                new TestStringSetMultimapGenerator() {

            

Reported by PMD.

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

Line: 63

              public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?
    suite.addTest(
        SortedSetMultimapTestSuiteBuilder.using(
                new TestStringSetMultimapGenerator() {

            

Reported by PMD.

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

Line: 73

                                protected SetMultimap<String, String> create(Entry<String, String>[] entries) {
                    SetMultimap<String, String> multimap =
                        TreeMultimap.create(
                            Ordering.natural().nullsFirst(), Ordering.natural().nullsFirst());
                    for (Entry<String, String> entry : entries) {
                      multimap.put(entry.getKey(), entry.getValue());
                    }
                    return multimap;
                  }

            

Reported by PMD.

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

Line: 73

                                protected SetMultimap<String, String> create(Entry<String, String>[] entries) {
                    SetMultimap<String, String> multimap =
                        TreeMultimap.create(
                            Ordering.natural().nullsFirst(), Ordering.natural().nullsFirst());
                    for (Entry<String, String> entry : entries) {
                      multimap.put(entry.getKey(), entry.getValue());
                    }
                    return multimap;
                  }

            

Reported by PMD.

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

Line: 47

               * @author mike nonemacher
 */

public class PopulatedCachesTest extends TestCase {
  // we use integers as keys; make sure the range covers some values that ARE cached by
  // Integer.valueOf(int), and some that are not cached. (127 is the highest cached value.)
  static final int WARMUP_MIN = 120;
  static final int WARMUP_MAX = 135;
  static final int WARMUP_SIZE = WARMUP_MAX - WARMUP_MIN;

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 54

                static final int WARMUP_MAX = 135;
  static final int WARMUP_SIZE = WARMUP_MAX - WARMUP_MIN;

  public void testSize_populated() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      assertEquals(WARMUP_SIZE, cache.size());
      assertMapSize(cache.asMap(), WARMUP_SIZE);

            

Reported by PMD.

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

Line: 54

                static final int WARMUP_MAX = 135;
  static final int WARMUP_SIZE = WARMUP_MAX - WARMUP_MIN;

  public void testSize_populated() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      assertEquals(WARMUP_SIZE, cache.size());
      assertMapSize(cache.asMap(), WARMUP_SIZE);

            

Reported by PMD.

Avoid unused local variables such as 'warmed'.
Design

Line: 57

                public void testSize_populated() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      assertEquals(WARMUP_SIZE, cache.size());
      assertMapSize(cache.asMap(), WARMUP_SIZE);
      checkValidState(cache);
    }
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 58

                  for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      assertEquals(WARMUP_SIZE, cache.size());
      assertMapSize(cache.asMap(), WARMUP_SIZE);
      checkValidState(cache);
    }
  }


            

Reported by PMD.

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

Line: 64

                  }
  }

  public void testContainsKey_found() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);

            

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

                  }
  }

  public void testContainsKey_found() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);

            

Reported by PMD.

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

Line: 69

                    // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
        assertTrue(cache.asMap().containsKey(entry.getKey()));
        assertTrue(cache.asMap().containsValue(entry.getValue()));
        // this getUnchecked() call shouldn't be a cache miss; verified below
        assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
      }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 70

                    List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
        assertTrue(cache.asMap().containsKey(entry.getKey()));
        assertTrue(cache.asMap().containsValue(entry.getValue()));
        // this getUnchecked() call shouldn't be a cache miss; verified below
        assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
      }
      assertEquals(WARMUP_SIZE, cache.stats().missCount());

            

Reported by PMD.

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

Line: 70

                    List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
        assertTrue(cache.asMap().containsKey(entry.getKey()));
        assertTrue(cache.asMap().containsValue(entry.getValue()));
        // this getUnchecked() call shouldn't be a cache miss; verified below
        assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
      }
      assertEquals(WARMUP_SIZE, cache.stats().missCount());

            

Reported by PMD.

android/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java
231 issues
This class has too many methods, consider refactoring it.
Design

Line: 45

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

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

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 48

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

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

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

            

Reported by PMD.

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

Line: 49

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

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

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

            

Reported by PMD.

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

Line: 49

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

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

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

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 52

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

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

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

            

Reported by PMD.

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

Line: 53

                }

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

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

            

Reported by PMD.

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

Line: 53

                }

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

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

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 56

                  assertThat(ImmutableIntArray.of(0).asList()).containsExactly(0);
  }

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

  public void testOf3() {
    assertThat(ImmutableIntArray.of(0, 1, 3).asList()).containsExactly(0, 1, 3).inOrder();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 57

                }

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

  public void testOf3() {
    assertThat(ImmutableIntArray.of(0, 1, 3).asList()).containsExactly(0, 1, 3).inOrder();
  }

            

Reported by PMD.

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

Line: 57

                }

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

  public void testOf3() {
    assertThat(ImmutableIntArray.of(0, 1, 3).asList()).containsExactly(0, 1, 3).inOrder();
  }

            

Reported by PMD.

guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java
231 issues
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.truth.Truth.assertThat;
import static java.util.Arrays.asList;


            

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.truth.Truth.assertThat;
import static java.util.Arrays.asList;


            

Reported by PMD.

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

Line: 59

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class ImmutableMultisetTest extends TestCase {

  @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);

            

Reported by PMD.

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

Line: 59

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class ImmutableMultisetTest extends TestCase {

  @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);

            

Reported by PMD.

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

Line: 59

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class ImmutableMultisetTest extends TestCase {

  @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);

            

Reported by PMD.

Possible God Class (WMC=72, ATFD=37, TCC=0.000%)
Design

Line: 59

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class ImmutableMultisetTest extends TestCase {

  @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);

            

Reported by PMD.

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

Line: 61

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

  @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);
    suite.addTestSuite(FloodingTest.class);


            

Reported by PMD.

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

Line: 62

              public class ImmutableMultisetTest extends TestCase {

  @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);
    suite.addTestSuite(FloodingTest.class);

    suite.addTest(

            

Reported by PMD.

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

Line: 62

              public class ImmutableMultisetTest extends TestCase {

  @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);
    suite.addTestSuite(FloodingTest.class);

    suite.addTest(

            

Reported by PMD.

Avoid really long methods.
Design

Line: 62

              public class ImmutableMultisetTest extends TestCase {

  @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMultisetTest.class);
    suite.addTestSuite(FloodingTest.class);

    suite.addTest(

            

Reported by PMD.

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

Line: 47

               * @author mike nonemacher
 */

public class PopulatedCachesTest extends TestCase {
  // we use integers as keys; make sure the range covers some values that ARE cached by
  // Integer.valueOf(int), and some that are not cached. (127 is the highest cached value.)
  static final int WARMUP_MIN = 120;
  static final int WARMUP_MAX = 135;
  static final int WARMUP_SIZE = WARMUP_MAX - WARMUP_MIN;

            

Reported by PMD.

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

Line: 54

                static final int WARMUP_MAX = 135;
  static final int WARMUP_SIZE = WARMUP_MAX - WARMUP_MIN;

  public void testSize_populated() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      assertEquals(WARMUP_SIZE, cache.size());
      assertMapSize(cache.asMap(), WARMUP_SIZE);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 54

                static final int WARMUP_MAX = 135;
  static final int WARMUP_SIZE = WARMUP_MAX - WARMUP_MIN;

  public void testSize_populated() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      assertEquals(WARMUP_SIZE, cache.size());
      assertMapSize(cache.asMap(), WARMUP_SIZE);

            

Reported by PMD.

Avoid unused local variables such as 'warmed'.
Design

Line: 57

                public void testSize_populated() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      assertEquals(WARMUP_SIZE, cache.size());
      assertMapSize(cache.asMap(), WARMUP_SIZE);
      checkValidState(cache);
    }
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 58

                  for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      assertEquals(WARMUP_SIZE, cache.size());
      assertMapSize(cache.asMap(), WARMUP_SIZE);
      checkValidState(cache);
    }
  }


            

Reported by PMD.

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

Line: 64

                  }
  }

  public void testContainsKey_found() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);

            

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

                  }
  }

  public void testContainsKey_found() {
    for (LoadingCache<Object, Object> cache : caches()) {
      // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);

            

Reported by PMD.

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

Line: 69

                    // don't let the entries get GCed
      List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
        assertTrue(cache.asMap().containsKey(entry.getKey()));
        assertTrue(cache.asMap().containsValue(entry.getValue()));
        // this getUnchecked() call shouldn't be a cache miss; verified below
        assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
      }

            

Reported by PMD.

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

Line: 70

                    List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
        assertTrue(cache.asMap().containsKey(entry.getKey()));
        assertTrue(cache.asMap().containsValue(entry.getValue()));
        // this getUnchecked() call shouldn't be a cache miss; verified below
        assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
      }
      assertEquals(WARMUP_SIZE, cache.stats().missCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 70

                    List<Entry<Object, Object>> warmed = warmUp(cache);
      for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
        Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
        assertTrue(cache.asMap().containsKey(entry.getKey()));
        assertTrue(cache.asMap().containsValue(entry.getValue()));
        // this getUnchecked() call shouldn't be a cache miss; verified below
        assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
      }
      assertEquals(WARMUP_SIZE, cache.stats().missCount());

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java
231 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.collect;

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

import com.google.common.annotations.GwtCompatible;

            

Reported by PMD.

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

Line: 60

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?

            

Reported by PMD.

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

Line: 60

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?

            

Reported by PMD.

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

Line: 60

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?

            

Reported by PMD.

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

Line: 62

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

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?
    suite.addTest(
        SortedSetMultimapTestSuiteBuilder.using(

            

Reported by PMD.

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

Line: 63

              public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?
    suite.addTest(
        SortedSetMultimapTestSuiteBuilder.using(
                new TestStringSetMultimapGenerator() {

            

Reported by PMD.

Avoid really long methods.
Design

Line: 63

              public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?
    suite.addTest(
        SortedSetMultimapTestSuiteBuilder.using(
                new TestStringSetMultimapGenerator() {

            

Reported by PMD.

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

Line: 63

              public class TreeMultimapNaturalTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls?
    suite.addTest(
        SortedSetMultimapTestSuiteBuilder.using(
                new TestStringSetMultimapGenerator() {

            

Reported by PMD.

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

Line: 73

                                protected SetMultimap<String, String> create(Entry<String, String>[] entries) {
                    SetMultimap<String, String> multimap =
                        TreeMultimap.create(
                            Ordering.natural().nullsFirst(), Ordering.natural().nullsFirst());
                    for (Entry<String, String> entry : entries) {
                      multimap.put(entry.getKey(), entry.getValue());
                    }
                    return multimap;
                  }

            

Reported by PMD.

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

Line: 73

                                protected SetMultimap<String, String> create(Entry<String, String>[] entries) {
                    SetMultimap<String, String> multimap =
                        TreeMultimap.create(
                            Ordering.natural().nullsFirst(), Ordering.natural().nullsFirst());
                    for (Entry<String, String> entry : entries) {
                      multimap.put(entry.getKey(), entry.getValue());
                    }
                    return multimap;
                  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
230 issues
Possible God Class (WMC=66, ATFD=174, TCC=0.000%)
Design

Line: 34

               *
 * @author Adam Winer
 */
public class CacheBuilderSpecTest extends TestCase {
  public void testParse_empty() {
    CacheBuilderSpec spec = parse("");
    assertNull(spec.initialCapacity);
    assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);

            

Reported by PMD.

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

Line: 34

               *
 * @author Adam Winer
 */
public class CacheBuilderSpecTest extends TestCase {
  public void testParse_empty() {
    CacheBuilderSpec spec = parse("");
    assertNull(spec.initialCapacity);
    assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);

            

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

               * @author Adam Winer
 */
public class CacheBuilderSpecTest extends TestCase {
  public void testParse_empty() {
    CacheBuilderSpec spec = parse("");
    assertNull(spec.initialCapacity);
    assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);
    assertNull(spec.concurrencyLevel);

            

Reported by PMD.

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

Line: 35

               * @author Adam Winer
 */
public class CacheBuilderSpecTest extends TestCase {
  public void testParse_empty() {
    CacheBuilderSpec spec = parse("");
    assertNull(spec.initialCapacity);
    assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);
    assertNull(spec.concurrencyLevel);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

              public class CacheBuilderSpecTest extends TestCase {
  public void testParse_empty() {
    CacheBuilderSpec spec = parse("");
    assertNull(spec.initialCapacity);
    assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);
    assertNull(spec.concurrencyLevel);
    assertNull(spec.keyStrength);
    assertNull(spec.valueStrength);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 38

                public void testParse_empty() {
    CacheBuilderSpec spec = parse("");
    assertNull(spec.initialCapacity);
    assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);
    assertNull(spec.concurrencyLevel);
    assertNull(spec.keyStrength);
    assertNull(spec.valueStrength);
    assertNull(spec.writeExpirationTimeUnit);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 39

                  CacheBuilderSpec spec = parse("");
    assertNull(spec.initialCapacity);
    assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);
    assertNull(spec.concurrencyLevel);
    assertNull(spec.keyStrength);
    assertNull(spec.valueStrength);
    assertNull(spec.writeExpirationTimeUnit);
    assertNull(spec.accessExpirationTimeUnit);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                  assertNull(spec.initialCapacity);
    assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);
    assertNull(spec.concurrencyLevel);
    assertNull(spec.keyStrength);
    assertNull(spec.valueStrength);
    assertNull(spec.writeExpirationTimeUnit);
    assertNull(spec.accessExpirationTimeUnit);
    assertCacheBuilderEquivalence(CacheBuilder.newBuilder(), CacheBuilder.from(spec));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

                  assertNull(spec.maximumSize);
    assertNull(spec.maximumWeight);
    assertNull(spec.concurrencyLevel);
    assertNull(spec.keyStrength);
    assertNull(spec.valueStrength);
    assertNull(spec.writeExpirationTimeUnit);
    assertNull(spec.accessExpirationTimeUnit);
    assertCacheBuilderEquivalence(CacheBuilder.newBuilder(), CacheBuilder.from(spec));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

                  assertNull(spec.maximumWeight);
    assertNull(spec.concurrencyLevel);
    assertNull(spec.keyStrength);
    assertNull(spec.valueStrength);
    assertNull(spec.writeExpirationTimeUnit);
    assertNull(spec.accessExpirationTimeUnit);
    assertCacheBuilderEquivalence(CacheBuilder.newBuilder(), CacheBuilder.from(spec));
  }


            

Reported by PMD.