The following issues were found

android/guava-tests/test/com/google/common/reflect/TypesTest.java
144 issues
This class has too many methods, consider refactoring it.
Design

Line: 46

               * @author Ben Yu
 */
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypesTest extends TestCase {
  public void testNewParameterizedType_ownerTypeImplied() throws Exception {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<Entry<String, Integer>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);

            

Reported by PMD.

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

Line: 47

               */
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypesTest extends TestCase {
  public void testNewParameterizedType_ownerTypeImplied() throws Exception {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<Entry<String, Integer>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);

            

Reported by PMD.

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

Line: 47

               */
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypesTest extends TestCase {
  public void testNewParameterizedType_ownerTypeImplied() throws Exception {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<Entry<String, Integer>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 52

                      (ParameterizedType) new TypeCapture<Entry<String, Integer>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);
    assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =

            

Reported by PMD.

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

Line: 53

                  ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);
    assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                  ParameterizedType ourType =
        Types.newParameterizedType(Entry.class, String.class, Integer.class);
    assertEquals(jvmType, ourType);
    assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();

            

Reported by PMD.

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

Line: 56

                  assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(HashMap.class, String.class, int[][].class);


            

Reported by PMD.

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

Line: 56

                  assertEquals(Map.class, ourType.getOwnerType());
  }

  public void testNewParameterizedType() {
    ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(HashMap.class, String.class, int[][].class);


            

Reported by PMD.

Avoid using implementation types like 'HashMap'; use the interface instead
Design

Line: 60

                  ParameterizedType jvmType =
        (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {}.capture();
    ParameterizedType ourType =
        Types.newParameterizedType(HashMap.class, String.class, int[][].class);

    new EqualsTester().addEqualityGroup(jvmType, ourType).testEquals();
    assertEquals(jvmType.toString(), ourType.toString());
    assertEquals(jvmType.hashCode(), ourType.hashCode());
    assertEquals(HashMap.class, ourType.getRawType());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                      Types.newParameterizedType(HashMap.class, String.class, int[][].class);

    new EqualsTester().addEqualityGroup(jvmType, ourType).testEquals();
    assertEquals(jvmType.toString(), ourType.toString());
    assertEquals(jvmType.hashCode(), ourType.hashCode());
    assertEquals(HashMap.class, ourType.getRawType());
    assertThat(ourType.getActualTypeArguments())
        .asList()
        .containsExactlyElementsIn(asList(jvmType.getActualTypeArguments()))

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/ToStringHelperTest.java
143 issues
Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 159

                @GwtIncompatible // Class names are obfuscated in GWT
  public void testToString_oneIntegerField() {
    String toTest =
        MoreObjects.toStringHelper(new TestClass()).add("field1", new Integer(42)).toString();
    assertEquals("TestClass{field1=42}", toTest);
  }

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testToString_nullInteger() {

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 177

              
  public void testToStringLenient_oneIntegerField() {
    String toTest =
        MoreObjects.toStringHelper(new TestClass()).add("field1", new Integer(42)).toString();
    assertTrue(toTest, toTest.matches(".*\\{field1\\=42\\}"));
  }

  public void testToStringLenient_nullInteger() {
    String toTest =

            

Reported by PMD.

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

Line: 32

               * @author Jason Lee
 */
@GwtCompatible
public class ToStringHelperTest extends TestCase {

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertEquals("ToStringHelperTest{}", toTest);

            

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

              @GwtCompatible
public class ToStringHelperTest extends TestCase {

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertEquals("ToStringHelperTest{}", toTest);
  }


            

Reported by PMD.

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

Line: 36

              
  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertEquals("ToStringHelperTest{}", toTest);
  }

  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertEquals("ToStringHelperTest{}", toTest);
  }

  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));

            

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

                  assertEquals("ToStringHelperTest{}", toTest);
  }

  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));
  }

  @GwtIncompatible // Class names are obfuscated in GWT

            

Reported by PMD.

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

