The following issues were found

android/guava-testlib/src/com/google/common/collect/testing/google/MultimapSizeTester.java
34 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: 42

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapSizeTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {

  public void testSize() {
    int expectedSize = getNumElements();
    Multimap<K, V> multimap = multimap();
    assertEquals(expectedSize, multimap.size());

    int size = 0;

            

Reported by PMD.

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

Line: 42

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapSizeTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {

  public void testSize() {
    int expectedSize = getNumElements();
    Multimap<K, V> multimap = multimap();
    assertEquals(expectedSize, multimap.size());

    int size = 0;

            

Reported by PMD.

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

Line: 45

                public void testSize() {
    int expectedSize = getNumElements();
    Multimap<K, V> multimap = multimap();
    assertEquals(expectedSize, multimap.size());

    int size = 0;
    for (Entry<K, V> entry : multimap.entries()) {
      assertTrue(multimap.containsEntry(entry.getKey(), entry.getValue()));
      size++;

            

Reported by PMD.

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

Line: 55

                  assertEquals(expectedSize, size);

    int size2 = 0;
    for (Entry<K, Collection<V>> entry2 : multimap.asMap().entrySet()) {
      size2 += entry2.getValue().size();
    }
    assertEquals(expectedSize, size2);
  }


            

Reported by PMD.

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

Line: 56

              
    int size2 = 0;
    for (Entry<K, Collection<V>> entry2 : multimap.asMap().entrySet()) {
      size2 += entry2.getValue().size();
    }
    assertEquals(expectedSize, size2);
  }

  @CollectionSize.Require(ZERO)

            

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

                  assertEquals(expectedSize, size2);
  }

  @CollectionSize.Require(ZERO)
  public void testIsEmptyYes() {
    assertTrue(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 63

              
  @CollectionSize.Require(ZERO)
  public void testIsEmptyYes() {
    assertTrue(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testIsEmptyNo() {
    assertFalse(multimap().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: 66

                  assertTrue(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testIsEmptyNo() {
    assertFalse(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 68

              
  @CollectionSize.Require(absent = ZERO)
  public void testIsEmptyNo() {
    assertFalse(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testSizeNullKey() {

            

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

                  assertFalse(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testSizeNullKey() {
    initMultimapWithNullKey();
    assertEquals(getNumElements(), multimap().size());
    assertFalse(multimap().isEmpty());

            

Reported by PMD.

android/guava/src/com/google/common/collect/ImmutableMultiset.java
34 issues
Avoid reassigning parameters such as 'offset'
Design

Line: 285

              
  @GwtIncompatible // not present in emulated superclass
  @Override
  int copyIntoArray(Object[] dst, int offset) {
    for (Multiset.Entry<E> entry : entrySet()) {
      Arrays.fill(dst, offset, offset + entry.getCount(), entry.getElement());
      offset += entry.getCount();
    }
    return offset;

            

Reported by PMD.

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

Line: 54

              @SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMultiset<E> extends ImmutableMultisetGwtSerializationDependencies<E>
    implements Multiset<E> {
  /**
   * Returns the empty immutable multiset.
   *
   * <p><b>Performance note:</b> the instance returned is a singleton.
   */

            

Reported by PMD.

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

Line: 150

                  if (elements instanceof ImmutableMultiset) {
      @SuppressWarnings("unchecked") // all supported methods are covariant
      ImmutableMultiset<E> result = (ImmutableMultiset<E>) elements;
      if (!result.isPartialView()) {
        return result;
      }
    }
    ImmutableMultiset.Builder<E> builder =
        new ImmutableMultiset.Builder<E>(Multisets.inferDistinctElements(elements));

            

Reported by PMD.

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

Line: 187

              
  @Override
  public UnmodifiableIterator<E> iterator() {
    final Iterator<Entry<E>> entryIterator = entrySet().iterator();
    return new UnmodifiableIterator<E>() {
      int remaining;
      @CheckForNull E element;

      @Override

            

Reported by PMD.

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

Line: 201

                    public E next() {
        if (remaining <= 0) {
          Entry<E> entry = entryIterator.next();
          element = entry.getElement();
          remaining = entry.getCount();
        }
        remaining--;
        /*
         * requireNonNull is safe because `remaining` starts at 0, forcing us to initialize

            

Reported by PMD.

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

Line: 202

                      if (remaining <= 0) {
          Entry<E> entry = entryIterator.next();
          element = entry.getElement();
          remaining = entry.getCount();
        }
        remaining--;
        /*
         * requireNonNull is safe because `remaining` starts at 0, forcing us to initialize
         * `element` above. After that, we never clear it.

            

Reported by PMD.

Field asList has the same name as a method
Error

Line: 214

                  };
  }

  @LazyInit @CheckForNull private transient ImmutableList<E> asList;

  @Override
  public ImmutableList<E> asList() {
    ImmutableList<E> result = asList;
    return (result == null) ? asList = super.asList() : result;

            

Reported by PMD.

The String literal 'Always throws UnsupportedOperationException' appears 4 times in this file; the first occurrence is on line 236
Error

Line: 236

                @CanIgnoreReturnValue
  @Deprecated
  @Override
  @DoNotCall("Always throws UnsupportedOperationException")
  public final int add(E element, int occurrences) {
    throw new UnsupportedOperationException();
  }

  /**

            

Reported by PMD.

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

Line: 305

              
  @Override
  public String toString() {
    return entrySet().toString();
  }

  /** @since 21.0 (present with return type {@code Set} since 2.0) */
  @Override
  public abstract ImmutableSet<E> elementSet();

            

Reported by PMD.

Field entrySet has the same name as a method
Error

Line: 312

                @Override
  public abstract ImmutableSet<E> elementSet();

  @LazyInit @CheckForNull private transient ImmutableSet<Entry<E>> entrySet;

  @Override
  public ImmutableSet<Entry<E>> entrySet() {
    ImmutableSet<Entry<E>> es = entrySet;
    return (es == null) ? (entrySet = createEntrySet()) : es;

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
34 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: 42

               */
@GwtCompatible(emulated = true)
public class FluentFutureTest extends TestCase {
  public void testFromFluentFuture() {
    FluentFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromFluentFuturePassingAsNonFluent() {

            

Reported by PMD.

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

Line: 44

              public class FluentFutureTest extends TestCase {
  public void testFromFluentFuture() {
    FluentFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromFluentFuturePassingAsNonFluent() {
    ListenableFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);

            

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

                  assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromFluentFuturePassingAsNonFluent() {
    ListenableFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromNonFluentFuture() throws Exception {

            

Reported by PMD.

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

Line: 49

              
  public void testFromFluentFuturePassingAsNonFluent() {
    ListenableFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromNonFluentFuture() throws Exception {
    ListenableFuture<String> f =
        new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};

            

Reported by PMD.

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

Line: 52

                  assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromNonFluentFuture() throws Exception {
    ListenableFuture<String> f =
        new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};
    verify(!(f instanceof FluentFuture));
    assertThat(FluentFuture.from(f).get()).isEqualTo("a");
    // TODO(cpovirk): Test forwarding more extensively.

            

Reported by PMD.

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

Line: 56

                  ListenableFuture<String> f =
        new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};
    verify(!(f instanceof FluentFuture));
    assertThat(FluentFuture.from(f).get()).isEqualTo("a");
    // TODO(cpovirk): Test forwarding more extensively.
  }

  public void testAddCallback() {
    FluentFuture<String> f = FluentFuture.from(immediateFuture("a"));

            

Reported by PMD.

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

Line: 56

                  ListenableFuture<String> f =
        new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};
    verify(!(f instanceof FluentFuture));
    assertThat(FluentFuture.from(f).get()).isEqualTo("a");
    // TODO(cpovirk): Test forwarding more extensively.
  }

  public void testAddCallback() {
    FluentFuture<String> f = FluentFuture.from(immediateFuture("a"));

            

Reported by PMD.

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

Line: 60

                  // TODO(cpovirk): Test forwarding more extensively.
  }

  public void testAddCallback() {
    FluentFuture<String> f = FluentFuture.from(immediateFuture("a"));
    final boolean[] called = new boolean[1];
    f.addCallback(
        new FutureCallback<String>() {
          @Override

            

Reported by PMD.

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

Line: 74

                        public void onFailure(Throwable t) {}
        },
        directExecutor());
    assertThat(called[0]).isTrue();
  }

  public void testCatching() throws Exception {
    FluentFuture<?> f =
        FluentFuture.from(immediateFailedFuture(new RuntimeException()))

            

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

                  assertThat(called[0]).isTrue();
  }

  public void testCatching() throws Exception {
    FluentFuture<?> f =
        FluentFuture.from(immediateFailedFuture(new RuntimeException()))
            .catching(
                Throwable.class,
                new Function<Throwable, Class<?>>() {

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultimapSizeTester.java
34 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: 42

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapSizeTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {

  public void testSize() {
    int expectedSize = getNumElements();
    Multimap<K, V> multimap = multimap();
    assertEquals(expectedSize, multimap.size());

    int size = 0;

            

Reported by PMD.

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

Line: 42

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapSizeTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {

  public void testSize() {
    int expectedSize = getNumElements();
    Multimap<K, V> multimap = multimap();
    assertEquals(expectedSize, multimap.size());

    int size = 0;

            

Reported by PMD.

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

Line: 45

                public void testSize() {
    int expectedSize = getNumElements();
    Multimap<K, V> multimap = multimap();
    assertEquals(expectedSize, multimap.size());

    int size = 0;
    for (Entry<K, V> entry : multimap.entries()) {
      assertTrue(multimap.containsEntry(entry.getKey(), entry.getValue()));
      size++;

            

Reported by PMD.

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

Line: 55

                  assertEquals(expectedSize, size);

    int size2 = 0;
    for (Entry<K, Collection<V>> entry2 : multimap.asMap().entrySet()) {
      size2 += entry2.getValue().size();
    }
    assertEquals(expectedSize, size2);
  }


            

Reported by PMD.

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

Line: 56

              
    int size2 = 0;
    for (Entry<K, Collection<V>> entry2 : multimap.asMap().entrySet()) {
      size2 += entry2.getValue().size();
    }
    assertEquals(expectedSize, size2);
  }

  @CollectionSize.Require(ZERO)

            

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

                  assertEquals(expectedSize, size2);
  }

  @CollectionSize.Require(ZERO)
  public void testIsEmptyYes() {
    assertTrue(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 63

              
  @CollectionSize.Require(ZERO)
  public void testIsEmptyYes() {
    assertTrue(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testIsEmptyNo() {
    assertFalse(multimap().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: 66

                  assertTrue(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testIsEmptyNo() {
    assertFalse(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 68

              
  @CollectionSize.Require(absent = ZERO)
  public void testIsEmptyNo() {
    assertFalse(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testSizeNullKey() {

            

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

                  assertFalse(multimap().isEmpty());
  }

  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testSizeNullKey() {
    initMultimapWithNullKey();
    assertEquals(getNumElements(), multimap().size());
    assertFalse(multimap().isEmpty());

            

Reported by PMD.

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

Line: 41

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public abstract class AbstractMapTester<K, V>
    extends AbstractContainerTester<Map<K, V>, Entry<K, V>> {
  protected Map<K, V> getMap() {
    return container;
  }

  @Override

            

Reported by PMD.

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

Line: 48

              
  @Override
  protected Collection<Entry<K, V>> actualContents() {
    return getMap().entrySet();
  }

  /** @see AbstractContainerTester#resetContainer() */
  protected final void resetMap() {
    resetContainer();

            

Reported by PMD.

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

Line: 62

              
  protected void expectMissingKeys(K... elements) {
    for (K element : elements) {
      assertFalse("Should not contain key " + element, getMap().containsKey(element));
    }
  }

  protected void expectMissingValues(V... elements) {
    for (V element : elements) {

            

Reported by PMD.

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

Line: 68

              
  protected void expectMissingValues(V... elements) {
    for (V element : elements) {
      assertFalse("Should not contain value " + element, getMap().containsValue(element));
    }
  }

  /** @return an array of the proper size with {@code null} as the key of the middle element. */
  protected Entry<K, V>[] createArrayWithNullKey() {

            

Reported by PMD.

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

Line: 77

                  Entry<K, V>[] array = createSamplesArray();
    final int nullKeyLocation = getNullLocation();
    final Entry<K, V> oldEntry = array[nullKeyLocation];
    array[nullKeyLocation] = entry(null, oldEntry.getValue());
    return array;
  }

  protected V getValueForNullKey() {
    return getEntryNullReplaces().getValue();

            

Reported by PMD.

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

Line: 82

                }

  protected V getValueForNullKey() {
    return getEntryNullReplaces().getValue();
  }

  protected K getKeyForNullValue() {
    return getEntryNullReplaces().getKey();
  }

            

Reported by PMD.

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

Line: 86

                }

  protected K getKeyForNullValue() {
    return getEntryNullReplaces().getKey();
  }

  private Entry<K, V> getEntryNullReplaces() {
    Iterator<Entry<K, V>> entries = getSampleElements().iterator();
    for (int i = 0; i < getNullLocation(); i++) {

            

Reported by PMD.

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

Line: 90

                }

  private Entry<K, V> getEntryNullReplaces() {
    Iterator<Entry<K, V>> entries = getSampleElements().iterator();
    for (int i = 0; i < getNullLocation(); i++) {
      entries.next();
    }
    return entries.next();
  }

            

Reported by PMD.

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

Line: 102

                  Entry<K, V>[] array = createSamplesArray();
    final int nullValueLocation = getNullLocation();
    final Entry<K, V> oldEntry = array[nullValueLocation];
    array[nullValueLocation] = entry(oldEntry.getKey(), null);
    return array;
  }

  protected void initMapWithNullKey() {
    resetMap(createArrayWithNullKey());

            

Reported by PMD.

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

Line: 122

                 */
  protected void expectNullKeyMissingWhenNullKeysUnsupported(String message) {
    try {
      assertFalse(message, getMap().containsKey(null));
    } catch (NullPointerException tolerated) {
      // Tolerated
    }
  }


            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
34 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: 42

               */
@GwtCompatible(emulated = true)
public class FluentFutureTest extends TestCase {
  public void testFromFluentFuture() {
    FluentFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromFluentFuturePassingAsNonFluent() {

            

Reported by PMD.

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

Line: 44

              public class FluentFutureTest extends TestCase {
  public void testFromFluentFuture() {
    FluentFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromFluentFuturePassingAsNonFluent() {
    ListenableFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);

            

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

                  assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromFluentFuturePassingAsNonFluent() {
    ListenableFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromNonFluentFuture() throws Exception {

            

Reported by PMD.

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

Line: 49

              
  public void testFromFluentFuturePassingAsNonFluent() {
    ListenableFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
    assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromNonFluentFuture() throws Exception {
    ListenableFuture<String> f =
        new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};

            

Reported by PMD.

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

Line: 52

                  assertThat(FluentFuture.from(f)).isSameInstanceAs(f);
  }

  public void testFromNonFluentFuture() throws Exception {
    ListenableFuture<String> f =
        new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};
    verify(!(f instanceof FluentFuture));
    assertThat(FluentFuture.from(f).get()).isEqualTo("a");
    // TODO(cpovirk): Test forwarding more extensively.

            

Reported by PMD.

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

Line: 56

                  ListenableFuture<String> f =
        new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};
    verify(!(f instanceof FluentFuture));
    assertThat(FluentFuture.from(f).get()).isEqualTo("a");
    // TODO(cpovirk): Test forwarding more extensively.
  }

  public void testAddCallback() {
    FluentFuture<String> f = FluentFuture.from(immediateFuture("a"));

            

Reported by PMD.

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

Line: 56

                  ListenableFuture<String> f =
        new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};
    verify(!(f instanceof FluentFuture));
    assertThat(FluentFuture.from(f).get()).isEqualTo("a");
    // TODO(cpovirk): Test forwarding more extensively.
  }

  public void testAddCallback() {
    FluentFuture<String> f = FluentFuture.from(immediateFuture("a"));

            

Reported by PMD.

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

Line: 60

                  // TODO(cpovirk): Test forwarding more extensively.
  }

  public void testAddCallback() {
    FluentFuture<String> f = FluentFuture.from(immediateFuture("a"));
    final boolean[] called = new boolean[1];
    f.addCallback(
        new FutureCallback<String>() {
          @Override

            

Reported by PMD.

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

Line: 74

                        public void onFailure(Throwable t) {}
        },
        directExecutor());
    assertThat(called[0]).isTrue();
  }

  public void testCatching() throws Exception {
    FluentFuture<?> f =
        FluentFuture.from(immediateFailedFuture(new RuntimeException()))

            

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

                  assertThat(called[0]).isTrue();
  }

  public void testCatching() throws Exception {
    FluentFuture<?> f =
        FluentFuture.from(immediateFailedFuture(new RuntimeException()))
            .catching(
                Throwable.class,
                new Function<Throwable, Class<?>>() {

            

Reported by PMD.

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

Line: 42

              @SuppressWarnings("unchecked") // too many "unchecked generic array creations"
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListAddAllAtIndexTester<E> extends AbstractListTester<E> {
  @ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
  @CollectionSize.Require(absent = ZERO)
  public void testAddAllAtIndex_supportedAllPresent() {
    assertTrue(
        "addAll(n, allPresent) should return true",

            

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

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListAddAllAtIndexTester<E> extends AbstractListTester<E> {
  @ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
  @CollectionSize.Require(absent = ZERO)
  public void testAddAllAtIndex_supportedAllPresent() {
    assertTrue(
        "addAll(n, allPresent) should return true",
        getList().addAll(0, MinimalCollection.of(e0())));

            

Reported by PMD.

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

Line: 48

                public void testAddAllAtIndex_supportedAllPresent() {
    assertTrue(
        "addAll(n, allPresent) should return true",
        getList().addAll(0, MinimalCollection.of(e0())));
    expectAdded(0, e0());
  }

  @ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
  @CollectionSize.Require(absent = ZERO)

            

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

                  expectAdded(0, e0());
  }

  @ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
  @CollectionSize.Require(absent = ZERO)
  public void testAddAllAtIndex_unsupportedAllPresent() {
    try {
      getList().addAll(0, MinimalCollection.of(e0()));
      fail("addAll(n, allPresent) should throw");

            

Reported by PMD.

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

Line: 56

                @CollectionSize.Require(absent = ZERO)
  public void testAddAllAtIndex_unsupportedAllPresent() {
    try {
      getList().addAll(0, MinimalCollection.of(e0()));
      fail("addAll(n, allPresent) should throw");
    } catch (UnsupportedOperationException expected) {
    }
    expectUnchanged();
  }

            

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

                  expectUnchanged();
  }

  @ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
  @CollectionSize.Require(absent = ZERO)
  public void testAddAllAtIndex_supportedSomePresent() {
    assertTrue(
        "addAll(n, allPresent) should return true",
        getList().addAll(0, MinimalCollection.of(e0(), e3())));

            

Reported by PMD.

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

Line: 68

                public void testAddAllAtIndex_supportedSomePresent() {
    assertTrue(
        "addAll(n, allPresent) should return true",
        getList().addAll(0, MinimalCollection.of(e0(), e3())));
    expectAdded(0, e0(), e3());
  }

  @ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
  @CollectionSize.Require(absent = ZERO)

            

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

                  expectAdded(0, e0(), e3());
  }

  @ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
  @CollectionSize.Require(absent = ZERO)
  public void testAddAllAtIndex_unsupportedSomePresent() {
    try {
      getList().addAll(0, MinimalCollection.of(e0(), e3()));
      fail("addAll(n, allPresent) should throw");

            

Reported by PMD.

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

Line: 76

                @CollectionSize.Require(absent = ZERO)
  public void testAddAllAtIndex_unsupportedSomePresent() {
    try {
      getList().addAll(0, MinimalCollection.of(e0(), e3()));
      fail("addAll(n, allPresent) should throw");
    } catch (UnsupportedOperationException expected) {
    }
    expectUnchanged();
    expectMissing(e3());

            

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

                  expectMissing(e3());
  }

  @ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
  public void testAddAllAtIndex_supportedNothing() {
    assertFalse("addAll(n, nothing) should return false", getList().addAll(0, emptyCollection()));
    expectUnchanged();
  }


            

Reported by PMD.

guava-tests/test/com/google/common/collect/FauxveridesTest.java
34 issues
Avoid reassigning parameters such as 'descendant'
Design

Line: 150

                }

  /** [descendant, ancestor) */
  private static Set<Class<?>> getClassesBetween(Class<?> descendant, Class<?> ancestor) {
    Set<Class<?>> classes = newHashSet();

    while (!descendant.equals(ancestor)) {
      classes.add(descendant);
      descendant = descendant.getSuperclass();

            

Reported by PMD.

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

Line: 45

               *
 * @author Chris Povirk
 */
public class FauxveridesTest extends TestCase {
  public void testImmutableBiMap() {
    doHasAllFauxveridesTest(ImmutableBiMap.class, ImmutableMap.class);
  }

  public void testImmutableListMultimap() {

            

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

               * @author Chris Povirk
 */
public class FauxveridesTest extends TestCase {
  public void testImmutableBiMap() {
    doHasAllFauxveridesTest(ImmutableBiMap.class, ImmutableMap.class);
  }

  public void testImmutableListMultimap() {
    doHasAllFauxveridesTest(ImmutableListMultimap.class, ImmutableMultimap.class);

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 46

               * @author Chris Povirk
 */
public class FauxveridesTest extends TestCase {
  public void testImmutableBiMap() {
    doHasAllFauxveridesTest(ImmutableBiMap.class, ImmutableMap.class);
  }

  public void testImmutableListMultimap() {
    doHasAllFauxveridesTest(ImmutableListMultimap.class, ImmutableMultimap.class);

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 50

                  doHasAllFauxveridesTest(ImmutableBiMap.class, ImmutableMap.class);
  }

  public void testImmutableListMultimap() {
    doHasAllFauxveridesTest(ImmutableListMultimap.class, ImmutableMultimap.class);
  }

  public void testImmutableSetMultimap() {
    doHasAllFauxveridesTest(ImmutableSetMultimap.class, ImmutableMultimap.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: 50

                  doHasAllFauxveridesTest(ImmutableBiMap.class, ImmutableMap.class);
  }

  public void testImmutableListMultimap() {
    doHasAllFauxveridesTest(ImmutableListMultimap.class, ImmutableMultimap.class);
  }

  public void testImmutableSetMultimap() {
    doHasAllFauxveridesTest(ImmutableSetMultimap.class, ImmutableMultimap.class);

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 54

                  doHasAllFauxveridesTest(ImmutableListMultimap.class, ImmutableMultimap.class);
  }

  public void testImmutableSetMultimap() {
    doHasAllFauxveridesTest(ImmutableSetMultimap.class, ImmutableMultimap.class);
  }

  public void testImmutableSortedMap() {
    doHasAllFauxveridesTest(ImmutableSortedMap.class, ImmutableMap.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: 54

                  doHasAllFauxveridesTest(ImmutableListMultimap.class, ImmutableMultimap.class);
  }

  public void testImmutableSetMultimap() {
    doHasAllFauxveridesTest(ImmutableSetMultimap.class, ImmutableMultimap.class);
  }

  public void testImmutableSortedMap() {
    doHasAllFauxveridesTest(ImmutableSortedMap.class, ImmutableMap.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: 58

                  doHasAllFauxveridesTest(ImmutableSetMultimap.class, ImmutableMultimap.class);
  }

  public void testImmutableSortedMap() {
    doHasAllFauxveridesTest(ImmutableSortedMap.class, ImmutableMap.class);
  }

  public void testImmutableSortedSet() {
    doHasAllFauxveridesTest(ImmutableSortedSet.class, ImmutableSet.class);

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 58

                  doHasAllFauxveridesTest(ImmutableSetMultimap.class, ImmutableMultimap.class);
  }

  public void testImmutableSortedMap() {
    doHasAllFauxveridesTest(ImmutableSortedMap.class, ImmutableMap.class);
  }

  public void testImmutableSortedSet() {
    doHasAllFauxveridesTest(ImmutableSortedSet.class, ImmutableSet.class);

            

Reported by PMD.

guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java
34 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: 32

               */
public class AbstractByteHasherTest extends TestCase {

  public void testBytes() {
    TestHasher hasher = new TestHasher(); // byte order insignificant here
    byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
    hasher.putByte((byte) 1);
    hasher.putBytes(new byte[] {2, 3, 4, 5, 6});
    hasher.putByte((byte) 7);

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 32

               */
public class AbstractByteHasherTest extends TestCase {

  public void testBytes() {
    TestHasher hasher = new TestHasher(); // byte order insignificant here
    byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
    hasher.putByte((byte) 1);
    hasher.putBytes(new byte[] {2, 3, 4, 5, 6});
    hasher.putByte((byte) 7);

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 43

                  hasher.assertBytes(expected);
  }

  public void testShort() {
    TestHasher hasher = new TestHasher();
    hasher.putShort((short) 0x0201);
    hasher.assertBytes(new byte[] {1, 2});
  }


            

Reported by PMD.

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

Line: 43

                  hasher.assertBytes(expected);
  }

  public void testShort() {
    TestHasher hasher = new TestHasher();
    hasher.putShort((short) 0x0201);
    hasher.assertBytes(new byte[] {1, 2});
  }


            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 49

                  hasher.assertBytes(new byte[] {1, 2});
  }

  public void testInt() {
    TestHasher hasher = new TestHasher();
    hasher.putInt(0x04030201);
    hasher.assertBytes(new byte[] {1, 2, 3, 4});
  }


            

Reported by PMD.

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

Line: 49

                  hasher.assertBytes(new byte[] {1, 2});
  }

  public void testInt() {
    TestHasher hasher = new TestHasher();
    hasher.putInt(0x04030201);
    hasher.assertBytes(new byte[] {1, 2, 3, 4});
  }


            

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

                  hasher.assertBytes(new byte[] {1, 2, 3, 4});
  }

  public void testLong() {
    TestHasher hasher = new TestHasher();
    hasher.putLong(0x0807060504030201L);
    hasher.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8});
  }


            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 55

                  hasher.assertBytes(new byte[] {1, 2, 3, 4});
  }

  public void testLong() {
    TestHasher hasher = new TestHasher();
    hasher.putLong(0x0807060504030201L);
    hasher.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8});
  }


            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 61

                  hasher.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8});
  }

  public void testChar() {
    TestHasher hasher = new TestHasher();
    hasher.putChar((char) 0x0201);
    hasher.assertBytes(new byte[] {1, 2});
  }


            

Reported by PMD.

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

Line: 61

                  hasher.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8});
  }

  public void testChar() {
    TestHasher hasher = new TestHasher();
    hasher.putChar((char) 0x0201);
    hasher.assertBytes(new byte[] {1, 2});
  }


            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java
33 issues
High amount of different objects as members denotes a high coupling
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect.testing.google;

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

import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.Multiset;

            

Reported by PMD.

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

Line: 74

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(CollectionSerializationEqualTester.class);
    testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);

            

Reported by PMD.

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

Line: 75

                protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(CollectionSerializationEqualTester.class);
    testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetForEachEntryTester.class);

            

Reported by PMD.

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

Line: 76

                  List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(CollectionSerializationEqualTester.class);
    testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetForEachEntryTester.class);
    testers.add(MultisetReadsTester.class);

            

Reported by PMD.

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

Line: 77

                  testers.add(CollectionSerializationEqualTester.class);
    testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetForEachEntryTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);

            

Reported by PMD.

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

Line: 78

                  testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetForEachEntryTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);

            

Reported by PMD.

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

Line: 79

                  testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetForEachEntryTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);

            

Reported by PMD.

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

Line: 80

                  testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetForEachEntryTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);
    testers.add(MultisetEntrySetTester.class);

            

Reported by PMD.

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

Line: 81

                  testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetForEachEntryTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);
    testers.add(MultisetEntrySetTester.class);
    testers.add(MultisetIteratorTester.class);

            

Reported by PMD.

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

Line: 82

                  testers.add(MultisetEqualsTester.class);
    testers.add(MultisetForEachEntryTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);
    testers.add(MultisetEntrySetTester.class);
    testers.add(MultisetIteratorTester.class);
    testers.add(MultisetSerializationTester.class);

            

Reported by PMD.