The following issues were found

guava/src/com/google/common/io/MoreFiles.java
60 issues
Avoid reassigning parameters such as 'exceptions'
Design

Line: 766

                 * the collection.
   */
  private static Collection<IOException> addException(
      @CheckForNull Collection<IOException> exceptions, IOException e) {
    if (exceptions == null) {
      exceptions = new ArrayList<>(); // don't need Set semantics
    }
    exceptions.add(e);
    return exceptions;

            

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

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
import static java.util.Objects.requireNonNull;

            

Reported by PMD.

Possible God Class (WMC=86, ATFD=27, TCC=0.000%)
Design

Line: 74

              @GwtIncompatible
@J2ObjCIncompatible // java.nio.file
@ElementTypesAreNonnullByDefault
public final class MoreFiles {

  private MoreFiles() {}

  /**
   * Returns a view of the given {@code path} as a {@link ByteSource}.

            

Reported by PMD.

The class 'MoreFiles' has a total cyclomatic complexity of 86 (highest 9).
Design

Line: 74

              @GwtIncompatible
@J2ObjCIncompatible // java.nio.file
@ElementTypesAreNonnullByDefault
public final class MoreFiles {

  private MoreFiles() {}

  /**
   * Returns a view of the given {@code path} as a {@link ByteSource}.

            

Reported by PMD.

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

Line: 74

              @GwtIncompatible
@J2ObjCIncompatible // java.nio.file
@ElementTypesAreNonnullByDefault
public final class MoreFiles {

  private MoreFiles() {}

  /**
   * Returns a view of the given {@code path} as a {@link ByteSource}.

            

Reported by PMD.

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

Line: 94

              
    private static final LinkOption[] FOLLOW_LINKS = {};

    private final Path path;
    private final OpenOption[] options;
    private final boolean followLinks;

    private PathByteSource(Path path, OpenOption... options) {
      this.path = checkNotNull(path);

            

Reported by PMD.

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

Line: 95

                  private static final LinkOption[] FOLLOW_LINKS = {};

    private final Path path;
    private final OpenOption[] options;
    private final boolean followLinks;

    private PathByteSource(Path path, OpenOption... options) {
      this.path = checkNotNull(path);
      this.options = options.clone();

            

Reported by PMD.

Field followLinks has the same name as a method
Error

Line: 96

              
    private final Path path;
    private final OpenOption[] options;
    private final boolean followLinks;

    private PathByteSource(Path path, OpenOption... options) {
      this.path = checkNotNull(path);
      this.options = options.clone();
      this.followLinks = followLinks(this.options);

            

Reported by PMD.

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

Line: 96

              
    private final Path path;
    private final OpenOption[] options;
    private final boolean followLinks;

    private PathByteSource(Path path, OpenOption... options) {
      this.path = checkNotNull(path);
      this.options = options.clone();
      this.followLinks = followLinks(this.options);

            

Reported by PMD.

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

Line: 138

              
      // Don't return a size for directories or symbolic links; their sizes are implementation
      // specific and they can't be read as bytes using the read methods anyway.
      if (attrs.isDirectory() || attrs.isSymbolicLink()) {
        return Optional.absent();
      }

      return Optional.of(attrs.size());
    }

            

Reported by PMD.

guava-testlib/src/com/google/common/testing/NullPointerTester.java
60 issues
Avoid throwing raw exception types.
Design

Line: 370

                    error.initCause(cause);
      throw error;
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }

  private Object[] buildParamList(Invokable<?, ?> invokable, int indexOfParamToSetToNull) {
    ImmutableList<Parameter> params = invokable.getParameters();

            

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

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

import com.google.common.annotations.Beta;

            

Reported by PMD.

Possible God Class (WMC=66, ATFD=72, TCC=0.758%)
Design

Line: 73

               */
@Beta
@GwtIncompatible
public final class NullPointerTester {

  private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
  private final List<Member> ignoredMembers = Lists.newArrayList();

  private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;

            

Reported by PMD.

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

Line: 73

               */
@Beta
@GwtIncompatible
public final class NullPointerTester {

  private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
  private final List<Member> ignoredMembers = Lists.newArrayList();

  private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;

            

Reported by PMD.

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

Line: 75

              @GwtIncompatible
public final class NullPointerTester {

  private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
  private final List<Member> ignoredMembers = Lists.newArrayList();

  private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;

  /**

            

Reported by PMD.

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

Line: 76

              public final class NullPointerTester {

  private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
  private final List<Member> ignoredMembers = Lists.newArrayList();

  private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;

  /**
   * Sets a default value that can be used for any parameter of type {@code type}. Returns this

            

Reported by PMD.

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

Line: 78

                private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
  private final List<Member> ignoredMembers = Lists.newArrayList();

  private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;

  /**
   * Sets a default value that can be used for any parameter of type {@code type}. Returns this
   * object.
   */

            

Reported by PMD.

Private field 'policy' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 78

                private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
  private final List<Member> ignoredMembers = Lists.newArrayList();

  private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;

  /**
   * Sets a default value that can be used for any parameter of type {@code type}. Returns this
   * object.
   */

            

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

                 * Runs {@link #testConstructor} on every constructor in class {@code c} that has at least {@code
   * minimalVisibility}.
   */
  public void testConstructors(Class<?> c, Visibility minimalVisibility) {
    for (Constructor<?> constructor : c.getDeclaredConstructors()) {
      if (minimalVisibility.isVisible(constructor) && !isIgnored(constructor)) {
        testConstructor(constructor);
      }
    }

            

Reported by PMD.

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

Line: 122

                }

  /** Runs {@link #testConstructor} on every public constructor in class {@code c}. */
  public void testAllPublicConstructors(Class<?> c) {
    testConstructors(c, Visibility.PUBLIC);
  }

  /**
   * Runs {@link #testMethod} on every static method of class {@code c} that has at least {@code

            

Reported by PMD.

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

Line: 39

               */
@GwtCompatible
@SuppressWarnings("serial") // No serialization is used in this test
public class IteratorTesterTest extends TestCase {

  public void testCanCatchDifferentLengthOfIteration() {
    IteratorTester<Integer> tester =
        new IteratorTester<Integer>(
            4, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {

            

Reported by PMD.

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

Line: 41

              @SuppressWarnings("serial") // No serialization is used in this test
public class IteratorTesterTest extends TestCase {

  public void testCanCatchDifferentLengthOfIteration() {
    IteratorTester<Integer> tester =
        new IteratorTester<Integer>(
            4, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {

            

Reported by PMD.

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

Line: 47

                          4, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {
            return Lists.newArrayList(1, 2, 3, 4).iterator();
          }
        };
    assertFailure(tester);
  }


            

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

                  assertFailure(tester);
  }

  public void testCanCatchDifferentContents() {
    IteratorTester<Integer> tester =
        new IteratorTester<Integer>(
            3, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {

            

Reported by PMD.

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

Line: 59

                          3, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {
            return Lists.newArrayList(1, 3, 2).iterator();
          }
        };
    assertFailure(tester);
  }


            

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

                  assertFailure(tester);
  }

  public void testCanCatchDifferentRemoveBehaviour() {
    IteratorTester<Integer> tester =
        new IteratorTester<Integer>(
            3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {

            

Reported by PMD.

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

Line: 71

                          3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {
            return ImmutableList.of(1, 2).iterator();
          }
        };
    assertFailure(tester);
  }


            

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

                  assertFailure(tester);
  }

  public void testUnknownOrder() {
    new IteratorTester<Integer>(
        3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.UNKNOWN_ORDER) {
      @Override
      protected Iterator<Integer> newTargetIterator() {
        return newArrayList(2, 1).iterator();

            

Reported by PMD.

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

Line: 77

                  assertFailure(tester);
  }

  public void testUnknownOrder() {
    new IteratorTester<Integer>(
        3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.UNKNOWN_ORDER) {
      @Override
      protected Iterator<Integer> newTargetIterator() {
        return newArrayList(2, 1).iterator();

            

Reported by PMD.

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

Line: 82

                      3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.UNKNOWN_ORDER) {
      @Override
      protected Iterator<Integer> newTargetIterator() {
        return newArrayList(2, 1).iterator();
      }
    }.test();
  }

  public void testUnknownOrderUnrecognizedElement() {

            

Reported by PMD.

guava-testlib/test/com/google/common/collect/testing/IteratorTesterTest.java
59 issues
This class has too many methods, consider refactoring it.
Design

Line: 39

               */
@GwtCompatible
@SuppressWarnings("serial") // No serialization is used in this test
public class IteratorTesterTest extends TestCase {

  public void testCanCatchDifferentLengthOfIteration() {
    IteratorTester<Integer> tester =
        new IteratorTester<Integer>(
            4, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {

            

Reported by PMD.

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

Line: 41

              @SuppressWarnings("serial") // No serialization is used in this test
public class IteratorTesterTest extends TestCase {

  public void testCanCatchDifferentLengthOfIteration() {
    IteratorTester<Integer> tester =
        new IteratorTester<Integer>(
            4, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {

            

Reported by PMD.

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

Line: 47

                          4, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {
            return Lists.newArrayList(1, 2, 3, 4).iterator();
          }
        };
    assertFailure(tester);
  }


            

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

                  assertFailure(tester);
  }

  public void testCanCatchDifferentContents() {
    IteratorTester<Integer> tester =
        new IteratorTester<Integer>(
            3, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {

            

Reported by PMD.

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

Line: 59

                          3, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {
            return Lists.newArrayList(1, 3, 2).iterator();
          }
        };
    assertFailure(tester);
  }


            

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

                  assertFailure(tester);
  }

  public void testCanCatchDifferentRemoveBehaviour() {
    IteratorTester<Integer> tester =
        new IteratorTester<Integer>(
            3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {

            

Reported by PMD.

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

Line: 71

                          3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.KNOWN_ORDER) {
          @Override
          protected Iterator<Integer> newTargetIterator() {
            return ImmutableList.of(1, 2).iterator();
          }
        };
    assertFailure(tester);
  }


            

Reported by PMD.

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

Line: 77

                  assertFailure(tester);
  }

  public void testUnknownOrder() {
    new IteratorTester<Integer>(
        3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.UNKNOWN_ORDER) {
      @Override
      protected Iterator<Integer> newTargetIterator() {
        return newArrayList(2, 1).iterator();

            

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

                  assertFailure(tester);
  }

  public void testUnknownOrder() {
    new IteratorTester<Integer>(
        3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.UNKNOWN_ORDER) {
      @Override
      protected Iterator<Integer> newTargetIterator() {
        return newArrayList(2, 1).iterator();

            

Reported by PMD.

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

Line: 82

                      3, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.UNKNOWN_ORDER) {
      @Override
      protected Iterator<Integer> newTargetIterator() {
        return newArrayList(2, 1).iterator();
      }
    }.test();
  }

  public void testUnknownOrderUnrecognizedElement() {

            

Reported by PMD.

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

Line: 38

              
/** Tests the package level *impl methods directly using various types of lists. */
@GwtCompatible(emulated = true)
public class ListsImplTest extends TestCase {

  /** Describes how a list is modifiable */
  public enum Modifiability {
    NONE, // immutable lists
    BY_ELEMENT, // elements can change (set), but not structure

            

Reported by PMD.

Field modifiability has the same name as a method
Error

Line: 52

                public abstract static class ListExample {

    private final String name;
    private final Modifiability modifiability;

    protected ListExample(String name, Modifiability modifiability) {
      this.name = name;
      this.modifiability = modifiability;
    }

            

Reported by PMD.

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

Line: 52

                public abstract static class ListExample {

    private final String name;
    private final Modifiability modifiability;

    protected ListExample(String name, Modifiability modifiability) {
      this.name = name;
      this.modifiability = modifiability;
    }

            

Reported by PMD.

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

Line: 73

                  }
  }

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(createExampleSuite(new ArrayListExample("ArrayList")));
    suite.addTest(createExampleSuite(new LinkedListExample("LinkedList")));
    suite.addTest(createExampleSuite(new ArraysAsListExample("Arrays.asList")));

            

Reported by PMD.

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

Line: 88

                @GwtIncompatible // suite sub call
  private static TestSuite createExampleSuite(ListExample example) {
    TestSuite resultSuite = new TestSuite(ListsImplTest.class);
    for (Enumeration<Test> testEnum = resultSuite.tests(); testEnum.hasMoreElements(); ) {
      ListsImplTest test = (ListsImplTest) testEnum.nextElement();
      test.example = example;
    }
    return resultSuite;
  }

            

Reported by PMD.

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

Line: 89

                private static TestSuite createExampleSuite(ListExample example) {
    TestSuite resultSuite = new TestSuite(ListsImplTest.class);
    for (Enumeration<Test> testEnum = resultSuite.tests(); testEnum.hasMoreElements(); ) {
      ListsImplTest test = (ListsImplTest) testEnum.nextElement();
      test.example = example;
    }
    return resultSuite;
  }


            

Reported by PMD.

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

Line: 95

                  return resultSuite;
  }

  private ListExample example;

  private ListExample getExample() {
    // because sometimes one version with a null example is created.
    return example == null ? new ImmutableListExample("test") : example;
  }

            

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

                  return super.getName() + ":" + example.getName();
  }

  public void testHashCodeImpl() {
    List<Integer> base = createList(Integer.class, 1, 2, 2);
    List<Integer> copy = createList(Integer.class, 1, 2, 2);
    List<Integer> outOfOrder = createList(Integer.class, 2, 2, 1);
    List<Integer> diffValue = createList(Integer.class, 1, 2, 4);
    List<Integer> diffLength = createList(Integer.class, 1, 2);

            

Reported by PMD.

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

Line: 111

                  return super.getName() + ":" + example.getName();
  }

  public void testHashCodeImpl() {
    List<Integer> base = createList(Integer.class, 1, 2, 2);
    List<Integer> copy = createList(Integer.class, 1, 2, 2);
    List<Integer> outOfOrder = createList(Integer.class, 2, 2, 1);
    List<Integer> diffValue = createList(Integer.class, 1, 2, 4);
    List<Integer> diffLength = createList(Integer.class, 1, 2);

            

Reported by PMD.

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

Line: 119

                  List<Integer> diffLength = createList(Integer.class, 1, 2);
    List<Integer> empty = createList(Integer.class);

    assertThat(Lists.hashCodeImpl(base)).isEqualTo(Lists.hashCodeImpl(copy));

    assertThat(Lists.hashCodeImpl(base)).isNotEqualTo(Lists.hashCodeImpl(outOfOrder));
    assertThat(Lists.hashCodeImpl(base)).isNotEqualTo(Lists.hashCodeImpl(diffValue));
    assertThat(Lists.hashCodeImpl(base)).isNotEqualTo(Lists.hashCodeImpl(diffLength));
    assertThat(Lists.hashCodeImpl(base)).isNotEqualTo(Lists.hashCodeImpl(empty));

            

Reported by PMD.

guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java
58 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 51

               * @see ImmutableSortedMap
 * @author Hayward Chan
 */
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
  static final ImmutableMap<Object, Object> EMPTY = new RegularImmutableMap<Object, Object>();

  abstract static class IteratorBasedImmutableMap<K, V> extends ImmutableMap<K, V> {
    abstract UnmodifiableIterator<Entry<K, V>> entryIterator();


            

Reported by PMD.

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

Line: 51

               * @see ImmutableSortedMap
 * @author Hayward Chan
 */
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
  static final ImmutableMap<Object, Object> EMPTY = new RegularImmutableMap<Object, Object>();

  abstract static class IteratorBasedImmutableMap<K, V> extends ImmutableMap<K, V> {
    abstract UnmodifiableIterator<Entry<K, V>> entryIterator();


            

Reported by PMD.

Possible God Class (WMC=51, ATFD=8, TCC=0.000%)
Design

Line: 51

               * @see ImmutableSortedMap
 * @author Hayward Chan
 */
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
  static final ImmutableMap<Object, Object> EMPTY = new RegularImmutableMap<Object, Object>();

  abstract static class IteratorBasedImmutableMap<K, V> extends ImmutableMap<K, V> {
    abstract UnmodifiableIterator<Entry<K, V>> entryIterator();


            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 54

              public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
  static final ImmutableMap<Object, Object> EMPTY = new RegularImmutableMap<Object, Object>();

  abstract static class IteratorBasedImmutableMap<K, V> extends ImmutableMap<K, V> {
    abstract UnmodifiableIterator<Entry<K, V>> entryIterator();

    @Override
    ImmutableSet<Entry<K, V>> createEntrySet() {
      return new ImmutableMapEntrySet<K, V>() {

            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 114

                      entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4));
  }

  public static <K, V> ImmutableMap<K, V> of(
      K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
    return new RegularImmutableMap<K, V>(
        entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
  }


            

Reported by PMD.

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

Line: 136

                }

  public static class Builder<K, V> {
    final List<Entry<K, V>> entries;
    Comparator<? super V> valueComparator;

    public Builder() {
      this.entries = Lists.newArrayList();
    }

            

Reported by PMD.

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

Line: 137

              
  public static class Builder<K, V> {
    final List<Entry<K, V>> entries;
    Comparator<? super V> valueComparator;

    public Builder() {
      this.entries = Lists.newArrayList();
    }


            

Reported by PMD.

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

Line: 156

                    if (entry instanceof ImmutableEntry) {
        checkNotNull(entry.getKey());
        checkNotNull(entry.getValue());
        @SuppressWarnings("unchecked") // all supported methods are covariant
        Entry<K, V> immutableEntry = (Entry<K, V>) entry;
        entries.add(immutableEntry);
      } else {
        entries.add(entryOf((K) entry.getKey(), (V) entry.getValue()));
      }

            

Reported by PMD.

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

Line: 191

                  public ImmutableMap<K, V> build() {
      if (valueComparator != null) {
        Collections.sort(
            entries, Ordering.from(valueComparator).onResultOf(Maps.<V>valueFunction()));
      }
      return fromEntryList(entries);
    }

    ImmutableMap<K, V> buildJdkBacked() {

            

Reported by PMD.

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

Line: 209

                      return of();
      case 1:
        Entry<? extends K, ? extends V> entry = getOnlyElement(entries);
        return of((K) entry.getKey(), (V) entry.getValue());
      default:
        @SuppressWarnings("unchecked")
        Entry<K, V>[] entryArray = entries.toArray(new Entry[entries.size()]);
        return new RegularImmutableMap<K, V>(entryArray);
    }

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;

            

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.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 72

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

  /**
   * Creates a new {@code Multimap} backed by {@code map}, whose internal value collections are
   * generated by {@code factory}.

            

Reported by PMD.

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

Line: 72

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

  /**
   * Creates a new {@code Multimap} backed by {@code map}, whose internal value collections are
   * generated by {@code factory}.

            

Reported by PMD.

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

Line: 72

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

  /**
   * Creates a new {@code Multimap} backed by {@code map}, whose internal value collections are
   * generated by {@code factory}.

            

Reported by PMD.

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

Line: 183

                  }

    @GwtIncompatible // java.io.ObjectInputStream
    @SuppressWarnings("unchecked") // reading data stored by writeObject
    private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
      stream.defaultReadObject();
      factory = (Supplier<? extends Collection<V>>) stream.readObject();
      Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
      setMap(map);

            

Reported by PMD.

Field valueComparator has the same name as a method
Error

Line: 418

                        K extends @Nullable Object, V extends @Nullable Object>
      extends AbstractSortedSetMultimap<K, V> {
    transient Supplier<? extends SortedSet<V>> factory;
    @CheckForNull transient Comparator<? super V> valueComparator;

    CustomSortedSetMultimap(Map<K, Collection<V>> map, Supplier<? extends SortedSet<V>> factory) {
      super(map);
      this.factory = checkNotNull(factory);
      valueComparator = factory.get().comparator();

            

Reported by PMD.

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

Line: 460

                  private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
      stream.defaultReadObject();
      factory = (Supplier<? extends SortedSet<V>>) stream.readObject();
      valueComparator = factory.get().comparator();
      Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
      setMap(map);
    }

    @GwtIncompatible // not needed in emulated source

            

Reported by PMD.

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

Line: 558

                }

  private static class UnmodifiableMultimap<K extends @Nullable Object, V extends @Nullable Object>
      extends ForwardingMultimap<K, V> implements Serializable {
    final Multimap<K, V> delegate;
    @LazyInit @CheckForNull transient Collection<Entry<K, V>> entries;
    @LazyInit @CheckForNull transient Multiset<K> keys;
    @LazyInit @CheckForNull transient Set<K> keySet;
    @LazyInit @CheckForNull transient Collection<V> values;

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 559

              
  private static class UnmodifiableMultimap<K extends @Nullable Object, V extends @Nullable Object>
      extends ForwardingMultimap<K, V> implements Serializable {
    final Multimap<K, V> delegate;
    @LazyInit @CheckForNull transient Collection<Entry<K, V>> entries;
    @LazyInit @CheckForNull transient Multiset<K> keys;
    @LazyInit @CheckForNull transient Set<K> keySet;
    @LazyInit @CheckForNull transient Collection<V> values;
    @LazyInit @CheckForNull transient Map<K, Collection<V>> map;

            

Reported by PMD.

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

Line: 38

              
/** Tests the package level *impl methods directly using various types of lists. */
@GwtCompatible(emulated = true)
public class ListsImplTest extends TestCase {

  /** Describes how a list is modifiable */
  public enum Modifiability {
    NONE, // immutable lists
    BY_ELEMENT, // elements can change (set), but not structure

            

Reported by PMD.

Field modifiability has the same name as a method
Error

Line: 52

                public abstract static class ListExample {

    private final String name;
    private final Modifiability modifiability;

    protected ListExample(String name, Modifiability modifiability) {
      this.name = name;
      this.modifiability = modifiability;
    }

            

Reported by PMD.

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

Line: 52

                public abstract static class ListExample {

    private final String name;
    private final Modifiability modifiability;

    protected ListExample(String name, Modifiability modifiability) {
      this.name = name;
      this.modifiability = modifiability;
    }

            

Reported by PMD.

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

Line: 73

                  }
  }

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(createExampleSuite(new ArrayListExample("ArrayList")));
    suite.addTest(createExampleSuite(new LinkedListExample("LinkedList")));
    suite.addTest(createExampleSuite(new ArraysAsListExample("Arrays.asList")));

            

Reported by PMD.

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

Line: 88

                @GwtIncompatible // suite sub call
  private static TestSuite createExampleSuite(ListExample example) {
    TestSuite resultSuite = new TestSuite(ListsImplTest.class);
    for (Enumeration<Test> testEnum = resultSuite.tests(); testEnum.hasMoreElements(); ) {
      ListsImplTest test = (ListsImplTest) testEnum.nextElement();
      test.example = example;
    }
    return resultSuite;
  }

            

Reported by PMD.

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

Line: 89

                private static TestSuite createExampleSuite(ListExample example) {
    TestSuite resultSuite = new TestSuite(ListsImplTest.class);
    for (Enumeration<Test> testEnum = resultSuite.tests(); testEnum.hasMoreElements(); ) {
      ListsImplTest test = (ListsImplTest) testEnum.nextElement();
      test.example = example;
    }
    return resultSuite;
  }


            

Reported by PMD.

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

Line: 95

                  return resultSuite;
  }

  private ListExample example;

  private ListExample getExample() {
    // because sometimes one version with a null example is created.
    return example == null ? new ImmutableListExample("test") : example;
  }

            

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

                  return super.getName() + ":" + example.getName();
  }

  public void testHashCodeImpl() {
    List<Integer> base = createList(Integer.class, 1, 2, 2);
    List<Integer> copy = createList(Integer.class, 1, 2, 2);
    List<Integer> outOfOrder = createList(Integer.class, 2, 2, 1);
    List<Integer> diffValue = createList(Integer.class, 1, 2, 4);
    List<Integer> diffLength = createList(Integer.class, 1, 2);

            

Reported by PMD.

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

Line: 111

                  return super.getName() + ":" + example.getName();
  }

  public void testHashCodeImpl() {
    List<Integer> base = createList(Integer.class, 1, 2, 2);
    List<Integer> copy = createList(Integer.class, 1, 2, 2);
    List<Integer> outOfOrder = createList(Integer.class, 2, 2, 1);
    List<Integer> diffValue = createList(Integer.class, 1, 2, 4);
    List<Integer> diffLength = createList(Integer.class, 1, 2);

            

Reported by PMD.

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

Line: 119

                  List<Integer> diffLength = createList(Integer.class, 1, 2);
    List<Integer> empty = createList(Integer.class);

    assertThat(Lists.hashCodeImpl(base)).isEqualTo(Lists.hashCodeImpl(copy));

    assertThat(Lists.hashCodeImpl(base)).isNotEqualTo(Lists.hashCodeImpl(outOfOrder));
    assertThat(Lists.hashCodeImpl(base)).isNotEqualTo(Lists.hashCodeImpl(diffValue));
    assertThat(Lists.hashCodeImpl(base)).isNotEqualTo(Lists.hashCodeImpl(diffLength));
    assertThat(Lists.hashCodeImpl(base)).isNotEqualTo(Lists.hashCodeImpl(empty));

            

Reported by PMD.

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

Line: 45

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }

            

Reported by PMD.

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

Line: 46

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }


            

Reported by PMD.

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

Line: 46

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }


            

Reported by PMD.

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

Line: 47

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 49

                public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());

            

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

                  assertEquals(0, result.size());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());
    assertFalse(result.isEmpty());
    assertContentsAnyOrder(result, v0());
  }

            

Reported by PMD.

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

Line: 53

                }

  @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());
    assertFalse(result.isEmpty());
    assertContentsAnyOrder(result, v0());
  }


            

Reported by PMD.

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

Line: 54

              
  @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());
    assertFalse(result.isEmpty());
    assertContentsAnyOrder(result, v0());
  }

  @CollectionSize.Require(SEVERAL)

            

Reported by PMD.

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

Line: 55

                @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());
    assertFalse(result.isEmpty());
    assertContentsAnyOrder(result, v0());
  }

  @CollectionSize.Require(SEVERAL)
  public void testGetMultiple() {

            

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

                  assertContentsAnyOrder(result, v0());
  }

  @CollectionSize.Require(SEVERAL)
  public void testGetMultiple() {
    resetContainer(
        Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k0(), v2()));
    assertGet(k0(), v0(), v1(), v2());
  }

            

Reported by PMD.

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

Line: 45

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }

            

Reported by PMD.

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

Line: 46

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }


            

Reported by PMD.

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

Line: 46

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }


            

Reported by PMD.

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

Line: 47

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 49

                public void testGetEmpty() {
    Collection<V> result = multimap().get(k3());
    assertEmpty(result);
    assertEquals(0, result.size());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());

            

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

                  assertEquals(0, result.size());
  }

  @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());
    assertFalse(result.isEmpty());
    assertContentsAnyOrder(result, v0());
  }

            

Reported by PMD.

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

Line: 53

                }

  @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());
    assertFalse(result.isEmpty());
    assertContentsAnyOrder(result, v0());
  }


            

Reported by PMD.

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

Line: 54

              
  @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());
    assertFalse(result.isEmpty());
    assertContentsAnyOrder(result, v0());
  }

  @CollectionSize.Require(SEVERAL)

            

Reported by PMD.

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

Line: 55

                @CollectionSize.Require(absent = ZERO)
  public void testGetNonEmpty() {
    Collection<V> result = multimap().get(k0());
    assertFalse(result.isEmpty());
    assertContentsAnyOrder(result, v0());
  }

  @CollectionSize.Require(SEVERAL)
  public void testGetMultiple() {

            

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

                  assertContentsAnyOrder(result, v0());
  }

  @CollectionSize.Require(SEVERAL)
  public void testGetMultiple() {
    resetContainer(
        Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k0(), v2()));
    assertGet(k0(), v0(), v1(), v2());
  }

            

Reported by PMD.