Line: 41

                }

  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));
  }

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_innerClass() {

            

Reported by PMD.

The String literal '.*\\{\\}' appears 7 times in this file; the first occurrence is on line 42
Error

Line: 42

              
  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));
  }

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_innerClass() {
    String toTest = MoreObjects.toStringHelper(new TestClass()).toString();

            

Reported by PMD.

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

Line: 42

              
  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));
  }

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_innerClass() {
    String toTest = MoreObjects.toStringHelper(new TestClass()).toString();

            

Reported by PMD.

guava-tests/test/com/google/common/base/ToStringHelperTest.java
143 issues
Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 159

                @GwtIncompatible // Class names are obfuscated in GWT
  public void testToString_oneIntegerField() {
    String toTest =
        MoreObjects.toStringHelper(new TestClass()).add("field1", new Integer(42)).toString();
    assertEquals("TestClass{field1=42}", toTest);
  }

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testToString_nullInteger() {

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 177

              
  public void testToStringLenient_oneIntegerField() {
    String toTest =
        MoreObjects.toStringHelper(new TestClass()).add("field1", new Integer(42)).toString();
    assertTrue(toTest, toTest.matches(".*\\{field1\\=42\\}"));
  }

  public void testToStringLenient_nullInteger() {
    String toTest =

            

Reported by PMD.

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

Line: 32

               * @author Jason Lee
 */
@GwtCompatible
public class ToStringHelperTest extends TestCase {

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertEquals("ToStringHelperTest{}", toTest);

            

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

              @GwtCompatible
public class ToStringHelperTest extends TestCase {

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertEquals("ToStringHelperTest{}", toTest);
  }


            

Reported by PMD.

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

Line: 36

              
  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertEquals("ToStringHelperTest{}", toTest);
  }

  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertEquals("ToStringHelperTest{}", toTest);
  }

  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));

            

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

                  assertEquals("ToStringHelperTest{}", toTest);
  }

  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));
  }

  @GwtIncompatible // Class names are obfuscated in GWT

            

Reported by PMD.

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

