The following issues were found

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.

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

Line: 45

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

  public void testOf0() {
    assertThat(ImmutableLongArray.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 ImmutableLongArrayTest extends TestCase {
  // Test all creation paths very lazily: by assuming asList() works

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

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

            

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(ImmutableLongArray.of().asList()).isEmpty();
  }

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

            

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(ImmutableLongArray.of().asList()).isEmpty();
  }

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

            

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(ImmutableLongArray.of().asList()).isEmpty();
  }

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

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

            

Reported by PMD.

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

Line: 53

                }

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

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

            

Reported by PMD.

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

Line: 53

                }

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

  public void testOf2() {
    assertThat(ImmutableLongArray.of(0, 1).asList()).containsExactly(0L, 1L).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(ImmutableLongArray.of(0).asList()).containsExactly(0L);
  }

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

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

            

Reported by PMD.

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

Line: 57

                }

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

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 57

                }

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

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

            

Reported by PMD.

guava/src/com/google/common/collect/Synchronized.java
230 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.checkNotNull;

import com.google.common.annotations.GwtCompatible;
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: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;

            

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

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 76

               * anyway, so we just need to get by without the annotations here until Kotlin better understands
 * our other nullness annotations.
 */
final class Synchronized {
  private Synchronized() {}

  static class SynchronizedObject implements Serializable {
    final Object delegate;
    final Object mutex;

            

Reported by PMD.

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

Line: 76

               * anyway, so we just need to get by without the annotations here until Kotlin better understands
 * our other nullness annotations.
 */
final class Synchronized {
  private Synchronized() {}

  static class SynchronizedObject implements Serializable {
    final Object delegate;
    final Object mutex;

            

Reported by PMD.

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

Line: 80

                private Synchronized() {}

  static class SynchronizedObject implements Serializable {
    final Object delegate;
    final Object mutex;

    SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
      this.delegate = checkNotNull(delegate);
      this.mutex = (mutex == null) ? this : mutex;

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 80

                private Synchronized() {}

  static class SynchronizedObject implements Serializable {
    final Object delegate;
    final Object mutex;

    SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
      this.delegate = checkNotNull(delegate);
      this.mutex = (mutex == null) ? this : mutex;

            

Reported by PMD.

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

Line: 81

              
  static class SynchronizedObject implements Serializable {
    final Object delegate;
    final Object mutex;

    SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
      this.delegate = checkNotNull(delegate);
      this.mutex = (mutex == null) ? this : mutex;
    }

            

Reported by PMD.

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

Line: 124

              
  @VisibleForTesting
  static class SynchronizedCollection<E extends @Nullable Object> extends SynchronizedObject
      implements Collection<E> {
    private SynchronizedCollection(Collection<E> delegate, @CheckForNull Object mutex) {
      super(delegate, mutex);
    }

    @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 129

                    super(delegate, mutex);
    }

    @SuppressWarnings("unchecked")
    @Override
    Collection<E> delegate() {
      return (Collection<E>) super.delegate();
    }


            

Reported by PMD.

guava-tests/test/com/google/common/math/LongMathTest.java
229 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_LONG_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.EXPONENTS;

            

Reported by PMD.

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

Line: 50

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

            

Reported by PMD.

Possible God Class (WMC=229, ATFD=58, TCC=0.034%)
Design

Line: 50

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

            

Reported by PMD.

The class 'LongMathTest' has a total cyclomatic complexity of 229 (highest 8).
Design

Line: 50

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 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: 51

               */
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }


            

Reported by PMD.

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

Line: 52

              @GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

  public void testCeilingPowerOfTwo() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

              public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

