The following issues were found

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

Line: 652

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

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.cache;

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

            

Reported by PMD.

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

Line: 51

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

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

    LoadingCache<String, Integer> cache =

            

Reported by PMD.

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

Line: 51

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

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

    LoadingCache<String, Integer> cache =

            

Reported by PMD.

The class 'CacheBuilderTest' has a total cyclomatic complexity of 86 (highest 6).
Design

Line: 51

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

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

    LoadingCache<String, Integer> cache =

            

Reported by PMD.

Possible God Class (WMC=86, ATFD=36, TCC=0.000%)
Design

Line: 51

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

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

    LoadingCache<String, Integer> cache =

            

Reported by PMD.

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

Line: 51

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

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

    LoadingCache<String, Integer> cache =

            

Reported by PMD.

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

Line: 53

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

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

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


            

Reported by PMD.

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

Line: 53

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

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

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


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 59

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

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

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

            

Reported by PMD.

guava-tests/test/com/google/common/io/MoreFilesTest.java
276 issues
Possible God Class (WMC=53, ATFD=171, TCC=4.359%)
Design

Line: 57

               * @author Colin Decker
 */

public class MoreFilesTest extends TestCase {

  public static TestSuite suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        ByteSourceTester.tests(

            

Reported by PMD.

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

Line: 57

               * @author Colin Decker
 */

public class MoreFilesTest extends TestCase {

  public static TestSuite suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        ByteSourceTester.tests(

            

Reported by PMD.

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

Line: 90

                private static final FileSystem FS = FileSystems.getDefault();

  private static Path root() {
    return FS.getRootDirectories().iterator().next();
  }

  private Path tempDir;

  @Override

            

Reported by PMD.

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

Line: 90

                private static final FileSystem FS = FileSystems.getDefault();

  private static Path root() {
    return FS.getRootDirectories().iterator().next();
  }

  private Path tempDir;

  @Override

            

Reported by PMD.

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

Line: 93

                  return FS.getRootDirectories().iterator().next();
  }

  private Path tempDir;

  @Override
  protected void setUp() throws Exception {
    tempDir = Files.createTempDirectory("MoreFilesTest");
  }

            

Reported by PMD.

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

Line: 95

              
  private Path tempDir;

  @Override
  protected void setUp() throws Exception {
    tempDir = Files.createTempDirectory("MoreFilesTest");
  }

  @Override

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 100

                  tempDir = Files.createTempDirectory("MoreFilesTest");
  }

  @Override
  protected void tearDown() throws Exception {
    if (tempDir != null) {
      // delete tempDir and its contents
      Files.walkFileTree(
          tempDir,

            

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

                  return Files.createTempFile(tempDir, "test", ".test");
  }

  public void testByteSource_size_ofDirectory() throws IOException {
    try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
      Path dir = fs.getPath("dir");
      Files.createDirectory(dir);

      ByteSource source = MoreFiles.asByteSource(dir);

            

Reported by PMD.

The String literal 'dir' appears 10 times in this file; the first occurrence is on line 133
Error

Line: 133

              
  public void testByteSource_size_ofDirectory() throws IOException {
    try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
      Path dir = fs.getPath("dir");
      Files.createDirectory(dir);

      ByteSource source = MoreFiles.asByteSource(dir);

      assertThat(source.sizeIfKnown()).isAbsent();

            

Reported by PMD.

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

Line: 138

              
      ByteSource source = MoreFiles.asByteSource(dir);

      assertThat(source.sizeIfKnown()).isAbsent();

      try {
        source.size();
        fail();
      } catch (IOException expected) {

            

Reported by PMD.

android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java
275 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.

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

Line: 35

              /**
 * 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.

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

Line: 35

              /**
 * 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 (object not created locally)
Design

Line: 42

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

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

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

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

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

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

              
      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.

guava/src/com/google/common/collect/Maps.java
273 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.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.compose;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.compose;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.compose;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;

            

Reported by PMD.

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

Line: 92

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

The class 'Maps' has a total cyclomatic complexity of 137 (highest 9).
Design

Line: 92

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

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

Line: 92

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

Avoid really long classes.
Design

Line: 92

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

Possible God Class (WMC=137, ATFD=41, TCC=0.000%)
Design

Line: 92

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

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

Line: 92

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

The String literal 'unchecked' appears 14 times in this file; the first occurrence is on line 112
Error

Line: 112

                  };
  }

  @SuppressWarnings("unchecked")
  static <K extends @Nullable Object> Function<Entry<K, ?>, K> keyFunction() {
    return (Function) EntryFunction.KEY;
  }

  @SuppressWarnings("unchecked")

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
270 issues
Possible God Class (WMC=56, ATFD=18, TCC=8.300%)
Design

Line: 38

               * @author Louis Wasserman
 */
@GwtIncompatible // ImmutableRangeSet
public class ImmutableRangeSetTest extends AbstractRangeSetTest {

  static final class ImmutableRangeSetIntegerAsSetGenerator implements TestSetGenerator<Integer> {
    @Override
    public SampleElements<Integer> samples() {
      return new SampleElements<>(1, 4, 3, 2, 5);

            

Reported by PMD.

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

Line: 38

               * @author Louis Wasserman
 */
@GwtIncompatible // ImmutableRangeSet
public class ImmutableRangeSetTest extends AbstractRangeSetTest {

  static final class ImmutableRangeSetIntegerAsSetGenerator implements TestSetGenerator<Integer> {
    @Override
    public SampleElements<Integer> samples() {
      return new SampleElements<>(1, 4, 3, 2, 5);

            

Reported by PMD.

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

Line: 38

               * @author Louis Wasserman
 */
@GwtIncompatible // ImmutableRangeSet
public class ImmutableRangeSetTest extends AbstractRangeSetTest {

  static final class ImmutableRangeSetIntegerAsSetGenerator implements TestSetGenerator<Integer> {
    @Override
    public SampleElements<Integer> samples() {
      return new SampleElements<>(1, 4, 3, 2, 5);

            

Reported by PMD.

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

Line: 38

               * @author Louis Wasserman
 */
@GwtIncompatible // ImmutableRangeSet
public class ImmutableRangeSetTest extends AbstractRangeSetTest {

  static final class ImmutableRangeSetIntegerAsSetGenerator implements TestSetGenerator<Integer> {
    @Override
    public SampleElements<Integer> samples() {
      return new SampleElements<>(1, 4, 3, 2, 5);

            

Reported by PMD.

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

Line: 53

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

    @Override
    public Set<Integer> create(Object... elements) {
      ImmutableRangeSet.Builder<Integer> builder = ImmutableRangeSet.builder();

            

Reported by PMD.

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

Line: 63

                      Integer i = (Integer) o;
        builder.add(Range.singleton(i));
      }
      return builder.build().asSet(DiscreteDomain.integers());
    }
  }

  static final class ImmutableRangeSetBigIntegerAsSetGenerator
      implements TestSetGenerator<BigInteger> {

            

Reported by PMD.

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

Line: 86

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

    @Override
    public Set<BigInteger> create(Object... elements) {
      ImmutableRangeSet.Builder<BigInteger> builder = ImmutableRangeSet.builder();

            

Reported by PMD.

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

Line: 94

                    ImmutableRangeSet.Builder<BigInteger> builder = ImmutableRangeSet.builder();
      for (Object o : elements) {
        BigInteger i = (BigInteger) o;
        builder.add(Range.closedOpen(i, i.add(BigInteger.ONE)));
      }
      return builder.build().asSet(DiscreteDomain.bigIntegers());
    }
  }


            

Reported by PMD.

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

Line: 96

                      BigInteger i = (BigInteger) o;
        builder.add(Range.closedOpen(i, i.add(BigInteger.ONE)));
      }
      return builder.build().asSet(DiscreteDomain.bigIntegers());
    }
  }

  public static Test suite() {
    TestSuite suite = new TestSuite();

            

Reported by PMD.

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

Line: 100

                  }
  }

  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableRangeSetTest.class);
    suite.addTest(
        NavigableSetTestSuiteBuilder.using(new ImmutableRangeSetIntegerAsSetGenerator())
            .named("ImmutableRangeSet.asSet[DiscreteDomain.integers[]]")

            

Reported by PMD.

android/guava/src/com/google/common/collect/Maps.java
268 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.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.compose;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.compose;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.compose;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;

            

Reported by PMD.

Possible God Class (WMC=135, ATFD=41, TCC=0.000%)
Design

Line: 85

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

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

Line: 85

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

The class 'Maps' has a total cyclomatic complexity of 135 (highest 9).
Design

Line: 85

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

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

Line: 85

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

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

Line: 85

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

Avoid really long classes.
Design

Line: 85

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

  private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
    KEY {
      @Override

            

Reported by PMD.

The String literal 'unchecked' appears 14 times in this file; the first occurrence is on line 105
Error

Line: 105

                  };
  }

  @SuppressWarnings("unchecked")
  static <K extends @Nullable Object> Function<Entry<K, ?>, K> keyFunction() {
    return (Function) EntryFunction.KEY;
  }

  @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 46

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

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

            

Reported by PMD.

Possible God Class (WMC=50, ATFD=32, TCC=0.000%)
Design

Line: 46

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

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

            

Reported by PMD.

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

Line: 49

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

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

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

            

Reported by PMD.

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

Line: 50

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

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

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

            

Reported by PMD.

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

Line: 50

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

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

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

            

Reported by PMD.

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

Line: 53

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

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

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

            

Reported by PMD.

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

Line: 54

                }

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

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

            

Reported by PMD.

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

Line: 54

                }

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

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

            

Reported by PMD.

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

Line: 57

                  assertThat(ImmutableDoubleArray.of(0).asList()).containsExactly(0.0);
  }

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

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

            

Reported by PMD.

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

Line: 58

                }

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

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

            

Reported by PMD.

guava-tests/test/com/google/common/collect/ImmutableMapTest.java
267 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.collect.testing.Helpers.mapEntry;
import static com.google.common.testing.SerializableTester.reserialize;
import static com.google.common.truth.Truth.assertThat;


            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.collect.testing.Helpers.mapEntry;
import static com.google.common.testing.SerializableTester.reserialize;
import static com.google.common.truth.Truth.assertThat;


            

Reported by PMD.

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

Line: 80

               * @author Jesse Wilson
 */
@GwtCompatible(emulated = true)
public class ImmutableMapTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMapTest.class);

            

Reported by PMD.

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

Line: 82

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

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMapTest.class);
    suite.addTestSuite(FloodingTest.class);


            

Reported by PMD.

Avoid really long methods.
Design

Line: 83

              public class ImmutableMapTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMapTest.class);
    suite.addTestSuite(FloodingTest.class);

    suite.addTest(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 216

                  protected void assertMoreInvariants(Map<K, V> map) {
      // TODO: can these be moved to MapInterfaceTest?
      for (Entry<K, V> entry : map.entrySet()) {
        assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
      }

      assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
      assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
      assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 219

                      assertEquals(entry.getKey() + "=" + entry.getValue(), entry.toString());
      }

      assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
      assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
      assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
      assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());

      assertEquals(MinimalSet.from(map.entrySet()), map.entrySet());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 220

                    }

      assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
      assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
      assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
      assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());

      assertEquals(MinimalSet.from(map.entrySet()), map.entrySet());
      assertEquals(Sets.newHashSet(map.keySet()), map.keySet());

            

Reported by PMD.

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

Line: 220

                    }

      assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
      assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
      assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
      assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());

