The following issues were found

guava-testlib/src/com/google/common/collect/testing/google/MultisetEntrySetTester.java
111 issues
This class has too many methods, consider refactoring it.
Design

Line: 44

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetEntrySetTester<E> extends AbstractMultisetTester<E> {

  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());

            

Reported by PMD.

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

Line: 46

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetEntrySetTester<E> extends AbstractMultisetTester<E> {

  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }


            

Reported by PMD.

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

Line: 48

              
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)

            

Reported by PMD.

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

Line: 48

              
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)

            

Reported by PMD.

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

Line: 49

                @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {

            

Reported by PMD.

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

Line: 52

                  assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {
    Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
    assertTrue(
        "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());

            

Reported by PMD.

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

Line: 54

              
  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {
    Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
    assertTrue(
        "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());
    assertEquals(
        "multiset.entrySet() iterator.next() returned incorrect entry",

            

Reported by PMD.

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

Line: 55

                @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {
    Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
    assertTrue(
        "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());
    assertEquals(
        "multiset.entrySet() iterator.next() returned incorrect entry",
        Multisets.immutableEntry(e0(), 1),

            

Reported by PMD.

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

Line: 55

                @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {
    Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
    assertTrue(
        "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());
    assertEquals(
        "multiset.entrySet() iterator.next() returned incorrect entry",
        Multisets.immutableEntry(e0(), 1),

            

Reported by PMD.

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

Line: 68

                  iterator.remove();
    assertTrue(
        "multiset isn't empty after multiset.entrySet() iterator.remove()",
        getMultiset().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_removePresent() {

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/MultisetEntrySetTester.java
111 issues
This class has too many methods, consider refactoring it.
Design

Line: 44

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetEntrySetTester<E> extends AbstractMultisetTester<E> {

  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());

            

Reported by PMD.

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

Line: 46

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetEntrySetTester<E> extends AbstractMultisetTester<E> {

  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }


            

Reported by PMD.

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

Line: 48

              
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)

            

Reported by PMD.

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

Line: 48

              
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)

            

Reported by PMD.

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

Line: 49

                @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_clear() {
    getMultiset().entrySet().clear();
    assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {

            

Reported by PMD.

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

Line: 52

                  assertTrue("multiset not empty after entrySet().clear()", getMultiset().isEmpty());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {
    Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
    assertTrue(
        "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());

            

Reported by PMD.

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

Line: 54

              
  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {
    Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
    assertTrue(
        "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());
    assertEquals(
        "multiset.entrySet() iterator.next() returned incorrect entry",

            

Reported by PMD.

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

Line: 55

                @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {
    Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
    assertTrue(
        "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());
    assertEquals(
        "multiset.entrySet() iterator.next() returned incorrect entry",
        Multisets.immutableEntry(e0(), 1),

            

Reported by PMD.

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

Line: 55

                @CollectionSize.Require(ONE)
  @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
  public void testEntrySet_iteratorRemovePropagates() {
    Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
    assertTrue(
        "non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());
    assertEquals(
        "multiset.entrySet() iterator.next() returned incorrect entry",
        Multisets.immutableEntry(e0(), 1),

            

Reported by PMD.

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

Line: 68

                  iterator.remove();
    assertTrue(
        "multiset isn't empty after multiset.entrySet() iterator.remove()",
        getMultiset().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testEntrySet_removePresent() {

            

Reported by PMD.

guava/src/com/google/common/collect/Sets.java
111 issues
Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 1468

                    int adjust = size() - 1;
      for (int i = 0; i < axes.size(); i++) {
        adjust *= 31;
        adjust = ~~adjust;
        // in GWT, we have to deal with integer overflow carefully
      }
      int hash = 1;
      for (Set<E> axis : axes) {
        hash = 31 * hash + (size() / axis.size() * axis.hashCode());

            

Reported by PMD.

Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 1475

                    for (Set<E> axis : axes) {
        hash = 31 * hash + (size() / axis.size() * axis.hashCode());

        hash = ~~hash;
      }
      hash += adjust;
      return ~~hash;
    }
  }

            

Reported by PMD.

Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 1478

                      hash = ~~hash;
      }
      hash += adjust;
      return ~~hash;
    }
  }

  /**
   * Returns the set of all possible subsets of {@code set}. For example, {@code

            

Reported by PMD.

Using multiple unary operators may be a bug, and/or is confusing.
Error

Line: 1749

                  for (Object o : s) {
      hashCode += o != null ? o.hashCode() : 0;

      hashCode = ~~hashCode;
      // Needed to deal with unusual integer overflow in GWT.
    }
    return hashCode;
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'collection'
Design

Line: 1966

                  return changed;
  }

  static boolean removeAllImpl(Set<?> set, Collection<?> collection) {
    checkNotNull(collection); // for GWT
    if (collection instanceof Multiset) {
      collection = ((Multiset<?>) collection).elementSet();
    }
    /*

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

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


            

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.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;


            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

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


            

Reported by PMD.

Avoid really long classes.
Design

Line: 71

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

  /**
   * {@link AbstractSet} substitute without the potentially-quadratic {@code removeAll}
   * implementation.

            

Reported by PMD.

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

Line: 71

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

  /**
   * {@link AbstractSet} substitute without the potentially-quadratic {@code removeAll}
   * implementation.

            

Reported by PMD.

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

Line: 36

               * @author Isaac Shum
 */
@GwtCompatible
public class MapsTransformValuesTest extends MapInterfaceTest<String, String> {

  /**
   * Constructor that assigns {@code supportsIteratorRemove} the same value as {@code
   * supportsRemove}.
   */

            

Reported by PMD.

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

Line: 69

                @Override
  protected Map<String, String> makePopulatedMap() {
    Map<String, Integer> underlying = Maps.newHashMap();
    underlying.put("a", 1);
    underlying.put("b", 2);
    underlying.put("c", 3);
    return Maps.transformValues(underlying, Functions.toStringFunction());
  }


            

Reported by PMD.

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

Line: 70

                protected Map<String, String> makePopulatedMap() {
    Map<String, Integer> underlying = Maps.newHashMap();
    underlying.put("a", 1);
    underlying.put("b", 2);
    underlying.put("c", 3);
    return Maps.transformValues(underlying, Functions.toStringFunction());
  }

  @Override

            

Reported by PMD.

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

Line: 71

                  Map<String, Integer> underlying = Maps.newHashMap();
    underlying.put("a", 1);
    underlying.put("b", 2);
    underlying.put("c", 3);
    return Maps.transformValues(underlying, Functions.toStringFunction());
  }

  @Override
  protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 76

                }

  @Override
  protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
    return "z";
  }

  @Override
  protected String getValueNotInPopulatedMap() throws UnsupportedOperationException {

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 81

                }

  @Override
  protected String getValueNotInPopulatedMap() throws UnsupportedOperationException {
    return "26";
  }

  /** Helper assertion comparing two maps */
  private void assertMapsEqual(Map<?, ?> expected, Map<?, ?> map) {

            

Reported by PMD.

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

Line: 95

                  // mapValues > expectedValues; i.e. that expectedValues == mapValues.
    Collection<?> expectedValues = expected.values();
    Collection<?> mapValues = map.values();
    assertEquals(expectedValues.size(), mapValues.size());
    assertTrue(expectedValues.containsAll(mapValues));
    assertTrue(mapValues.containsAll(expectedValues));
  }

  public void testTransformEmptyMapEquality() {

            

Reported by PMD.

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

Line: 95

                  // mapValues > expectedValues; i.e. that expectedValues == mapValues.
    Collection<?> expectedValues = expected.values();
    Collection<?> mapValues = map.values();
    assertEquals(expectedValues.size(), mapValues.size());
    assertTrue(expectedValues.containsAll(mapValues));
    assertTrue(mapValues.containsAll(expectedValues));
  }

  public void testTransformEmptyMapEquality() {

            

Reported by PMD.

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

Line: 96

                  Collection<?> expectedValues = expected.values();
    Collection<?> mapValues = map.values();
    assertEquals(expectedValues.size(), mapValues.size());
    assertTrue(expectedValues.containsAll(mapValues));
    assertTrue(mapValues.containsAll(expectedValues));
  }

  public void testTransformEmptyMapEquality() {
    Map<String, String> map =

            

Reported by PMD.

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

Line: 97

                  Collection<?> mapValues = map.values();
    assertEquals(expectedValues.size(), mapValues.size());
    assertTrue(expectedValues.containsAll(mapValues));
    assertTrue(mapValues.containsAll(expectedValues));
  }

  public void testTransformEmptyMapEquality() {
    Map<String, String> map =
        Maps.transformValues(ImmutableMap.<String, Integer>of(), Functions.toStringFunction());

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java
111 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 50

                    protected void shutDown() throws Exception {}
    }

    public void testServiceStartStop() throws Exception {
      AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());

            

Reported by PMD.

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

Line: 50

                    protected void shutDown() throws Exception {}
    }

    public void testServiceStartStop() throws Exception {
      AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());

            

Reported by PMD.

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

Line: 52

              
    public void testServiceStartStop() throws Exception {
      AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                  public void testServiceStartStop() throws Exception {
      AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {

            

Reported by PMD.

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

Line: 54

                    AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 55

                    service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");
      AbstractIdleService service =

            

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

                    assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");
      AbstractIdleService service =
          new DefaultService() {
            @Override
            protected void startUp() throws Exception {

            

Reported by PMD.

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

Line: 58

                    assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");
      AbstractIdleService service =
          new DefaultService() {
            @Override
            protected void startUp() throws Exception {

            

Reported by PMD.

The String literal 'deliberate' appears 4 times in this file; the first occurrence is on line 59
Error

Line: 59

                  }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");
      AbstractIdleService service =
          new DefaultService() {
            @Override
            protected void startUp() throws Exception {
              throw exception;

            

Reported by PMD.

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

Line: 68

                          }
          };
      try {
        service.startAsync().awaitRunning();
        fail();
      } catch (RuntimeException e) {
        assertThat(e).hasCauseThat().isSameInstanceAs(exception);
      }
      assertEquals(Service.State.FAILED, service.state());

            

Reported by PMD.

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

Line: 32

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class UnsignedIntegerTest extends TestCase {
  private static final ImmutableSet<Integer> TEST_INTS;
  private static final ImmutableSet<Long> TEST_LONGS;

  private static int force32(int value) {
    // GWT doesn't consistently overflow values to make them 32-bit, so we need to force it.

            

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

                  TEST_LONGS = testLongsBuilder.build();
  }

  public void testFromIntBitsAndIntValueAreInverses() {
    for (int value : TEST_INTS) {
      assertEquals(
          UnsignedInts.toString(value), value, UnsignedInteger.fromIntBits(value).intValue());
    }
  }

            

Reported by PMD.

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

Line: 62

                public void testFromIntBitsAndIntValueAreInverses() {
    for (int value : TEST_INTS) {
      assertEquals(
          UnsignedInts.toString(value), value, UnsignedInteger.fromIntBits(value).intValue());
    }
  }

  public void testFromIntBitsLongValue() {
    for (int value : TEST_INTS) {

            

Reported by PMD.

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

Line: 66

                  }
  }

  public void testFromIntBitsLongValue() {
    for (int value : TEST_INTS) {
      long expected = value & 0xffffffffL;
      assertEquals(
          UnsignedInts.toString(value), expected, UnsignedInteger.fromIntBits(value).longValue());
    }

            

Reported by PMD.

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

Line: 70

                  for (int value : TEST_INTS) {
      long expected = value & 0xffffffffL;
      assertEquals(
          UnsignedInts.toString(value), expected, UnsignedInteger.fromIntBits(value).longValue());
    }
  }

  public void testValueOfLong() {
    long min = 0;

            

Reported by PMD.

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

Line: 74

                  }
  }

  public void testValueOfLong() {
    long min = 0;
    long max = (1L << 32) - 1;
    for (long value : TEST_LONGS) {
      boolean expectSuccess = value >= min && value <= max;
      try {

            

Reported by PMD.

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

Line: 74

                  }
  }

  public void testValueOfLong() {
    long min = 0;
    long max = (1L << 32) - 1;
    for (long value : TEST_LONGS) {
      boolean expectSuccess = value >= min && value <= max;
      try {

            

Reported by PMD.

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

Line: 80

                  for (long value : TEST_LONGS) {
      boolean expectSuccess = value >= min && value <= max;
      try {
        assertEquals(value, UnsignedInteger.valueOf(value).longValue());
        assertTrue(expectSuccess);
      } catch (IllegalArgumentException e) {
        assertFalse(expectSuccess);
      }
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 80

                  for (long value : TEST_LONGS) {
      boolean expectSuccess = value >= min && value <= max;
      try {
        assertEquals(value, UnsignedInteger.valueOf(value).longValue());
        assertTrue(expectSuccess);
      } catch (IllegalArgumentException e) {
        assertFalse(expectSuccess);
      }
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 81

                    boolean expectSuccess = value >= min && value <= max;
      try {
        assertEquals(value, UnsignedInteger.valueOf(value).longValue());
        assertTrue(expectSuccess);
      } catch (IllegalArgumentException e) {
        assertFalse(expectSuccess);
      }
    }
  }

            

Reported by PMD.

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

Line: 32

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class UnsignedIntegerTest extends TestCase {
  private static final ImmutableSet<Integer> TEST_INTS;
  private static final ImmutableSet<Long> TEST_LONGS;

  private static int force32(int value) {
    // GWT doesn't consistently overflow values to make them 32-bit, so we need to force it.

            

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

                  TEST_LONGS = testLongsBuilder.build();
  }

  public void testFromIntBitsAndIntValueAreInverses() {
    for (int value : TEST_INTS) {
      assertEquals(
          UnsignedInts.toString(value), value, UnsignedInteger.fromIntBits(value).intValue());
    }
  }

            

Reported by PMD.

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

Line: 62

                public void testFromIntBitsAndIntValueAreInverses() {
    for (int value : TEST_INTS) {
      assertEquals(
          UnsignedInts.toString(value), value, UnsignedInteger.fromIntBits(value).intValue());
    }
  }

  public void testFromIntBitsLongValue() {
    for (int value : TEST_INTS) {

            

Reported by PMD.

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

Line: 66

                  }
  }

  public void testFromIntBitsLongValue() {
    for (int value : TEST_INTS) {
      long expected = value & 0xffffffffL;
      assertEquals(
          UnsignedInts.toString(value), expected, UnsignedInteger.fromIntBits(value).longValue());
    }

            

Reported by PMD.

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

Line: 70

                  for (int value : TEST_INTS) {
      long expected = value & 0xffffffffL;
      assertEquals(
          UnsignedInts.toString(value), expected, UnsignedInteger.fromIntBits(value).longValue());
    }
  }

  public void testValueOfLong() {
    long min = 0;

            

Reported by PMD.

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

Line: 74

                  }
  }

  public void testValueOfLong() {
    long min = 0;
    long max = (1L << 32) - 1;
    for (long value : TEST_LONGS) {
      boolean expectSuccess = value >= min && value <= max;
      try {

            

Reported by PMD.

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

Line: 74

                  }
  }

  public void testValueOfLong() {
    long min = 0;
    long max = (1L << 32) - 1;
    for (long value : TEST_LONGS) {
      boolean expectSuccess = value >= min && value <= max;
      try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 80

                  for (long value : TEST_LONGS) {
      boolean expectSuccess = value >= min && value <= max;
      try {
        assertEquals(value, UnsignedInteger.valueOf(value).longValue());
        assertTrue(expectSuccess);
      } catch (IllegalArgumentException e) {
        assertFalse(expectSuccess);
      }
    }

            

Reported by PMD.

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

Line: 80

                  for (long value : TEST_LONGS) {
      boolean expectSuccess = value >= min && value <= max;
      try {
        assertEquals(value, UnsignedInteger.valueOf(value).longValue());
        assertTrue(expectSuccess);
      } catch (IllegalArgumentException e) {
        assertFalse(expectSuccess);
      }
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 81

                    boolean expectSuccess = value >= min && value <= max;
      try {
        assertEquals(value, UnsignedInteger.valueOf(value).longValue());
        assertTrue(expectSuccess);
      } catch (IllegalArgumentException e) {
        assertFalse(expectSuccess);
      }
    }
  }

            

Reported by PMD.

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

Line: 36

               * @author Isaac Shum
 */
@GwtCompatible
public class MapsTransformValuesTest extends MapInterfaceTest<String, String> {

  /**
   * Constructor that assigns {@code supportsIteratorRemove} the same value as {@code
   * supportsRemove}.
   */

            

Reported by PMD.

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

Line: 68

                @Override
  protected Map<String, String> makePopulatedMap() {
    Map<String, Integer> underlying = Maps.newHashMap();
    underlying.put("a", 1);
    underlying.put("b", 2);
    underlying.put("c", 3);
    return Maps.transformValues(underlying, Functions.toStringFunction());
  }


            

Reported by PMD.

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

Line: 69

                protected Map<String, String> makePopulatedMap() {
    Map<String, Integer> underlying = Maps.newHashMap();
    underlying.put("a", 1);
    underlying.put("b", 2);
    underlying.put("c", 3);
    return Maps.transformValues(underlying, Functions.toStringFunction());
  }

  @Override

            

Reported by PMD.

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

Line: 70

                  Map<String, Integer> underlying = Maps.newHashMap();
    underlying.put("a", 1);
    underlying.put("b", 2);
    underlying.put("c", 3);
    return Maps.transformValues(underlying, Functions.toStringFunction());
  }

  @Override
  protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 75

                }

  @Override
  protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
    return "z";
  }

  @Override
  protected String getValueNotInPopulatedMap() throws UnsupportedOperationException {

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 80

                }

  @Override
  protected String getValueNotInPopulatedMap() throws UnsupportedOperationException {
    return "26";
  }

  /** Helper assertion comparing two maps */
  private void assertMapsEqual(Map<?, ?> expected, Map<?, ?> map) {

            

Reported by PMD.

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

Line: 94

                  // mapValues > expectedValues; i.e. that expectedValues == mapValues.
    Collection<?> expectedValues = expected.values();
    Collection<?> mapValues = map.values();
    assertEquals(expectedValues.size(), mapValues.size());
    assertTrue(expectedValues.containsAll(mapValues));
    assertTrue(mapValues.containsAll(expectedValues));
  }

  public void testTransformEmptyMapEquality() {

            

Reported by PMD.

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

Line: 94

                  // mapValues > expectedValues; i.e. that expectedValues == mapValues.
    Collection<?> expectedValues = expected.values();
    Collection<?> mapValues = map.values();
    assertEquals(expectedValues.size(), mapValues.size());
    assertTrue(expectedValues.containsAll(mapValues));
    assertTrue(mapValues.containsAll(expectedValues));
  }

  public void testTransformEmptyMapEquality() {

            

Reported by PMD.

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

Line: 95

                  Collection<?> expectedValues = expected.values();
    Collection<?> mapValues = map.values();
    assertEquals(expectedValues.size(), mapValues.size());
    assertTrue(expectedValues.containsAll(mapValues));
    assertTrue(mapValues.containsAll(expectedValues));
  }

  public void testTransformEmptyMapEquality() {
    Map<String, String> map =

            

Reported by PMD.

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

Line: 96

                  Collection<?> mapValues = map.values();
    assertEquals(expectedValues.size(), mapValues.size());
    assertTrue(expectedValues.containsAll(mapValues));
    assertTrue(mapValues.containsAll(expectedValues));
  }

  public void testTransformEmptyMapEquality() {
    Map<String, String> map =
        Maps.transformValues(ImmutableMap.<String, Integer>of(), Functions.toStringFunction());

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java
111 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 50

                    protected void shutDown() throws Exception {}
    }

    public void testServiceStartStop() throws Exception {
      AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());

            

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

                    protected void shutDown() throws Exception {}
    }

    public void testServiceStartStop() throws Exception {
      AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());

            

Reported by PMD.

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

Line: 52

              
    public void testServiceStartStop() throws Exception {
      AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                  public void testServiceStartStop() throws Exception {
      AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {

            

Reported by PMD.

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

Line: 54

                    AbstractIdleService service = new DefaultService();
      service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 55

                    service.startAsync().awaitRunning();
      assertEquals(Service.State.RUNNING, service.state());
      service.stopAsync().awaitTerminated();
      assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");
      AbstractIdleService service =

            

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

                    assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");
      AbstractIdleService service =
          new DefaultService() {
            @Override
            protected void startUp() throws Exception {

            

Reported by PMD.

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

Line: 58

                    assertEquals(Service.State.TERMINATED, service.state());
    }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");
      AbstractIdleService service =
          new DefaultService() {
            @Override
            protected void startUp() throws Exception {

            

Reported by PMD.

The String literal 'deliberate' appears 4 times in this file; the first occurrence is on line 59
Error

Line: 59

                  }

    public void testStart_failed() throws Exception {
      final Exception exception = new Exception("deliberate");
      AbstractIdleService service =
          new DefaultService() {
            @Override
            protected void startUp() throws Exception {
              throw exception;

            

Reported by PMD.

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

Line: 68

                          }
          };
      try {
        service.startAsync().awaitRunning();
        fail();
      } catch (RuntimeException e) {
        assertThat(e).hasCauseThat().isSameInstanceAs(exception);
      }
      assertEquals(Service.State.FAILED, service.state());

            

Reported by PMD.

guava-tests/test/com/google/common/collect/HashingTest.java
110 issues
Avoid really long methods.
Design

Line: 25

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

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

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

Reported by PMD.

The method 'testSmear()' has a NCSS line count of 106.
Design

Line: 25

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

Reported by PMD.

The method testSmear() has an NCSS line count of 106
Design

Line: 25

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

Reported by PMD.

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

Line: 25

              /** Tests for {@code Hashing}. */
@GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

              @GwtCompatible
public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

              public class HashingTest extends TestCase {
  public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));
    assertEquals(-1645495900, smear(-723955400));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                public void testSmear() {
    assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));
    assertEquals(-1645495900, smear(-723955400));
    assertEquals(766424523, smear(1033096058));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                  assertEquals(1459320713, smear(754102528));
    assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));
    assertEquals(-1645495900, smear(-723955400));
    assertEquals(766424523, smear(1033096058));
    assertEquals(-757003149, smear(-1690734402));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                  assertEquals(-160560296, smear(1234567890));
    assertEquals(-1017931171, smear(1));
    assertEquals(-1350072884, smear(-2000000000));
    assertEquals(-809843551, smear(2000000000));
    assertEquals(-309370926, smear(-1155484576));
    assertEquals(-1645495900, smear(-723955400));
    assertEquals(766424523, smear(1033096058));
    assertEquals(-757003149, smear(-1690734402));
    assertEquals(-245078984, smear(-1557280266));

            

Reported by PMD.