The following issues were found

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.collect.Iterables.unmodifiableIterable;
import static com.google.common.collect.Sets.newHashSet;
import static com.google.common.collect.testing.features.CollectionFeature.ALLOWS_NULL_QUERIES;

            

Reported by PMD.

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.Iterables.getOnlyElement;
import static com.google.common.collect.Iterables.unmodifiableIterable;
import static com.google.common.collect.Sets.newHashSet;
import static com.google.common.collect.testing.features.CollectionFeature.ALLOWS_NULL_QUERIES;

            

Reported by PMD.

This class name ends with Test but contains no test cases
Error

Line: 66

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

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

            

Reported by PMD.

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

Line: 68

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

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        ListTestSuiteBuilder.using(new ImmutableListOfGenerator())
            .named("ImmutableList")

            

Reported by PMD.

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

Line: 115

                  return suite;
  }

  public static class CreationTests extends TestCase {
    public void testCreation_noArgs() {
      List<String> list = ImmutableList.of();
      assertEquals(Collections.emptyList(), list);
    }


            

Reported by PMD.

Possible God Class (WMC=63, ATFD=7, TCC=0.000%)
Design

Line: 115

                  return suite;
  }

  public static class CreationTests extends TestCase {
    public void testCreation_noArgs() {
      List<String> list = ImmutableList.of();
      assertEquals(Collections.emptyList(), list);
    }


            

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

                }

  public static class CreationTests extends TestCase {
    public void testCreation_noArgs() {
      List<String> list = ImmutableList.of();
      assertEquals(Collections.emptyList(), list);
    }

    public void testCreation_oneElement() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 118

                public static class CreationTests extends TestCase {
    public void testCreation_noArgs() {
      List<String> list = ImmutableList.of();
      assertEquals(Collections.emptyList(), list);
    }

    public void testCreation_oneElement() {
      List<String> list = ImmutableList.of("a");
      assertEquals(Collections.singletonList("a"), list);

            

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

                    assertEquals(Collections.emptyList(), list);
    }

    public void testCreation_oneElement() {
      List<String> list = ImmutableList.of("a");
      assertEquals(Collections.singletonList("a"), list);
    }

    public void testCreation_twoElements() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 123

              
    public void testCreation_oneElement() {
      List<String> list = ImmutableList.of("a");
      assertEquals(Collections.singletonList("a"), list);
    }

    public void testCreation_twoElements() {
      List<String> list = ImmutableList.of("a", "b");
      assertEquals(Lists.newArrayList("a", "b"), list);

            

Reported by PMD.

android/guava-tests/test/com/google/common/math/QuantilesTest.java
298 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.Quantiles.median;
import static com.google.common.math.Quantiles.percentiles;
import static com.google.common.math.Quantiles.quartiles;
import static com.google.common.truth.Truth.assertThat;

            

Reported by PMD.

Possible God Class (WMC=88, ATFD=9, TCC=25.355%)
Design

Line: 52

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

  /*
   * Since Quantiles provides a fluent-style API, each test covers a chain of methods resulting in
   * the computation of one or more quantiles (or in an error) rather than individual methods. The
   * tests are divided into three sections:

            

Reported by PMD.

The class 'QuantilesTest' has a total cyclomatic complexity of 88 (highest 4).
Design

Line: 52

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

  /*
   * Since Quantiles provides a fluent-style API, each test covers a chain of methods resulting in
   * the computation of one or more quantiles (or in an error) rather than individual methods. The
   * tests are divided into three sections:

            

Reported by PMD.

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

Line: 52

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

  /*
   * Since Quantiles provides a fluent-style API, each test covers a chain of methods resulting in
   * the computation of one or more quantiles (or in an error) rather than individual methods. The
   * tests are divided into three sections:

            

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

                private static final double SIXTEEN_SQUARES_DECILE_8 = 144.0;
  private static final double SIXTEEN_SQUARES_MAX = 225.0;

  public void testMedian_compute_doubleCollection() {
    assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
        .isWithin(ALLOWED_ERROR)
        .of(SIXTEEN_SQUARES_MEDIAN);
  }


            

Reported by PMD.

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

Line: 126

                private static final double SIXTEEN_SQUARES_MAX = 225.0;

  public void testMedian_compute_doubleCollection() {
    assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
        .isWithin(ALLOWED_ERROR)
        .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {

            

Reported by PMD.

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

Line: 126

                private static final double SIXTEEN_SQUARES_MAX = 225.0;

  public void testMedian_compute_doubleCollection() {
    assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
        .isWithin(ALLOWED_ERROR)
        .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {

            

Reported by PMD.

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

Line: 126

                private static final double SIXTEEN_SQUARES_MAX = 225.0;

  public void testMedian_compute_doubleCollection() {
    assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
        .isWithin(ALLOWED_ERROR)
        .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {

            

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

                      .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {
    double[] dataset = Doubles.toArray(SIXTEEN_SQUARES_DOUBLES);
    assertThat(median().computeInPlace(dataset)).isWithin(ALLOWED_ERROR).of(SIXTEEN_SQUARES_MEDIAN);
    assertThat(dataset).usingExactEquality().containsExactlyElementsIn(SIXTEEN_SQUARES_DOUBLES);
  }


            

Reported by PMD.

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

Line: 131

                      .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {
    double[] dataset = Doubles.toArray(SIXTEEN_SQUARES_DOUBLES);
    assertThat(median().computeInPlace(dataset)).isWithin(ALLOWED_ERROR).of(SIXTEEN_SQUARES_MEDIAN);
    assertThat(dataset).usingExactEquality().containsExactlyElementsIn(SIXTEEN_SQUARES_DOUBLES);
  }


            

Reported by PMD.

guava-tests/test/com/google/common/math/QuantilesTest.java
298 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.Quantiles.median;
import static com.google.common.math.Quantiles.percentiles;
import static com.google.common.math.Quantiles.quartiles;
import static com.google.common.truth.Truth.assertThat;

            

Reported by PMD.

Possible God Class (WMC=88, ATFD=9, TCC=25.355%)
Design

Line: 52

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

  /*
   * Since Quantiles provides a fluent-style API, each test covers a chain of methods resulting in
   * the computation of one or more quantiles (or in an error) rather than individual methods. The
   * tests are divided into three sections:

            

Reported by PMD.

The class 'QuantilesTest' has a total cyclomatic complexity of 88 (highest 4).
Design

Line: 52

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

  /*
   * Since Quantiles provides a fluent-style API, each test covers a chain of methods resulting in
   * the computation of one or more quantiles (or in an error) rather than individual methods. The
   * tests are divided into three sections:

            

Reported by PMD.

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

Line: 52

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

  /*
   * Since Quantiles provides a fluent-style API, each test covers a chain of methods resulting in
   * the computation of one or more quantiles (or in an error) rather than individual methods. The
   * tests are divided into three sections:

            

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

                private static final double SIXTEEN_SQUARES_DECILE_8 = 144.0;
  private static final double SIXTEEN_SQUARES_MAX = 225.0;

  public void testMedian_compute_doubleCollection() {
    assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
        .isWithin(ALLOWED_ERROR)
        .of(SIXTEEN_SQUARES_MEDIAN);
  }


            

Reported by PMD.

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

Line: 126

                private static final double SIXTEEN_SQUARES_MAX = 225.0;

  public void testMedian_compute_doubleCollection() {
    assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
        .isWithin(ALLOWED_ERROR)
        .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {

            

Reported by PMD.

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

Line: 126

                private static final double SIXTEEN_SQUARES_MAX = 225.0;

  public void testMedian_compute_doubleCollection() {
    assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
        .isWithin(ALLOWED_ERROR)
        .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {

            

Reported by PMD.

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

Line: 126

                private static final double SIXTEEN_SQUARES_MAX = 225.0;

  public void testMedian_compute_doubleCollection() {
    assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
        .isWithin(ALLOWED_ERROR)
        .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {

            

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

                      .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {
    double[] dataset = Doubles.toArray(SIXTEEN_SQUARES_DOUBLES);
    assertThat(median().computeInPlace(dataset)).isWithin(ALLOWED_ERROR).of(SIXTEEN_SQUARES_MEDIAN);
    assertThat(dataset).usingExactEquality().containsExactlyElementsIn(SIXTEEN_SQUARES_DOUBLES);
  }


            

Reported by PMD.

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

Line: 131

                      .of(SIXTEEN_SQUARES_MEDIAN);
  }

  public void testMedian_computeInPlace() {
    double[] dataset = Doubles.toArray(SIXTEEN_SQUARES_DOUBLES);
    assertThat(median().computeInPlace(dataset)).isWithin(ALLOWED_ERROR).of(SIXTEEN_SQUARES_MEDIAN);
    assertThat(dataset).usingExactEquality().containsExactlyElementsIn(SIXTEEN_SQUARES_DOUBLES);
  }


            

Reported by PMD.

android/guava-tests/test/com/google/common/primitives/ShortsTest.java
296 issues
Do not use the short type
Performance

Line: 45

                private static final short[] ARRAY1 = {(short) 1};
  private static final short[] ARRAY234 = {(short) 2, (short) 3, (short) 4};

  private static final short LEAST = Short.MIN_VALUE;
  private static final short GREATEST = Short.MAX_VALUE;

  private static final short[] VALUES = {LEAST, (short) -1, (short) 0, (short) 1, GREATEST};

  public void testHashCode() {

            

Reported by PMD.

Do not use the short type
Performance

Line: 46

                private static final short[] ARRAY234 = {(short) 2, (short) 3, (short) 4};

  private static final short LEAST = Short.MIN_VALUE;
  private static final short GREATEST = Short.MAX_VALUE;

  private static final short[] VALUES = {LEAST, (short) -1, (short) 0, (short) 1, GREATEST};

  public void testHashCode() {
    for (short value : VALUES) {

            

Reported by PMD.

Do not use the short type
Performance

Line: 51

                private static final short[] VALUES = {LEAST, (short) -1, (short) 0, (short) 1, GREATEST};

  public void testHashCode() {
    for (short value : VALUES) {
      assertEquals(((Short) value).hashCode(), Shorts.hashCode(value));
    }
  }

  public void testCheckedCast() {

            

Reported by PMD.

Do not use the short type
Performance

Line: 57

                }

  public void testCheckedCast() {
    for (short value : VALUES) {
      assertEquals(value, Shorts.checkedCast((long) value));
    }
    assertCastFails(GREATEST + 1L);
    assertCastFails(LEAST - 1L);
    assertCastFails(Long.MAX_VALUE);

            

Reported by PMD.

Do not use the short type
Performance

Line: 67

                }

  public void testSaturatedCast() {
    for (short value : VALUES) {
      assertEquals(value, Shorts.saturatedCast((long) value));
    }
    assertEquals(GREATEST, Shorts.saturatedCast(GREATEST + 1L));
    assertEquals(LEAST, Shorts.saturatedCast(LEAST - 1L));
    assertEquals(GREATEST, Shorts.saturatedCast(Long.MAX_VALUE));

            

Reported by PMD.

Do not use the short type
Performance

Line: 88

                }

  public void testCompare() {
    for (short x : VALUES) {
      for (short y : VALUES) {
        // Only compare the sign of the result of compareTo().
        int expected = Short.valueOf(x).compareTo(y);
        int actual = Shorts.compare(x, y);
        if (expected == 0) {

            

Reported by PMD.

Do not use the short type
Performance

Line: 89

              
  public void testCompare() {
    for (short x : VALUES) {
      for (short y : VALUES) {
        // Only compare the sign of the result of compareTo().
        int expected = Short.valueOf(x).compareTo(y);
        int actual = Shorts.compare(x, y);
        if (expected == 0) {
          assertEquals(x + ", " + y, expected, actual);

            

Reported by PMD.

Do not use the short type
Performance

Line: 276

              
    // total overkill, but, it takes 0.1 sec so why not...
    for (int i = 0; i < 10000; i++) {
      short num = (short) r.nextInt();
      assertEquals(num, Shorts.fromByteArray(Shorts.toByteArray(num)));

      r.nextBytes(b);
      assertTrue(Arrays.equals(b, Shorts.toByteArray(Shorts.fromByteArray(b))));
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 345

                  testReverse(new short[] {-1, 1, -2, 2}, new short[] {2, -2, 1, -1});
  }

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 352

                }

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


            

Reported by PMD.

android/guava-tests/test/com/google/common/net/MediaTypeTest.java
296 issues
Avoid throwing raw exception types.
Design

Line: 120

                              try {
                  return (MediaType) input.get(null);
                } catch (Exception e) {
                  throw new RuntimeException(e);
                }
              }
            });
  }


            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.net;

import static com.google.common.base.Charsets.UTF_16;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.net.MediaType.ANY_APPLICATION_TYPE;
import static com.google.common.net.MediaType.ANY_AUDIO_TYPE;

            

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

import static com.google.common.base.Charsets.UTF_16;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.net.MediaType.ANY_APPLICATION_TYPE;
import static com.google.common.net.MediaType.ANY_AUDIO_TYPE;

            

Reported by PMD.

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

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

Reported by PMD.

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

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

Reported by PMD.

Possible God Class (WMC=93, ATFD=19, TCC=0.075%)
Design

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

Reported by PMD.

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

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

Reported by PMD.

The class 'MediaTypeTest' has a total cyclomatic complexity of 93 (highest 17).
Design

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

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

               */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }
  }

  @GwtIncompatible // reflection
  public void testCreate_useConstants() throws Exception {

            

Reported by PMD.

guava-tests/test/com/google/common/net/MediaTypeTest.java
296 issues
Avoid throwing raw exception types.
Design

Line: 120

                              try {
                  return (MediaType) input.get(null);
                } catch (Exception e) {
                  throw new RuntimeException(e);
                }
              }
            });
  }


            

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