Line: 41

                }

  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));
  }

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_innerClass() {

            

Reported by PMD.

The String literal '.*\\{\\}' appears 7 times in this file; the first occurrence is on line 42
Error

Line: 42

              
  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));
  }

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_innerClass() {
    String toTest = MoreObjects.toStringHelper(new TestClass()).toString();

            

Reported by PMD.

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

Line: 42

              
  public void testConstructorLenient_instance() {
    String toTest = MoreObjects.toStringHelper(this).toString();
    assertTrue(toTest, toTest.matches(".*\\{\\}"));
  }

  @GwtIncompatible // Class names are obfuscated in GWT
  public void testConstructor_innerClass() {
    String toTest = MoreObjects.toStringHelper(new TestClass()).toString();

            

Reported by PMD.

guava/src/com/google/common/collect/TreeRangeMap.java
143 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.base.Predicates.in;

            

Reported by PMD.

Possible God Class (WMC=51, ATFD=77, TCC=8.615%)
Design

Line: 57

              @Beta
@GwtIncompatible // NavigableMap
@ElementTypesAreNonnullByDefault
public final class TreeRangeMap<K extends Comparable, V> implements RangeMap<K, V> {

  private final NavigableMap<Cut<K>, RangeMapEntry<K, V>> entriesByLowerBound;

  public static <K extends Comparable, V> TreeRangeMap<K, V> create() {
    return new TreeRangeMap<>();

            

Reported by PMD.

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

Line: 57

              @Beta
@GwtIncompatible // NavigableMap
@ElementTypesAreNonnullByDefault
public final class TreeRangeMap<K extends Comparable, V> implements RangeMap<K, V> {

  private final NavigableMap<Cut<K>, RangeMapEntry<K, V>> entriesByLowerBound;

  public static <K extends Comparable, V> TreeRangeMap<K, V> create() {
    return new TreeRangeMap<>();

            

Reported by PMD.

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

Line: 59

              @ElementTypesAreNonnullByDefault
public final class TreeRangeMap<K extends Comparable, V> implements RangeMap<K, V> {

  private final NavigableMap<Cut<K>, RangeMapEntry<K, V>> entriesByLowerBound;

  public static <K extends Comparable, V> TreeRangeMap<K, V> create() {
    return new TreeRangeMap<>();
  }


            

Reported by PMD.

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

Line: 71

              
  private static final class RangeMapEntry<K extends Comparable, V>
      extends AbstractMapEntry<Range<K>, V> {
    private final Range<K> range;
    private final V value;

    RangeMapEntry(Cut<K> lowerBound, Cut<K> upperBound, V value) {
      this(Range.create(lowerBound, upperBound), value);
    }

            

Reported by PMD.

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

Line: 110

                @CheckForNull
  public V get(K key) {
    Entry<Range<K>, V> entry = getEntry(key);
    return (entry == null) ? null : entry.getValue();
  }

  @Override
  @CheckForNull
  public Entry<Range<K>, V> getEntry(K key) {

            

Reported by PMD.

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

Line: 118

                public Entry<Range<K>, V> getEntry(K key) {
    Entry<Cut<K>, RangeMapEntry<K, V>> mapEntry =
        entriesByLowerBound.floorEntry(Cut.belowValue(key));
    if (mapEntry != null && mapEntry.getValue().contains(key)) {
      return mapEntry.getValue();
    } else {
      return null;
    }
  }

            

Reported by PMD.

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

Line: 118

                public Entry<Range<K>, V> getEntry(K key) {
    Entry<Cut<K>, RangeMapEntry<K, V>> mapEntry =
        entriesByLowerBound.floorEntry(Cut.belowValue(key));
    if (mapEntry != null && mapEntry.getValue().contains(key)) {
      return mapEntry.getValue();
    } else {
      return null;
    }
  }

            

Reported by PMD.

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

Line: 164

                private static <K extends Comparable, V> Range<K> coalesce(
      Range<K> range, V value, @CheckForNull Entry<Cut<K>, RangeMapEntry<K, V>> entry) {
    if (entry != null
        && entry.getValue().getKey().isConnected(range)
        && entry.getValue().getValue().equals(value)) {
      return range.span(entry.getValue().getKey());
    }
    return range;
  }

            

Reported by PMD.

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

Line: 164

                private static <K extends Comparable, V> Range<K> coalesce(
      Range<K> range, V value, @CheckForNull Entry<Cut<K>, RangeMapEntry<K, V>> entry) {
    if (entry != null
        && entry.getValue().getKey().isConnected(range)
        && entry.getValue().getValue().equals(value)) {
      return range.span(entry.getValue().getKey());
    }
    return range;
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/primitives/UnsignedLongsTest.java
142 issues
Avoid reassigning parameters such as 'input'
Design

Line: 120

                  testSort(new long[] {2, GREATEST, 1, LEAST}, new long[] {LEAST, 1, 2, GREATEST});
  }

  static void testSort(long[] input, long[] expected) {
    input = Arrays.copyOf(input, input.length);
    UnsignedLongs.sort(input);
    assertTrue(Arrays.equals(expected, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 126

                  assertTrue(Arrays.equals(expected, input));
  }

  static void testSort(long[] input, int from, int to, long[] expected) {
    input = Arrays.copyOf(input, input.length);
    UnsignedLongs.sort(input, from, to);
    assertTrue(Arrays.equals(expected, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 149

                      new long[] {GREATEST - 1, GREATEST - 2, 2, 1});
  }

  private static void testSortDescending(long[] input, long[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    UnsignedLongs.sortDescending(input);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 156

                }

  private static void testSortDescending(
      long[] input, int fromIndex, int toIndex, long[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    UnsignedLongs.sortDescending(input, fromIndex, toIndex);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

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

Line: 37

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class UnsignedLongsTest extends TestCase {
  private static final long LEAST = 0L;
  private static final long GREATEST = 0xffffffffffffffffL;

  public void testCompare() {
    // max value

            

Reported by PMD.

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

Line: 41

                private static final long LEAST = 0L;
  private static final long GREATEST = 0xffffffffffffffffL;

  public void testCompare() {
    // max value
    assertTrue(UnsignedLongs.compare(0, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set

            

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

                private static final long LEAST = 0L;
  private static final long GREATEST = 0xffffffffffffffffL;

  public void testCompare() {
    // max value
    assertTrue(UnsignedLongs.compare(0, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

              
  public void testCompare() {
    // max value
    assertTrue(UnsignedLongs.compare(0, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set
    assertTrue(UnsignedLongs.compare(0xff1a618b7f65ea12L, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0xff1a618b7f65ea12L) > 0);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

                public void testCompare() {
    // max value
    assertTrue(UnsignedLongs.compare(0, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set
    assertTrue(UnsignedLongs.compare(0xff1a618b7f65ea12L, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0xff1a618b7f65ea12L) > 0);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

                  assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set
    assertTrue(UnsignedLongs.compare(0xff1a618b7f65ea12L, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0xff1a618b7f65ea12L) > 0);

    // one with high bit set
    assertTrue(UnsignedLongs.compare(0x5a4316b8c153ac4dL, 0xff1a618b7f65ea12L) < 0);
    assertTrue(UnsignedLongs.compare(0xff1a618b7f65ea12L, 0x5a4316b8c153ac4dL) > 0);

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/UnsignedLongsTest.java
142 issues
Avoid reassigning parameters such as 'input'
Design

Line: 120

                  testSort(new long[] {2, GREATEST, 1, LEAST}, new long[] {LEAST, 1, 2, GREATEST});
  }

  static void testSort(long[] input, long[] expected) {
    input = Arrays.copyOf(input, input.length);
    UnsignedLongs.sort(input);
    assertTrue(Arrays.equals(expected, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 126

                  assertTrue(Arrays.equals(expected, input));
  }

  static void testSort(long[] input, int from, int to, long[] expected) {
    input = Arrays.copyOf(input, input.length);
    UnsignedLongs.sort(input, from, to);
    assertTrue(Arrays.equals(expected, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 149

                      new long[] {GREATEST - 1, GREATEST - 2, 2, 1});
  }

  private static void testSortDescending(long[] input, long[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    UnsignedLongs.sortDescending(input);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 156

                }

  private static void testSortDescending(
      long[] input, int fromIndex, int toIndex, long[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    UnsignedLongs.sortDescending(input, fromIndex, toIndex);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

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

Line: 37

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class UnsignedLongsTest extends TestCase {
  private static final long LEAST = 0L;
  private static final long GREATEST = 0xffffffffffffffffL;

  public void testCompare() {
    // max value

            

Reported by PMD.

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

Line: 41

                private static final long LEAST = 0L;
  private static final long GREATEST = 0xffffffffffffffffL;

  public void testCompare() {
    // max value
    assertTrue(UnsignedLongs.compare(0, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set

            

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

                private static final long LEAST = 0L;
  private static final long GREATEST = 0xffffffffffffffffL;

  public void testCompare() {
    // max value
    assertTrue(UnsignedLongs.compare(0, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

              
  public void testCompare() {
    // max value
    assertTrue(UnsignedLongs.compare(0, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set
    assertTrue(UnsignedLongs.compare(0xff1a618b7f65ea12L, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0xff1a618b7f65ea12L) > 0);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

                public void testCompare() {
    // max value
    assertTrue(UnsignedLongs.compare(0, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set
    assertTrue(UnsignedLongs.compare(0xff1a618b7f65ea12L, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0xff1a618b7f65ea12L) > 0);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

                  assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0) > 0);

    // both with high bit set
    assertTrue(UnsignedLongs.compare(0xff1a618b7f65ea12L, 0xffffffffffffffffL) < 0);
    assertTrue(UnsignedLongs.compare(0xffffffffffffffffL, 0xff1a618b7f65ea12L) > 0);

    // one with high bit set
    assertTrue(UnsignedLongs.compare(0x5a4316b8c153ac4dL, 0xff1a618b7f65ea12L) < 0);
    assertTrue(UnsignedLongs.compare(0xff1a618b7f65ea12L, 0x5a4316b8c153ac4dL) > 0);

            

Reported by PMD.

guava/src/com/google/common/collect/Streams.java
141 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * permissions and limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import static java.util.Objects.requireNonNull;


            

Reported by PMD.

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

Line: 60

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Streams {
  /**
   * Returns a sequential {@link Stream} of the contents of {@code iterable}, delegating to {@link
   * Collection#stream} if possible.
   */
  public static <T extends @Nullable Object> Stream<T> stream(Iterable<T> iterable) {

            

Reported by PMD.

Possible God Class (WMC=53, ATFD=81, TCC=0.000%)
Design

Line: 60

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Streams {
  /**
   * Returns a sequential {@link Stream} of the contents of {@code iterable}, delegating to {@link
   * Collection#stream} if possible.
   */
  public static <T extends @Nullable Object> Stream<T> stream(Iterable<T> iterable) {

            

Reported by PMD.

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

Line: 146

                }

  private static void closeAll(BaseStream<?, ?>[] toClose) {
    for (BaseStream<?, ?> stream : toClose) {
      // TODO(b/80534298): Catch exceptions, rethrowing later with extras as suppressed exceptions.
      stream.close();
    }
  }


            

Reported by PMD.

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

Line: 173

                    isParallel |= stream.isParallel();
      Spliterator<? extends T> splitr = stream.spliterator();
      splitrsBuilder.add(splitr);
      characteristics &= splitr.characteristics();
      estimatedSize = LongMath.saturatedAdd(estimatedSize, splitr.estimateSize());
    }
    return StreamSupport.stream(
            CollectSpliterators.flatMap(
                splitrsBuilder.build().spliterator(),

            

Reported by PMD.

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

Line: 174

                    Spliterator<? extends T> splitr = stream.spliterator();
      splitrsBuilder.add(splitr);
      characteristics &= splitr.characteristics();
      estimatedSize = LongMath.saturatedAdd(estimatedSize, splitr.estimateSize());
    }
    return StreamSupport.stream(
            CollectSpliterators.flatMap(
                splitrsBuilder.build().spliterator(),
                splitr -> (Spliterator<T>) splitr,

            

Reported by PMD.

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

Line: 176

                    characteristics &= splitr.characteristics();
      estimatedSize = LongMath.saturatedAdd(estimatedSize, splitr.estimateSize());
    }
    return StreamSupport.stream(
            CollectSpliterators.flatMap(
                splitrsBuilder.build().spliterator(),
                splitr -> (Spliterator<T>) splitr,
                characteristics,
                estimatedSize),

            

Reported by PMD.

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

Line: 178

                  }
    return StreamSupport.stream(
            CollectSpliterators.flatMap(
                splitrsBuilder.build().spliterator(),
                splitr -> (Spliterator<T>) splitr,
                characteristics,
                estimatedSize),
            isParallel)
        .onClose(() -> closeAll(streams));

            

Reported by PMD.

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

Line: 205

                    isParallel |= stream.isParallel();
      Spliterator.OfInt splitr = stream.spliterator();
      splitrsBuilder.add(splitr);
      characteristics &= splitr.characteristics();
      estimatedSize = LongMath.saturatedAdd(estimatedSize, splitr.estimateSize());
    }
    return StreamSupport.intStream(
            CollectSpliterators.flatMapToInt(
                splitrsBuilder.build().spliterator(),

            

Reported by PMD.

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

Line: 206

                    Spliterator.OfInt splitr = stream.spliterator();
      splitrsBuilder.add(splitr);
      characteristics &= splitr.characteristics();
      estimatedSize = LongMath.saturatedAdd(estimatedSize, splitr.estimateSize());
    }
    return StreamSupport.intStream(
            CollectSpliterators.flatMapToInt(
                splitrsBuilder.build().spliterator(),
                splitr -> splitr,

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/AbstractAbstractFutureTest.java
140 issues
This class has too many methods, consider refactoring it.
Design

Line: 43

               * different "source Future" for {@link AbstractFuture#setFuture} calls.
 */
@GwtCompatible(emulated = true)
abstract class AbstractAbstractFutureTest extends TestCase {
  private TestedFuture<Integer> future;
  private AbstractFuture<Integer> delegate;

  abstract AbstractFuture<Integer> newDelegate();


            

Reported by PMD.

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

Line: 44

               */
@GwtCompatible(emulated = true)
abstract class AbstractAbstractFutureTest extends TestCase {
  private TestedFuture<Integer> future;
  private AbstractFuture<Integer> delegate;

  abstract AbstractFuture<Integer> newDelegate();

  @Override

            

Reported by PMD.

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

Line: 45

              @GwtCompatible(emulated = true)
abstract class AbstractAbstractFutureTest extends TestCase {
  private TestedFuture<Integer> future;
  private AbstractFuture<Integer> delegate;

  abstract AbstractFuture<Integer> newDelegate();

  @Override
  protected void setUp() {

            

Reported by PMD.

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

Line: 49

              
  abstract AbstractFuture<Integer> newDelegate();

  @Override
  protected void setUp() {
    future = TestedFuture.create();
    delegate = newDelegate();
  }


            

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

                  delegate = newDelegate();
  }

  public void testPending() {
    assertPending(future);
  }

  public void testSuccessful() throws Exception {
    assertThat(future.set(1)).isTrue();

            

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

                  assertPending(future);
  }

  public void testSuccessful() throws Exception {
    assertThat(future.set(1)).isTrue();
    assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {

            

Reported by PMD.

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

Line: 59

                  assertPending(future);
  }

  public void testSuccessful() throws Exception {
    assertThat(future.set(1)).isTrue();
    assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {

            

Reported by PMD.

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

Line: 60

                }

  public void testSuccessful() throws Exception {
    assertThat(future.set(1)).isTrue();
    assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {
    Exception cause = new Exception();

            

Reported by PMD.

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

Line: 64

                  assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {
    Exception cause = new Exception();
    assertThat(future.setException(cause)).isTrue();
    assertFailed(future, cause);
  }


            

Reported by PMD.

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

Line: 64

                  assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {
    Exception cause = new Exception();
    assertThat(future.setException(cause)).isTrue();
    assertFailed(future, cause);
  }


            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/AbstractAbstractFutureTest.java
140 issues
This class has too many methods, consider refactoring it.
Design

Line: 43

               * different "source Future" for {@link AbstractFuture#setFuture} calls.
 */
@GwtCompatible(emulated = true)
abstract class AbstractAbstractFutureTest extends TestCase {
  private TestedFuture<Integer> future;
  private AbstractFuture<Integer> delegate;

  abstract AbstractFuture<Integer> newDelegate();


            

Reported by PMD.

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

Line: 44

               */
@GwtCompatible(emulated = true)
abstract class AbstractAbstractFutureTest extends TestCase {
  private TestedFuture<Integer> future;
  private AbstractFuture<Integer> delegate;

  abstract AbstractFuture<Integer> newDelegate();

  @Override

            

Reported by PMD.

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

Line: 45

              @GwtCompatible(emulated = true)
abstract class AbstractAbstractFutureTest extends TestCase {
  private TestedFuture<Integer> future;
  private AbstractFuture<Integer> delegate;

  abstract AbstractFuture<Integer> newDelegate();

  @Override
  protected void setUp() {

            

Reported by PMD.

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

Line: 49

              
  abstract AbstractFuture<Integer> newDelegate();

  @Override
  protected void setUp() {
    future = TestedFuture.create();
    delegate = newDelegate();
  }


            

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

                  delegate = newDelegate();
  }

  public void testPending() {
    assertPending(future);
  }

  public void testSuccessful() throws Exception {
    assertThat(future.set(1)).isTrue();

            

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

                  assertPending(future);
  }

  public void testSuccessful() throws Exception {
    assertThat(future.set(1)).isTrue();
    assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {

            

Reported by PMD.

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

Line: 59

                  assertPending(future);
  }

  public void testSuccessful() throws Exception {
    assertThat(future.set(1)).isTrue();
    assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {

            

Reported by PMD.

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

Line: 60

                }

  public void testSuccessful() throws Exception {
    assertThat(future.set(1)).isTrue();
    assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {
    Exception cause = new Exception();

            

Reported by PMD.

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

Line: 64

                  assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {
    Exception cause = new Exception();
    assertThat(future.setException(cause)).isTrue();
    assertFailed(future, cause);
  }


            

Reported by PMD.

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

Line: 64

                  assertSuccessful(future, 1);
  }

  public void testFailed() throws Exception {
    Exception cause = new Exception();
    assertThat(future.setException(cause)).isTrue();
    assertFailed(future, cause);
  }


            

Reported by PMD.

android/guava-tests/test/com/google/common/graph/EndpointPairTest.java
140 issues
This class has too many methods, consider refactoring it.
Design

Line: 33

              
/** Tests for {@link EndpointPair} and {@link Graph#edges()}. */
@RunWith(JUnit4.class)
public final class EndpointPairTest {
  private static final Integer N0 = 0;
  private static final Integer N1 = 1;
  private static final Integer N2 = 2;
  private static final Integer N3 = 3;
  private static final Integer N4 = 4;

            

Reported by PMD.

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

Line: 48

                // Test for EndpointPair class

  @Test
  public void testOrderedEndpointPair() {
    EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");

            

Reported by PMD.

The String literal 'source' appears 6 times in this file; the first occurrence is on line 49
Error

Line: 49

              
  @Test
  public void testOrderedEndpointPair() {
    EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");
    assertThat(ordered.nodeU()).isEqualTo("source");

            

Reported by PMD.

The String literal 'target' appears 6 times in this file; the first occurrence is on line 49
Error

Line: 49

              
  @Test
  public void testOrderedEndpointPair() {
    EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");
    assertThat(ordered.nodeU()).isEqualTo("source");

            

Reported by PMD.

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

Line: 50

                @Test
  public void testOrderedEndpointPair() {
    EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");
    assertThat(ordered.nodeU()).isEqualTo("source");
    assertThat(ordered.nodeV()).isEqualTo("target");

            

Reported by PMD.

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

Line: 50

                @Test
  public void testOrderedEndpointPair() {
    EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");
    assertThat(ordered.nodeU()).isEqualTo("source");
    assertThat(ordered.nodeV()).isEqualTo("target");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                public void testOrderedEndpointPair() {
    EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");
    assertThat(ordered.nodeU()).isEqualTo("source");
    assertThat(ordered.nodeV()).isEqualTo("target");
    assertThat(ordered.adjacentNode("source")).isEqualTo("target");

            

Reported by PMD.

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

Line: 51

                public void testOrderedEndpointPair() {
    EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");
    assertThat(ordered.nodeU()).isEqualTo("source");
    assertThat(ordered.nodeV()).isEqualTo("target");
    assertThat(ordered.adjacentNode("source")).isEqualTo("target");

            

Reported by PMD.

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

Line: 51

                public void testOrderedEndpointPair() {
    EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");
    assertThat(ordered.nodeU()).isEqualTo("source");
    assertThat(ordered.nodeV()).isEqualTo("target");
    assertThat(ordered.adjacentNode("source")).isEqualTo("target");

            

Reported by PMD.

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

Line: 52

                  EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
    assertThat(ordered.isOrdered()).isTrue();
    assertThat(ordered).containsExactly("source", "target").inOrder();
    assertThat(ordered.source()).isEqualTo("source");
    assertThat(ordered.target()).isEqualTo("target");
    assertThat(ordered.nodeU()).isEqualTo("source");
    assertThat(ordered.nodeV()).isEqualTo("target");
    assertThat(ordered.adjacentNode("source")).isEqualTo("target");
    assertThat(ordered.adjacentNode("target")).isEqualTo("source");

            

Reported by PMD.