      assertEquals(MinimalSet.from(map.entrySet()), map.entrySet());
      assertEquals(Sets.newHashSet(map.keySet()), map.keySet());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 221

              
      assertEquals("{" + joiner.join(map.entrySet()) + "}", map.toString());
      assertEquals("[" + joiner.join(map.entrySet()) + "]", map.entrySet().toString());
      assertEquals("[" + joiner.join(map.keySet()) + "]", map.keySet().toString());
      assertEquals("[" + joiner.join(map.values()) + "]", map.values().toString());

      assertEquals(MinimalSet.from(map.entrySet()), map.entrySet());
      assertEquals(Sets.newHashSet(map.keySet()), map.keySet());
    }

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.math;

import static com.google.common.math.MathTesting.ALL_BIGINTEGER_CANDIDATES;
import static com.google.common.math.MathTesting.ALL_ROUNDING_MODES;
import static com.google.common.math.MathTesting.ALL_SAFE_ROUNDING_MODES;
import static com.google.common.math.MathTesting.NEGATIVE_BIGINTEGER_CANDIDATES;

            

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

import static com.google.common.math.MathTesting.ALL_BIGINTEGER_CANDIDATES;
import static com.google.common.math.MathTesting.ALL_ROUNDING_MODES;
import static com.google.common.math.MathTesting.ALL_SAFE_ROUNDING_MODES;
import static com.google.common.math.MathTesting.NEGATIVE_BIGINTEGER_CANDIDATES;

            