import static com.google.common.base.Charsets.UTF_16;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.net.MediaType.ANY_APPLICATION_TYPE;
import static com.google.common.net.MediaType.ANY_AUDIO_TYPE;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.net;

import static com.google.common.base.Charsets.UTF_16;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.net.MediaType.ANY_APPLICATION_TYPE;
import static com.google.common.net.MediaType.ANY_AUDIO_TYPE;

            

Reported by PMD.

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

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

Reported by PMD.

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

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

Reported by PMD.

The class 'MediaTypeTest' has a total cyclomatic complexity of 93 (highest 17).
Design

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

Reported by PMD.

Possible God Class (WMC=93, ATFD=19, TCC=0.075%)
Design

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

Reported by PMD.

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

Line: 59

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }

            

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

               */
@GwtCompatible(emulated = true)
public class MediaTypeTest extends TestCase {
  @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                @GwtIncompatible // reflection
  public void testParse_useConstants() throws Exception {
    for (MediaType constant : getConstants()) {
      assertSame(constant, MediaType.parse(constant.toString()));
    }
  }

  @GwtIncompatible // reflection
  public void testCreate_useConstants() throws Exception {

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/ShortsTest.java
296 issues
Do not use the short type
Performance

Line: 45

                private static final short[] ARRAY1 = {(short) 1};
  private static final short[] ARRAY234 = {(short) 2, (short) 3, (short) 4};

  private static final short LEAST = Short.MIN_VALUE;
  private static final short GREATEST = Short.MAX_VALUE;

  private static final short[] VALUES = {LEAST, (short) -1, (short) 0, (short) 1, GREATEST};

  public void testHashCode() {

            

Reported by PMD.

Do not use the short type
Performance

Line: 46

                private static final short[] ARRAY234 = {(short) 2, (short) 3, (short) 4};

  private static final short LEAST = Short.MIN_VALUE;
  private static final short GREATEST = Short.MAX_VALUE;

  private static final short[] VALUES = {LEAST, (short) -1, (short) 0, (short) 1, GREATEST};

  public void testHashCode() {
    for (short value : VALUES) {

            

Reported by PMD.

Do not use the short type
Performance

Line: 51

                private static final short[] VALUES = {LEAST, (short) -1, (short) 0, (short) 1, GREATEST};

  public void testHashCode() {
    for (short value : VALUES) {
      assertEquals(((Short) value).hashCode(), Shorts.hashCode(value));
    }
  }

  public void testCheckedCast() {

            

Reported by PMD.

Do not use the short type
Performance

Line: 57

                }

  public void testCheckedCast() {
    for (short value : VALUES) {
      assertEquals(value, Shorts.checkedCast((long) value));
    }
    assertCastFails(GREATEST + 1L);
    assertCastFails(LEAST - 1L);
    assertCastFails(Long.MAX_VALUE);

            

Reported by PMD.

Do not use the short type
Performance

Line: 67

                }

  public void testSaturatedCast() {
    for (short value : VALUES) {
      assertEquals(value, Shorts.saturatedCast((long) value));
    }
    assertEquals(GREATEST, Shorts.saturatedCast(GREATEST + 1L));
    assertEquals(LEAST, Shorts.saturatedCast(LEAST - 1L));
    assertEquals(GREATEST, Shorts.saturatedCast(Long.MAX_VALUE));

            

Reported by PMD.

Do not use the short type
Performance

Line: 88

                }

  public void testCompare() {
    for (short x : VALUES) {
      for (short y : VALUES) {
        // Only compare the sign of the result of compareTo().
        int expected = Short.valueOf(x).compareTo(y);
        int actual = Shorts.compare(x, y);
        if (expected == 0) {

            

Reported by PMD.

Do not use the short type
Performance

Line: 89

              
  public void testCompare() {
    for (short x : VALUES) {
      for (short y : VALUES) {
        // Only compare the sign of the result of compareTo().
        int expected = Short.valueOf(x).compareTo(y);
        int actual = Shorts.compare(x, y);
        if (expected == 0) {
          assertEquals(x + ", " + y, expected, actual);

            

Reported by PMD.

Do not use the short type
Performance

Line: 276

              
    // total overkill, but, it takes 0.1 sec so why not...
    for (int i = 0; i < 10000; i++) {
      short num = (short) r.nextInt();
      assertEquals(num, Shorts.fromByteArray(Shorts.toByteArray(num)));

      r.nextBytes(b);
      assertTrue(Arrays.equals(b, Shorts.toByteArray(Shorts.fromByteArray(b))));
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 345

                  testReverse(new short[] {-1, 1, -2, 2}, new short[] {2, -2, 1, -1});
  }

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


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 352

                }

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


            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
import static com.google.common.collect.Sets.newLinkedHashSet;
import static com.google.common.collect.testing.IteratorFeature.MODIFIABLE;

            

Reported by PMD.

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

Line: 58

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

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

            

Reported by PMD.

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

Line: 60

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

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

            

Reported by PMD.

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

Line: 95

                }

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

            

Reported by PMD.

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

Line: 95

                }

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

            

Reported by PMD.

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

Line: 97

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


            

Reported by PMD.

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

Line: 97

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


            

Reported by PMD.

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

Line: 98

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

  /**

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 99

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

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

            

Reported by PMD.

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

Line: 99

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

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

            

Reported by PMD.

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

Line: 15

               * the License.
 */

package com.google.common.collect;

import static com.google.common.collect.BoundType.OPEN;
import static com.google.common.collect.testing.Helpers.mapEntry;

import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

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

Line: 42

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

Possible God Class (WMC=80, ATFD=44, TCC=8.772%)
Design

Line: 42

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

The class 'TreeRangeMapTest' has a Modified Cyclomatic Complexity of 4 (Highest = 29).
Design

Line: 42

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

The class 'TreeRangeMapTest' has a Standard Cyclomatic Complexity of 4 (Highest = 29).
Design

Line: 42

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

The class 'TreeRangeMapTest' has a total cyclomatic complexity of 80 (highest 9).
Design

Line: 42

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

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

Line: 43

               */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(
                new TestMapGenerator<Range<Integer>, String>() {

            

Reported by PMD.

Avoid really long methods.
Design

Line: 43

               */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(
                new TestMapGenerator<Range<Integer>, String>() {

            

Reported by PMD.

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

Line: 43

               */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(
                new TestMapGenerator<Range<Integer>, String>() {

            

Reported by PMD.

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

Line: 43

               */
@GwtIncompatible // NavigableMap
public class TreeRangeMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(TreeRangeMapTest.class);
    suite.addTest(
        MapTestSuiteBuilder.using(
                new TestMapGenerator<Range<Integer>, String>() {

            

Reported by PMD.

guava-tests/test/com/google/common/collect/ImmutableListTest.java
291 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.collect.Iterables.unmodifiableIterable;
import static com.google.common.collect.Sets.newHashSet;
import static com.google.common.collect.testing.features.CollectionFeature.ALLOWS_NULL_QUERIES;

            

Reported by PMD.

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.Iterables.getOnlyElement;
import static com.google.common.collect.Iterables.unmodifiableIterable;
import static com.google.common.collect.Sets.newHashSet;
import static com.google.common.collect.testing.features.CollectionFeature.ALLOWS_NULL_QUERIES;

            

Reported by PMD.

This class name ends with Test but contains no test cases
Error

Line: 67

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

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

            

Reported by PMD.

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

Line: 69

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

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        ListTestSuiteBuilder.using(new ImmutableListOfGenerator())
            .named("ImmutableList")

            

Reported by PMD.

Possible God Class (WMC=63, ATFD=7, TCC=0.000%)
Design

Line: 116

                  return suite;
  }

  public static class CreationTests extends TestCase {
    public void testCreation_noArgs() {
      List<String> list = ImmutableList.of();
      assertEquals(Collections.emptyList(), list);
    }


            

Reported by PMD.

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

Line: 116

                  return suite;
  }

  public static class CreationTests extends TestCase {
    public void testCreation_noArgs() {
      List<String> list = ImmutableList.of();
      assertEquals(Collections.emptyList(), list);
    }


            

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

                }

  public static class CreationTests extends TestCase {
    public void testCreation_noArgs() {
      List<String> list = ImmutableList.of();
      assertEquals(Collections.emptyList(), list);
    }

    public void testCreation_oneElement() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 119

                public static class CreationTests extends TestCase {
    public void testCreation_noArgs() {
      List<String> list = ImmutableList.of();
      assertEquals(Collections.emptyList(), list);
    }

    public void testCreation_oneElement() {
      List<String> list = ImmutableList.of("a");
      assertEquals(Collections.singletonList("a"), list);

            

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

                    assertEquals(Collections.emptyList(), list);
    }

    public void testCreation_oneElement() {
      List<String> list = ImmutableList.of("a");
      assertEquals(Collections.singletonList("a"), list);
    }

    public void testCreation_twoElements() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 124

              
    public void testCreation_oneElement() {
      List<String> list = ImmutableList.of("a");
      assertEquals(Collections.singletonList("a"), list);
    }

    public void testCreation_twoElements() {
      List<String> list = ImmutableList.of("a", "b");
      assertEquals(Lists.newArrayList("a", "b"), list);

            

Reported by PMD.