The following issues were found

guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java
290 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.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
import static com.google.common.collect.Sets.newLinkedHashSet;
import static com.google.common.collect.testing.IteratorFeature.MODIFIABLE;

            

Reported by PMD.

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

Line: 57

               * @author Mike Bostock
 */
@GwtCompatible(emulated = true)
public class LinkedListMultimapTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(

            

Reported by PMD.

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

Line: 59

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

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        ListMultimapTestSuiteBuilder.using(
                new TestStringListMultimapGenerator() {

            

Reported by PMD.

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

Line: 94

                }

  /** Confirm that get() returns a List that doesn't implement RandomAccess. */
  public void testGetRandomAccess() {
    Multimap<String, Integer> multimap = create();
    multimap.put("foo", 1);
    multimap.put("foo", 3);
    assertFalse(multimap.get("foo") instanceof RandomAccess);
    assertFalse(multimap.get("bar") instanceof RandomAccess);

            

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

                }

  /** Confirm that get() returns a List that doesn't implement RandomAccess. */
  public void testGetRandomAccess() {
    Multimap<String, Integer> multimap = create();
    multimap.put("foo", 1);
    multimap.put("foo", 3);
    assertFalse(multimap.get("foo") instanceof RandomAccess);
    assertFalse(multimap.get("bar") instanceof RandomAccess);

            

Reported by PMD.

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

Line: 96

                /** Confirm that get() returns a List that doesn't implement RandomAccess. */
  public void testGetRandomAccess() {
    Multimap<String, Integer> multimap = create();
    multimap.put("foo", 1);
    multimap.put("foo", 3);
    assertFalse(multimap.get("foo") instanceof RandomAccess);
    assertFalse(multimap.get("bar") instanceof RandomAccess);
  }


            

Reported by PMD.

The String literal 'foo' appears 60 times in this file; the first occurrence is on line 96
Error

Line: 96

                /** Confirm that get() returns a List that doesn't implement RandomAccess. */
  public void testGetRandomAccess() {
    Multimap<String, Integer> multimap = create();
    multimap.put("foo", 1);
    multimap.put("foo", 3);
    assertFalse(multimap.get("foo") instanceof RandomAccess);
    assertFalse(multimap.get("bar") instanceof RandomAccess);
  }


            

Reported by PMD.

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

Line: 97

                public void testGetRandomAccess() {
    Multimap<String, Integer> multimap = create();
    multimap.put("foo", 1);
    multimap.put("foo", 3);
    assertFalse(multimap.get("foo") instanceof RandomAccess);
    assertFalse(multimap.get("bar") instanceof RandomAccess);
  }

  /**

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 98

                  Multimap<String, Integer> multimap = create();
    multimap.put("foo", 1);
    multimap.put("foo", 3);
    assertFalse(multimap.get("foo") instanceof RandomAccess);
    assertFalse(multimap.get("bar") instanceof RandomAccess);
  }

  /**
   * Confirm that removeAll() returns a List that implements RandomAccess, even though get()

            

Reported by PMD.

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

Line: 98

                  Multimap<String, Integer> multimap = create();
    multimap.put("foo", 1);
    multimap.put("foo", 3);
    assertFalse(multimap.get("foo") instanceof RandomAccess);
    assertFalse(multimap.get("bar") instanceof RandomAccess);
  }

  /**
   * Confirm that removeAll() returns a List that implements RandomAccess, even though get()

            

Reported by PMD.

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

Line: 39

              import junit.framework.TestCase;

/** @author Charles Fry */
public class LocalLoadingCacheTest extends TestCase {

  private static <K, V> LocalLoadingCache<K, V> makeCache(
      CacheBuilder<K, V> builder, CacheLoader<? super K, V> loader) {
    return new LocalLoadingCache<>(builder, loader);
  }

            

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

              
  // constructor tests

  public void testComputingFunction() {
    CacheLoader<Object, Object> loader =
        new CacheLoader<Object, Object>() {
          @Override
          public Object load(Object from) {
            return new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 61

                        }
        };
    LocalLoadingCache<Object, Object> cache = makeCache(createCacheBuilder(), loader);
    assertSame(loader, cache.localCache.defaultLoader);
  }

  // null parameters test

  public void testNullParameters() throws Exception {

            

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

              
  // null parameters test

  public void testNullParameters() throws Exception {
    NullPointerTester tester = new NullPointerTester();
    CacheLoader<Object, Object> loader = identityLoader();
    tester.testAllPublicInstanceMethods(makeCache(createCacheBuilder(), loader));
  }


            

Reported by PMD.

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

Line: 66

              
  // null parameters test

  public void testNullParameters() throws Exception {
    NullPointerTester tester = new NullPointerTester();
    CacheLoader<Object, Object> loader = identityLoader();
    tester.testAllPublicInstanceMethods(makeCache(createCacheBuilder(), loader));
  }


            

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

              
  // stats tests

  public void testStats() {
    CacheBuilder<Object, Object> builder = createCacheBuilder().concurrencyLevel(1).maximumSize(2);
    LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
    assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();

            

Reported by PMD.

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

Line: 74

              
  // stats tests

  public void testStats() {
    CacheBuilder<Object, Object> builder = createCacheBuilder().concurrencyLevel(1).maximumSize(2);
    LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
    assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 77

                public void testStats() {
    CacheBuilder<Object, Object> builder = createCacheBuilder().concurrencyLevel(1).maximumSize(2);
    LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
    assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();
    cache.getUnchecked(one);
    CacheStats stats = cache.stats();
    assertEquals(1, stats.requestCount());

            

Reported by PMD.

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

Line: 77

                public void testStats() {
    CacheBuilder<Object, Object> builder = createCacheBuilder().concurrencyLevel(1).maximumSize(2);
    LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
    assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();
    cache.getUnchecked(one);
    CacheStats stats = cache.stats();
    assertEquals(1, stats.requestCount());

            

Reported by PMD.

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

Line: 80

                  assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();
    cache.getUnchecked(one);
    CacheStats stats = cache.stats();
    assertEquals(1, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(0.0, stats.hitRate());
    assertEquals(1, stats.missCount());

            

Reported by PMD.

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

Line: 39

              import junit.framework.TestCase;

/** @author Charles Fry */
public class LocalLoadingCacheTest extends TestCase {

  private static <K, V> LocalLoadingCache<K, V> makeCache(
      CacheBuilder<K, V> builder, CacheLoader<? super K, V> loader) {
    return new LocalLoadingCache<>(builder, loader);
  }

            

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

              
  // constructor tests

  public void testComputingFunction() {
    CacheLoader<Object, Object> loader =
        new CacheLoader<Object, Object>() {
          @Override
          public Object load(Object from) {
            return new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 61

                        }
        };
    LocalLoadingCache<Object, Object> cache = makeCache(createCacheBuilder(), loader);
    assertSame(loader, cache.localCache.defaultLoader);
  }

  // null parameters test

  public void testNullParameters() throws Exception {

            

Reported by PMD.

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

Line: 66

              
  // null parameters test

  public void testNullParameters() throws Exception {
    NullPointerTester tester = new NullPointerTester();
    CacheLoader<Object, Object> loader = identityLoader();
    tester.testAllPublicInstanceMethods(makeCache(createCacheBuilder(), loader));
  }


            

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

              
  // null parameters test

  public void testNullParameters() throws Exception {
    NullPointerTester tester = new NullPointerTester();
    CacheLoader<Object, Object> loader = identityLoader();
    tester.testAllPublicInstanceMethods(makeCache(createCacheBuilder(), loader));
  }


            

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

              
  // stats tests

  public void testStats() {
    CacheBuilder<Object, Object> builder = createCacheBuilder().concurrencyLevel(1).maximumSize(2);
    LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
    assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();

            

Reported by PMD.

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

Line: 74

              
  // stats tests

  public void testStats() {
    CacheBuilder<Object, Object> builder = createCacheBuilder().concurrencyLevel(1).maximumSize(2);
    LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
    assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();

            

Reported by PMD.

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

Line: 77

                public void testStats() {
    CacheBuilder<Object, Object> builder = createCacheBuilder().concurrencyLevel(1).maximumSize(2);
    LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
    assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();
    cache.getUnchecked(one);
    CacheStats stats = cache.stats();
    assertEquals(1, stats.requestCount());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 77

                public void testStats() {
    CacheBuilder<Object, Object> builder = createCacheBuilder().concurrencyLevel(1).maximumSize(2);
    LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
    assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();
    cache.getUnchecked(one);
    CacheStats stats = cache.stats();
    assertEquals(1, stats.requestCount());

            

Reported by PMD.

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

Line: 80

                  assertEquals(EMPTY_STATS, cache.stats());

    Object one = new Object();
    cache.getUnchecked(one);
    CacheStats stats = cache.stats();
    assertEquals(1, stats.requestCount());
    assertEquals(0, stats.hitCount());
    assertEquals(0.0, stats.hitRate());
    assertEquals(1, stats.missCount());

            

Reported by PMD.

guava/src/com/google/common/collect/MapMakerInternalMap.java
285 issues
Overridable method 'initTable' called during object construction
Error

Line: 1209

                  Segment(MapMakerInternalMap<K, V, E, S> map, int initialCapacity, int maxSegmentSize) {
      this.map = map;
      this.maxSegmentSize = maxSegmentSize;
      initTable(newEntryArray(initialCapacity));
    }

    /**
     * Returns {@code this} up-casted to the specific {@link Segment} implementation type {@code S}.
     *

            

Reported by PMD.

Overridable method 'nextInChain' called during object construction
Error

Line: 2516

                  HashIterator() {
      nextSegmentIndex = segments.length - 1;
      nextTableIndex = -1;
      advance();
    }

    @Override
    public abstract T next();


            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1055

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1055

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1055

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1055

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1055

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

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

Line: 15

               * the License.
 */

package com.google.common.collect;

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

import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

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.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkRemove;

import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

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

Line: 15

               * the License.
 */

package com.google.common.collect;

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

import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

android/guava/src/com/google/common/collect/MapMakerInternalMap.java
285 issues
Overridable method 'initTable' called during object construction
Error

Line: 1214

                  Segment(MapMakerInternalMap<K, V, E, S> map, int initialCapacity, int maxSegmentSize) {
      this.map = map;
      this.maxSegmentSize = maxSegmentSize;
      initTable(newEntryArray(initialCapacity));
    }

    /**
     * Returns {@code this} up-casted to the specific {@link Segment} implementation type {@code S}.
     *

            

Reported by PMD.

Overridable method 'nextInChain' called during object construction
Error

Line: 2521

                  HashIterator() {
      nextSegmentIndex = segments.length - 1;
      nextTableIndex = -1;
      advance();
    }

    @Override
    public abstract T next();


            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1060

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1060

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1060

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1060

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

Avoid reassigning parameters such as 'h'
Design

Line: 1060

                 *
   * @param h hash code
   */
  static int rehash(int h) {
    // Spread bits to regularize both segment and index locations,
    // using variant of single-word Wang/Jenkins hash.
    // TODO(kevinb): use Hashing/move this to Hashing?
    h += (h << 15) ^ 0xffffcd7d;
    h ^= (h >>> 10);

            

Reported by PMD.

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

Line: 15

               * the License.
 */

package com.google.common.collect;

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

import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

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.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkRemove;

import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

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

Line: 15

               * the License.
 */

package com.google.common.collect;

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

import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

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

Line: 49

              
/** @author Gregory Kick */
@GwtCompatible(emulated = true)
public class ContiguousSetTest extends TestCase {
  private static final DiscreteDomain<Integer> NOT_EQUAL_TO_INTEGERS =
      new DiscreteDomain<Integer>() {
        @Override
        public Integer next(Integer value) {
          return integers().next(value);

            

Reported by PMD.

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

Line: 54

                    new DiscreteDomain<Integer>() {
        @Override
        public Integer next(Integer value) {
          return integers().next(value);
        }

        @Override
        public Integer previous(Integer value) {
          return integers().previous(value);

            

Reported by PMD.

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

Line: 59

              
        @Override
        public Integer previous(Integer value) {
          return integers().previous(value);
        }

        @Override
        public long distance(Integer start, Integer end) {
          return integers().distance(start, end);

            

Reported by PMD.

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

Line: 64

              
        @Override
        public long distance(Integer start, Integer end) {
          return integers().distance(start, end);
        }

        @Override
        public Integer minValue() {
          return integers().minValue();

            

Reported by PMD.

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

Line: 69

              
        @Override
        public Integer minValue() {
          return integers().minValue();
        }

        @Override
        public Integer maxValue() {
          return integers().maxValue();

            

Reported by PMD.

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

Line: 74

              
        @Override
        public Integer maxValue() {
          return integers().maxValue();
        }
      };

  public void testInvalidIntRange() {
    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: 78

                      }
      };

  public void testInvalidIntRange() {
    try {
      ContiguousSet.closed(2, 1);
      fail();
    } catch (IllegalArgumentException expected) {
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 81

                public void testInvalidIntRange() {
    try {
      ContiguousSet.closed(2, 1);
      fail();
    } catch (IllegalArgumentException expected) {
    }
    try {
      ContiguousSet.closedOpen(2, 1);
      fail();

            

Reported by PMD.

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

Line: 81

                public void testInvalidIntRange() {
    try {
      ContiguousSet.closed(2, 1);
      fail();
    } catch (IllegalArgumentException expected) {
    }
    try {
      ContiguousSet.closedOpen(2, 1);
      fail();

            

Reported by PMD.

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

Line: 86

                  }
    try {
      ContiguousSet.closedOpen(2, 1);
      fail();
    } catch (IllegalArgumentException expected) {
    }
  }

  public void testInvalidLongRange() {

            

Reported by PMD.

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

Line: 465

                      new WithExceptionalConstructor("whatever");

    public WithExceptionalConstructor() {
      throw new RuntimeException();
    }

    private WithExceptionalConstructor(String unused) {}
  }


            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

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

import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

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

import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;

            

Reported by PMD.

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

Line: 140

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

  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));

            

Reported by PMD.

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

Line: 142

               */
public class ArbitraryInstancesTest extends TestCase {

  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));

            

Reported by PMD.

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

Line: 142

               */
public class ArbitraryInstancesTest extends TestCase {

  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 143

              public class ArbitraryInstancesTest extends TestCase {

  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 144

              
  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(byte.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 145

                public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(byte.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(Byte.class));

            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 145

                public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(byte.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(Byte.class));

            

Reported by PMD.

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

Line: 49

              
/** @author Gregory Kick */
@GwtCompatible(emulated = true)
public class ContiguousSetTest extends TestCase {
  private static final DiscreteDomain<Integer> NOT_EQUAL_TO_INTEGERS =
      new DiscreteDomain<Integer>() {
        @Override
        public Integer next(Integer value) {
          return integers().next(value);

            

Reported by PMD.

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

Line: 54

                    new DiscreteDomain<Integer>() {
        @Override
        public Integer next(Integer value) {
          return integers().next(value);
        }

        @Override
        public Integer previous(Integer value) {
          return integers().previous(value);

            

Reported by PMD.

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

Line: 59

              
        @Override
        public Integer previous(Integer value) {
          return integers().previous(value);
        }

        @Override
        public long distance(Integer start, Integer end) {
          return integers().distance(start, end);

            

Reported by PMD.

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

Line: 64

              
        @Override
        public long distance(Integer start, Integer end) {
          return integers().distance(start, end);
        }

        @Override
        public Integer minValue() {
          return integers().minValue();

            

Reported by PMD.

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

Line: 69

              
        @Override
        public Integer minValue() {
          return integers().minValue();
        }

        @Override
        public Integer maxValue() {
          return integers().maxValue();

            

Reported by PMD.

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

Line: 74

              
        @Override
        public Integer maxValue() {
          return integers().maxValue();
        }
      };

  public void testInvalidIntRange() {
    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: 78

                      }
      };

  public void testInvalidIntRange() {
    try {
      ContiguousSet.closed(2, 1);
      fail();
    } catch (IllegalArgumentException expected) {
    }

            

Reported by PMD.

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

Line: 81

                public void testInvalidIntRange() {
    try {
      ContiguousSet.closed(2, 1);
      fail();
    } catch (IllegalArgumentException expected) {
    }
    try {
      ContiguousSet.closedOpen(2, 1);
      fail();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 81

                public void testInvalidIntRange() {
    try {
      ContiguousSet.closed(2, 1);
      fail();
    } catch (IllegalArgumentException expected) {
    }
    try {
      ContiguousSet.closedOpen(2, 1);
      fail();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 86

                  }
    try {
      ContiguousSet.closedOpen(2, 1);
      fail();
    } catch (IllegalArgumentException expected) {
    }
  }

  public void testInvalidLongRange() {

            

Reported by PMD.

guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java
280 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.graph;

import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
import static com.google.common.graph.TestUtil.assertEdgeNotInGraphErrorMessage;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;

            

Reported by PMD.

The class 'AbstractStandardDirectedNetworkTest' has a total cyclomatic complexity of 85 (highest 5).
Design

Line: 36

              /**
 * Abstract base class for testing directed {@link Network} implementations defined in this package.
 */
public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetworkTest {

  @After
  public void validateSourceAndTarget() {
    for (Integer node : network.nodes()) {
      for (String inEdge : network.inEdges(node)) {

            

Reported by PMD.

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

Line: 36

              /**
 * Abstract base class for testing directed {@link Network} implementations defined in this package.
 */
public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetworkTest {

  @After
  public void validateSourceAndTarget() {
    for (Integer node : network.nodes()) {
      for (String inEdge : network.inEdges(node)) {

            

Reported by PMD.

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

Line: 43

                  for (Integer node : network.nodes()) {
      for (String inEdge : network.inEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(inEdge);
        assertThat(endpointPair.source()).isEqualTo(endpointPair.adjacentNode(node));
        assertThat(endpointPair.target()).isEqualTo(node);
      }

      for (String outEdge : network.outEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge);

            

Reported by PMD.

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

Line: 43

                  for (Integer node : network.nodes()) {
      for (String inEdge : network.inEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(inEdge);
        assertThat(endpointPair.source()).isEqualTo(endpointPair.adjacentNode(node));
        assertThat(endpointPair.target()).isEqualTo(node);
      }

      for (String outEdge : network.outEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge);

            

Reported by PMD.

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

Line: 43

                  for (Integer node : network.nodes()) {
      for (String inEdge : network.inEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(inEdge);
        assertThat(endpointPair.source()).isEqualTo(endpointPair.adjacentNode(node));
        assertThat(endpointPair.target()).isEqualTo(node);
      }

      for (String outEdge : network.outEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge);

            

Reported by PMD.

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

Line: 44

                    for (String inEdge : network.inEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(inEdge);
        assertThat(endpointPair.source()).isEqualTo(endpointPair.adjacentNode(node));
        assertThat(endpointPair.target()).isEqualTo(node);
      }

      for (String outEdge : network.outEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge);
        assertThat(endpointPair.source()).isEqualTo(node);

            

Reported by PMD.

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

Line: 44

                    for (String inEdge : network.inEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(inEdge);
        assertThat(endpointPair.source()).isEqualTo(endpointPair.adjacentNode(node));
        assertThat(endpointPair.target()).isEqualTo(node);
      }

      for (String outEdge : network.outEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge);
        assertThat(endpointPair.source()).isEqualTo(node);

            

Reported by PMD.

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

Line: 49

              
      for (String outEdge : network.outEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge);
        assertThat(endpointPair.source()).isEqualTo(node);
        assertThat(endpointPair.target()).isEqualTo(endpointPair.adjacentNode(node));
      }

      for (Integer adjacentNode : network.adjacentNodes(node)) {
        Set<String> edges = network.edgesConnecting(node, adjacentNode);

            

Reported by PMD.

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

Line: 49

              
      for (String outEdge : network.outEdges(node)) {
        EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge);
        assertThat(endpointPair.source()).isEqualTo(node);
        assertThat(endpointPair.target()).isEqualTo(endpointPair.adjacentNode(node));
      }

      for (Integer adjacentNode : network.adjacentNodes(node)) {
        Set<String> edges = network.edgesConnecting(node, adjacentNode);

            

Reported by PMD.

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

Line: 457

                      new WithExceptionalConstructor("whatever");

    public WithExceptionalConstructor() {
      throw new RuntimeException();
    }

    private WithExceptionalConstructor(String unused) {}
  }


            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

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

import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

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

import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;

            

Reported by PMD.

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

Line: 136

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

  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));

            

Reported by PMD.

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

Line: 138

               */
public class ArbitraryInstancesTest extends TestCase {

  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));

            

Reported by PMD.

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

Line: 138

               */
public class ArbitraryInstancesTest extends TestCase {

  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 139

              public class ArbitraryInstancesTest extends TestCase {

  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 140

              
  public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(byte.class));

            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 141

                public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(byte.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(Byte.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 141

                public void testGet_primitives() {
    assertNull(ArbitraryInstances.get(void.class));
    assertNull(ArbitraryInstances.get(Void.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(boolean.class));
    assertEquals(Boolean.FALSE, ArbitraryInstances.get(Boolean.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(char.class));
    assertEquals(Character.valueOf('\0'), ArbitraryInstances.get(Character.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(byte.class));
    assertEquals(Byte.valueOf((byte) 0), ArbitraryInstances.get(Byte.class));

            

Reported by PMD.