  public void testCeilingPowerOfTwo() {
    for (long x : POSITIVE_LONG_CANDIDATES) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 54

                @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

  public void testCeilingPowerOfTwo() {
    for (long x : POSITIVE_LONG_CANDIDATES) {
      BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));

            

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

                  assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

  public void testCeilingPowerOfTwo() {
    for (long x : POSITIVE_LONG_CANDIDATES) {
      BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
      if (fitsInLong(expectedResult)) {
        assertEquals(expectedResult.longValue(), LongMath.ceilingPowerOfTwo(x));
      } else {

            

Reported by PMD.

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

Line: 61

                  for (long x : POSITIVE_LONG_CANDIDATES) {
      BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
      if (fitsInLong(expectedResult)) {
        assertEquals(expectedResult.longValue(), LongMath.ceilingPowerOfTwo(x));
      } else {
        try {
          LongMath.ceilingPowerOfTwo(x);
          fail("Expected ArithmeticException");
        } catch (ArithmeticException expected) {

            

Reported by PMD.

android/guava-tests/test/com/google/common/math/LongMathTest.java
229 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_LONG_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.EXPONENTS;

            

Reported by PMD.

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

Line: 50

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

            

Reported by PMD.

Possible God Class (WMC=229, ATFD=58, TCC=0.034%)
Design

Line: 50

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

            

Reported by PMD.

The class 'LongMathTest' has a total cyclomatic complexity of 229 (highest 8).
Design

Line: 50

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 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: 51

               */
@GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }


            

Reported by PMD.

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

Line: 52

              @GwtCompatible(emulated = true)
public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

  public void testCeilingPowerOfTwo() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

              public class LongMathTest extends TestCase {
  @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

  public void testCeilingPowerOfTwo() {
    for (long x : POSITIVE_LONG_CANDIDATES) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 54

                @SuppressWarnings("ConstantOverflow")
  public void testMaxSignedPowerOfTwo() {
    assertTrue(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO));
    assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

  public void testCeilingPowerOfTwo() {
    for (long x : POSITIVE_LONG_CANDIDATES) {
      BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));

            

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

                  assertFalse(LongMath.isPowerOfTwo(LongMath.MAX_SIGNED_POWER_OF_TWO * 2));
  }

  public void testCeilingPowerOfTwo() {
    for (long x : POSITIVE_LONG_CANDIDATES) {
      BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
      if (fitsInLong(expectedResult)) {
        assertEquals(expectedResult.longValue(), LongMath.ceilingPowerOfTwo(x));
      } else {

            

Reported by PMD.

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

Line: 61

                  for (long x : POSITIVE_LONG_CANDIDATES) {
      BigInteger expectedResult = BigIntegerMath.ceilingPowerOfTwo(BigInteger.valueOf(x));
      if (fitsInLong(expectedResult)) {
        assertEquals(expectedResult.longValue(), LongMath.ceilingPowerOfTwo(x));
      } else {
        try {
          LongMath.ceilingPowerOfTwo(x);
          fail("Expected ArithmeticException");
        } catch (ArithmeticException expected) {

            

Reported by PMD.

guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java
229 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.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
import static org.junit.Assert.assertTrue;

            

Reported by PMD.

Possible God Class (WMC=70, ATFD=7, TCC=0.490%)
Design

Line: 35

               * Abstract base class for testing undirected {@link Network} implementations defined in this
 * package.
 */
public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetworkTest {
  private static final EndpointPair<Integer> ENDPOINTS_N1N2 = EndpointPair.ordered(N1, N2);
  private static final EndpointPair<Integer> ENDPOINTS_N2N1 = EndpointPair.ordered(N2, N1);

  @After
  public void validateUndirectedEdges() {

            

Reported by PMD.

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

Line: 35

               * Abstract base class for testing undirected {@link Network} implementations defined in this
 * package.
 */
public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetworkTest {
  private static final EndpointPair<Integer> ENDPOINTS_N1N2 = EndpointPair.ordered(N1, N2);
  private static final EndpointPair<Integer> ENDPOINTS_N2N1 = EndpointPair.ordered(N2, N1);

  @After
  public void validateUndirectedEdges() {

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 42

                @After
  public void validateUndirectedEdges() {
    for (Integer node : network.nodes()) {
      new EqualsTester()
          .addEqualityGroup(
              network.inEdges(node), network.outEdges(node), network.incidentEdges(node))
          .testEquals();
      new EqualsTester()
          .addEqualityGroup(

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 46

                        .addEqualityGroup(
              network.inEdges(node), network.outEdges(node), network.incidentEdges(node))
          .testEquals();
      new EqualsTester()
          .addEqualityGroup(
              network.predecessors(node), network.successors(node), network.adjacentNodes(node))
          .testEquals();

      for (Integer adjacentNode : network.adjacentNodes(node)) {

            

Reported by PMD.

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

Line: 52

                        .testEquals();

      for (Integer adjacentNode : network.adjacentNodes(node)) {
        assertThat(network.edgesConnecting(node, adjacentNode))
            .containsExactlyElementsIn(network.edgesConnecting(adjacentNode, node));
      }
    }
  }


            

Reported by PMD.

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

Line: 67

                    fail(ERROR_MODIFIABLE_COLLECTION);
    } catch (UnsupportedOperationException e) {
      addNode(N1);
      assertThat(network.nodes()).containsExactlyElementsIn(nodes);
    }
  }

  @Override
  @Test

            

Reported by PMD.

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

Line: 80

                    fail(ERROR_MODIFIABLE_COLLECTION);
    } catch (UnsupportedOperationException e) {
      addEdge(N1, N2, E12);
      assertThat(network.edges()).containsExactlyElementsIn(edges);
    }
  }

  @Override
  @Test

            

Reported by PMD.

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

Line: 94

                    fail(ERROR_MODIFIABLE_COLLECTION);
    } catch (UnsupportedOperationException e) {
      addEdge(N1, N2, E12);
      assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
    }
  }

  @Override
  @Test

            

Reported by PMD.

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

Line: 108

                    fail(ERROR_MODIFIABLE_COLLECTION);
    } catch (UnsupportedOperationException e) {
      addEdge(N1, N2, E12);
      assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
    }
  }

  @Override
  public void adjacentEdges_checkReturnedSetMutability() {

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
228 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 29

               * Pat Fisher, Mike Judd.
 */

package com.google.common.util.concurrent;

import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.MoreExecutors.invokeAnyImpl;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 29

               * Pat Fisher, Mike Judd.
 */

package com.google.common.util.concurrent;

import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.MoreExecutors.invokeAnyImpl;

            

Reported by PMD.

Possible God Class (WMC=57, ATFD=129, TCC=1.951%)
Design

Line: 83

               *
 * @author Kyle Littlefield (klittle)
 */
public class MoreExecutorsTest extends JSR166TestCase {

  private static final Runnable EMPTY_RUNNABLE =
      new Runnable() {
        @Override
        public void run() {}

            

Reported by PMD.

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

Line: 83

               *
 * @author Kyle Littlefield (klittle)
 */
public class MoreExecutorsTest extends JSR166TestCase {

  private static final Runnable EMPTY_RUNNABLE =
      new Runnable() {
        @Override
        public void run() {}

            

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

                    };


  public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
    final ListeningExecutorService executor = newDirectExecutorService();
    final ThreadLocal<Integer> threadLocalCount =
        new ThreadLocal<Integer>() {
          @Override
          protected Integer initialValue() {

            

Reported by PMD.

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

Line: 92

                    };


  public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
    final ListeningExecutorService executor = newDirectExecutorService();
    final ThreadLocal<Integer> threadLocalCount =
        new ThreadLocal<Integer>() {
          @Override
          protected Integer initialValue() {

            

Reported by PMD.

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

Line: 117

                            public void run() {
                try {
                  Future<?> future = executor.submit(incrementTask);
                  assertTrue(future.isDone());
                  assertEquals(1, threadLocalCount.get().intValue());
                } catch (Throwable t) {
                  throwableFromOtherThread.set(t);
                }
              }

            

Reported by PMD.

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

Line: 118

                              try {
                  Future<?> future = executor.submit(incrementTask);
                  assertTrue(future.isDone());
                  assertEquals(1, threadLocalCount.get().intValue());
                } catch (Throwable t) {
                  throwableFromOtherThread.set(t);
                }
              }
            });

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 119

                                Future<?> future = executor.submit(incrementTask);
                  assertTrue(future.isDone());
                  assertEquals(1, threadLocalCount.get().intValue());
                } catch (Throwable t) {
                  throwableFromOtherThread.set(t);
                }
              }
            });


            

Reported by PMD.

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

Line: 127

              
    otherThread.start();

    ListenableFuture<?> future = executor.submit(incrementTask);
    assertTrue(future.isDone());
    assertListenerRunImmediately(future);
    assertEquals(1, threadLocalCount.get().intValue());
    otherThread.join(1000);
    assertEquals(Thread.State.TERMINATED, otherThread.getState());

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
228 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 29

               * Pat Fisher, Mike Judd.
 */

package com.google.common.util.concurrent;

import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.MoreExecutors.invokeAnyImpl;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 29

               * Pat Fisher, Mike Judd.
 */

package com.google.common.util.concurrent;

import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.MoreExecutors.invokeAnyImpl;

            

Reported by PMD.

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

Line: 83

               *
 * @author Kyle Littlefield (klittle)
 */
public class MoreExecutorsTest extends JSR166TestCase {

  private static final Runnable EMPTY_RUNNABLE =
      new Runnable() {
        @Override
        public void run() {}

            

Reported by PMD.

Possible God Class (WMC=57, ATFD=129, TCC=1.951%)
Design

Line: 83

               *
 * @author Kyle Littlefield (klittle)
 */
public class MoreExecutorsTest extends JSR166TestCase {

  private static final Runnable EMPTY_RUNNABLE =
      new Runnable() {
        @Override
        public void run() {}

            

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

                    };


  public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
    final ListeningExecutorService executor = newDirectExecutorService();
    final ThreadLocal<Integer> threadLocalCount =
        new ThreadLocal<Integer>() {
          @Override
          protected Integer initialValue() {

            

Reported by PMD.

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

Line: 92

                    };


  public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
    final ListeningExecutorService executor = newDirectExecutorService();
    final ThreadLocal<Integer> threadLocalCount =
        new ThreadLocal<Integer>() {
          @Override
          protected Integer initialValue() {

            

Reported by PMD.

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

Line: 117

                            public void run() {
                try {
                  Future<?> future = executor.submit(incrementTask);
                  assertTrue(future.isDone());
                  assertEquals(1, threadLocalCount.get().intValue());
                } catch (Throwable t) {
                  throwableFromOtherThread.set(t);
                }
              }

            

Reported by PMD.

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

Line: 118

                              try {
                  Future<?> future = executor.submit(incrementTask);
                  assertTrue(future.isDone());
                  assertEquals(1, threadLocalCount.get().intValue());
                } catch (Throwable t) {
                  throwableFromOtherThread.set(t);
                }
              }
            });

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 119

                                Future<?> future = executor.submit(incrementTask);
                  assertTrue(future.isDone());
                  assertEquals(1, threadLocalCount.get().intValue());
                } catch (Throwable t) {
                  throwableFromOtherThread.set(t);
                }
              }
            });


            

Reported by PMD.

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

Line: 127

              
    otherThread.start();

    ListenableFuture<?> future = executor.submit(incrementTask);
    assertTrue(future.isDone());
    assertListenerRunImmediately(future);
    assertEquals(1, threadLocalCount.get().intValue());
    otherThread.join(1000);
    assertEquals(Thread.State.TERMINATED, otherThread.getState());

            

Reported by PMD.

android/guava-tests/test/com/google/common/io/ByteStreamsTest.java
226 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 62

              
    File testFile = createTempFile();
    byte[] dummyData = newPreFilledByteArray(chunkSize);
    try (FileOutputStream fos = new FileOutputStream(testFile)) {
      for (int i = 0; i < 500; i++) {
        fos.write(dummyData);
      }
    }
    try (ReadableByteChannel inChannel = new RandomAccessFile(testFile, "r").getChannel()) {

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.io;

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

import com.google.common.base.Charsets;
import java.io.ByteArrayInputStream;

            

Reported by PMD.

Possible God Class (WMC=78, ATFD=16, TCC=8.023%)
Design

Line: 42

               *
 * @author Chris Nokleberg
 */
public class ByteStreamsTest extends IoTestCase {

  public void testCopyChannel() throws IOException {
    byte[] expected = newPreFilledByteArray(100);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

            

Reported by PMD.

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

Line: 42

               *
 * @author Chris Nokleberg
 */
public class ByteStreamsTest extends IoTestCase {

  public void testCopyChannel() throws IOException {
    byte[] expected = newPreFilledByteArray(100);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

            

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

               */
public class ByteStreamsTest extends IoTestCase {

  public void testCopyChannel() throws IOException {
    byte[] expected = newPreFilledByteArray(100);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

    ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));

            

Reported by PMD.

Ensure that resources like this WritableByteChannel object are closed after use
Error

Line: 47

                public void testCopyChannel() throws IOException {
    byte[] expected = newPreFilledByteArray(100);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

    ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
    ByteStreams.copy(inChannel, outChannel);
    assertThat(out.toByteArray()).isEqualTo(expected);
  }

            

Reported by PMD.

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

Line: 51

              
    ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
    ByteStreams.copy(inChannel, outChannel);
    assertThat(out.toByteArray()).isEqualTo(expected);
  }


  public void testCopyFileChannel() throws IOException {
    final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk 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: 55

                }


  public void testCopyFileChannel() throws IOException {
    final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

    File testFile = createTempFile();

            

Reported by PMD.

Ensure that resources like this WritableByteChannel object are closed after use
Error

Line: 58

                public void testCopyFileChannel() throws IOException {
    final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

    File testFile = createTempFile();
    byte[] dummyData = newPreFilledByteArray(chunkSize);
    try (FileOutputStream fos = new FileOutputStream(testFile)) {
      for (int i = 0; i < 500; i++) {

            

Reported by PMD.

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

Line: 72

                  }
    byte[] actual = out.toByteArray();
    for (int i = 0; i < 500 * chunkSize; i += chunkSize) {
      assertThat(Arrays.copyOfRange(actual, i, i + chunkSize)).isEqualTo(dummyData);
    }
  }

  public void testReadFully() throws IOException {
    byte[] b = new byte[10];

            

Reported by PMD.

guava-tests/test/com/google/common/io/ByteStreamsTest.java
226 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 62

              
    File testFile = createTempFile();
    byte[] dummyData = newPreFilledByteArray(chunkSize);
    try (FileOutputStream fos = new FileOutputStream(testFile)) {
      for (int i = 0; i < 500; i++) {
        fos.write(dummyData);
      }
    }
    try (ReadableByteChannel inChannel = new RandomAccessFile(testFile, "r").getChannel()) {

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.io;

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

import com.google.common.base.Charsets;
import java.io.ByteArrayInputStream;

            

Reported by PMD.

Possible God Class (WMC=78, ATFD=16, TCC=8.023%)
Design

Line: 42

               *
 * @author Chris Nokleberg
 */
public class ByteStreamsTest extends IoTestCase {

  public void testCopyChannel() throws IOException {
    byte[] expected = newPreFilledByteArray(100);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

            

Reported by PMD.

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

Line: 42

               *
 * @author Chris Nokleberg
 */
public class ByteStreamsTest extends IoTestCase {

  public void testCopyChannel() throws IOException {
    byte[] expected = newPreFilledByteArray(100);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

            

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

               */
public class ByteStreamsTest extends IoTestCase {

  public void testCopyChannel() throws IOException {
    byte[] expected = newPreFilledByteArray(100);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

    ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));

            

Reported by PMD.

Ensure that resources like this WritableByteChannel object are closed after use
Error

Line: 47

                public void testCopyChannel() throws IOException {
    byte[] expected = newPreFilledByteArray(100);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

    ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
    ByteStreams.copy(inChannel, outChannel);
    assertThat(out.toByteArray()).isEqualTo(expected);
  }

            

Reported by PMD.

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

Line: 51

              
    ReadableByteChannel inChannel = Channels.newChannel(new ByteArrayInputStream(expected));
    ByteStreams.copy(inChannel, outChannel);
    assertThat(out.toByteArray()).isEqualTo(expected);
  }


  public void testCopyFileChannel() throws IOException {
    final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk 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: 55

                }


  public void testCopyFileChannel() throws IOException {
    final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

    File testFile = createTempFile();

            

Reported by PMD.

Ensure that resources like this WritableByteChannel object are closed after use
Error

Line: 58

                public void testCopyFileChannel() throws IOException {
    final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    WritableByteChannel outChannel = Channels.newChannel(out);

    File testFile = createTempFile();
    byte[] dummyData = newPreFilledByteArray(chunkSize);
    try (FileOutputStream fos = new FileOutputStream(testFile)) {
      for (int i = 0; i < 500; i++) {

            

Reported by PMD.

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

Line: 72

                  }
    byte[] actual = out.toByteArray();
    for (int i = 0; i < 500 * chunkSize; i += chunkSize) {
      assertThat(Arrays.copyOfRange(actual, i, i + chunkSize)).isEqualTo(dummyData);
    }
  }

  public void testReadFully() throws IOException {
    byte[] b = new byte[10];

            

Reported by PMD.