Reported by PMD.

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

Line: 58

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);

            

Reported by PMD.

Possible God Class (WMC=141, ATFD=47, TCC=0.000%)
Design

Line: 58

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);

            

Reported by PMD.

The class 'BigIntegerMathTest' has a total cyclomatic complexity of 141 (highest 11).
Design

Line: 58

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 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: 59

               */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);

            

Reported by PMD.

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

Line: 59

               */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 62

                public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);
    }
  }


            

Reported by PMD.

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

Line: 63

                  for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);
    }
  }

  public void testFloorPowerOfTwo() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                  for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);
    }
  }

  public void testFloorPowerOfTwo() {

            

Reported by PMD.

android/guava-tests/test/com/google/common/math/BigIntegerMathTest.java
267 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.math;

import static com.google.common.math.MathTesting.ALL_BIGINTEGER_CANDIDATES;
import static com.google.common.math.MathTesting.ALL_ROUNDING_MODES;
import static com.google.common.math.MathTesting.ALL_SAFE_ROUNDING_MODES;
import static com.google.common.math.MathTesting.NEGATIVE_BIGINTEGER_CANDIDATES;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.math;

import static com.google.common.math.MathTesting.ALL_BIGINTEGER_CANDIDATES;
import static com.google.common.math.MathTesting.ALL_ROUNDING_MODES;
import static com.google.common.math.MathTesting.ALL_SAFE_ROUNDING_MODES;
import static com.google.common.math.MathTesting.NEGATIVE_BIGINTEGER_CANDIDATES;

            

Reported by PMD.

The class 'BigIntegerMathTest' has a total cyclomatic complexity of 141 (highest 11).
Design

Line: 58

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);

            

Reported by PMD.

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

Line: 58

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);

            

Reported by PMD.

Possible God Class (WMC=141, ATFD=47, TCC=0.000%)
Design

Line: 58

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);

            

Reported by PMD.

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

Line: 59

               */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 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: 59

               */
@GwtCompatible(emulated = true)
public class BigIntegerMathTest extends TestCase {
  public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 62

                public void testCeilingPowerOfTwo() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);
    }
  }


            

Reported by PMD.

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

Line: 63

                  for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);
    }
  }

  public void testFloorPowerOfTwo() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                  for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      BigInteger result = BigIntegerMath.ceilingPowerOfTwo(x);
      assertTrue(BigIntegerMath.isPowerOfTwo(result));
      assertTrue(result.compareTo(x) >= 0);
      assertTrue(result.compareTo(x.add(x)) < 0);
    }
  }

  public void testFloorPowerOfTwo() {

            

Reported by PMD.