The following issues were found

guava-testlib/src/com/google/common/testing/CollectorTester.java
15 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 69

                  return new CollectorTester<>(collector, equivalence);
  }

  private final Collector<T, A, R> collector;
  private final BiPredicate<? super R, ? super R> equivalence;

  private CollectorTester(
      Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) {
    this.collector = checkNotNull(collector);

            

Reported by PMD.

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

Line: 70

                }

  private final Collector<T, A, R> collector;
  private final BiPredicate<? super R, ? super R> equivalence;

  private CollectorTester(
      Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) {
    this.collector = checkNotNull(collector);
    this.equivalence = checkNotNull(equivalence);

            

Reported by PMD.

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

Line: 87

                  SEQUENTIAL {
      @Override
      final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
        A accum = collector.supplier().get();
        for (T input : inputs) {
          collector.accumulator().accept(accum, input);
        }
        return accum;
      }

            

Reported by PMD.

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

Line: 89

                    final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
        A accum = collector.supplier().get();
        for (T input : inputs) {
          collector.accumulator().accept(accum, input);
        }
        return accum;
      }
    },
    /** Get one accumulator for each element and merge the accumulators left-to-right. */

            

Reported by PMD.

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

Line: 98

                  MERGE_LEFT_ASSOCIATIVE {
      @Override
      final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
        A accum = collector.supplier().get();
        for (T input : inputs) {
          A newAccum = collector.supplier().get();
          collector.accumulator().accept(newAccum, input);
          accum = collector.combiner().apply(accum, newAccum);
        }

            

Reported by PMD.

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

Line: 100

                    final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
        A accum = collector.supplier().get();
        for (T input : inputs) {
          A newAccum = collector.supplier().get();
          collector.accumulator().accept(newAccum, input);
          accum = collector.combiner().apply(accum, newAccum);
        }
        return accum;
      }

            

Reported by PMD.

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

Line: 101

                      A accum = collector.supplier().get();
        for (T input : inputs) {
          A newAccum = collector.supplier().get();
          collector.accumulator().accept(newAccum, input);
          accum = collector.combiner().apply(accum, newAccum);
        }
        return accum;
      }
    },

            

Reported by PMD.

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

Line: 102

                      for (T input : inputs) {
          A newAccum = collector.supplier().get();
          collector.accumulator().accept(newAccum, input);
          accum = collector.combiner().apply(accum, newAccum);
        }
        return accum;
      }
    },
    /** Get one accumulator for each element and merge the accumulators right-to-left. */

            

Reported by PMD.

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

Line: 113

                    final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
        List<A> stack = new ArrayList<>();
        for (T input : inputs) {
          A newAccum = collector.supplier().get();
          collector.accumulator().accept(newAccum, input);
          push(stack, newAccum);
        }
        push(stack, collector.supplier().get());
        while (stack.size() > 1) {

            

Reported by PMD.

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

Line: 114

                      List<A> stack = new ArrayList<>();
        for (T input : inputs) {
          A newAccum = collector.supplier().get();
          collector.accumulator().accept(newAccum, input);
          push(stack, newAccum);
        }
        push(stack, collector.supplier().get());
        while (stack.size() > 1) {
          A right = pop(stack);

            

Reported by PMD.

guava-tests/benchmark/com/google/common/hash/MessageDigestAlgorithmBenchmark.java
15 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 42

               */
public class MessageDigestAlgorithmBenchmark {
  @Param({"10", "1000", "100000", "1000000"})
  int size;

  @Param Algorithm algorithm;
  @Param HashMethod hashMethod;

  private enum HashMethod {

            

Reported by PMD.

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

Line: 44

                @Param({"10", "1000", "100000", "1000000"})
  int size;

  @Param Algorithm algorithm;
  @Param HashMethod hashMethod;

  private enum HashMethod {
    MESSAGE_DIGEST_API() {
      @Override

            

Reported by PMD.

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

Line: 45

                int size;

  @Param Algorithm algorithm;
  @Param HashMethod hashMethod;

  private enum HashMethod {
    MESSAGE_DIGEST_API() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {

            

Reported by PMD.

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

Line: 52

                    @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {
        MessageDigest md = algorithm.getMessageDigest();
        md.update(input);
        return md.digest();
      }
    },
    HASH_FUNCTION_DIRECT() {
      @Override

            

Reported by PMD.

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

Line: 53

                    public byte[] hash(Algorithm algorithm, byte[] input) {
        MessageDigest md = algorithm.getMessageDigest();
        md.update(input);
        return md.digest();
      }
    },
    HASH_FUNCTION_DIRECT() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {

            

Reported by PMD.

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

Line: 59

                  HASH_FUNCTION_DIRECT() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {
        return algorithm.getHashFunction().hashBytes(input).asBytes();
      }
    },
    HASH_FUNCTION_VIA_HASHER() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {

            

Reported by PMD.

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

Line: 59

                  HASH_FUNCTION_DIRECT() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {
        return algorithm.getHashFunction().hashBytes(input).asBytes();
      }
    },
    HASH_FUNCTION_VIA_HASHER() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {

            

Reported by PMD.

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

Line: 65

                  HASH_FUNCTION_VIA_HASHER() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {
        return algorithm.getHashFunction().newHasher().putBytes(input).hash().asBytes();
      }
    };
    ;

    public abstract byte[] hash(Algorithm algorithm, byte[] input);

            

Reported by PMD.

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

Line: 65

                  HASH_FUNCTION_VIA_HASHER() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {
        return algorithm.getHashFunction().newHasher().putBytes(input).hash().asBytes();
      }
    };
    ;

    public abstract byte[] hash(Algorithm algorithm, byte[] input);

            

Reported by PMD.

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

Line: 65

                  HASH_FUNCTION_VIA_HASHER() {
      @Override
      public byte[] hash(Algorithm algorithm, byte[] input) {
        return algorithm.getHashFunction().newHasher().putBytes(input).hash().asBytes();
      }
    };
    ;

    public abstract byte[] hash(Algorithm algorithm, byte[] input);

            

Reported by PMD.

guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java
15 issues
JUnit 4 indicates test suites via annotations, not the suite method.
Design

Line: 45

              @SuppressWarnings("serial") // No serialization is used in this test
@GwtCompatible(emulated = true)
public class SimpleAbstractMultisetTest extends TestCase {
  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(SimpleAbstractMultisetTest.class);
    suite.addTest(
        MultisetTestSuiteBuilder.using(

            

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

                  return suite;
  }

  public void testFastAddAllMultiset() {
    final AtomicInteger addCalls = new AtomicInteger();
    Multiset<String> multiset =
        new NoRemoveMultiset<String>() {
          @Override
          public int add(String element, int occurrences) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 81

                  ImmutableMultiset<String> adds =
        new ImmutableMultiset.Builder<String>().addCopies("x", 10).build();
    multiset.addAll(adds);
    assertEquals(1, addCalls.get());
  }

  public void testRemoveUnsupported() {
    Multiset<String> multiset = new NoRemoveMultiset<>();
    multiset.add("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: 84

                  assertEquals(1, addCalls.get());
  }

  public void testRemoveUnsupported() {
    Multiset<String> multiset = new NoRemoveMultiset<>();
    multiset.add("a");
    try {
      multiset.remove("a");
      fail();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 89

                  multiset.add("a");
    try {
      multiset.remove("a");
      fail();
    } catch (UnsupportedOperationException expected) {
    }
    assertTrue(multiset.contains("a"));
  }


            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 89

                  multiset.add("a");
    try {
      multiset.remove("a");
      fail();
    } catch (UnsupportedOperationException expected) {
    }
    assertTrue(multiset.contains("a"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 92

                    fail();
    } catch (UnsupportedOperationException expected) {
    }
    assertTrue(multiset.contains("a"));
  }

  private static class NoRemoveMultiset<E> extends AbstractMultiset<E> implements Serializable {
    final Map<E, Integer> backingMap = Maps.newHashMap();


            

Reported by PMD.

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

Line: 140

              
    @Override
    Iterator<Entry<E>> entryIterator() {
      final Iterator<Map.Entry<E, Integer>> backingEntries = backingMap.entrySet().iterator();
      return new UnmodifiableIterator<Multiset.Entry<E>>() {
        @Override
        public boolean hasNext() {
          return backingEntries.hasNext();
        }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'multiset' (lines '70'-'82').
Error

Line: 70

              
  public void testFastAddAllMultiset() {
    final AtomicInteger addCalls = new AtomicInteger();
    Multiset<String> multiset =
        new NoRemoveMultiset<String>() {
          @Override
          public int add(String element, int occurrences) {
            addCalls.incrementAndGet();
            return super.add(element, occurrences);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'multiset' (lines '70'-'82').
Error

Line: 70

              
  public void testFastAddAllMultiset() {
    final AtomicInteger addCalls = new AtomicInteger();
    Multiset<String> multiset =
        new NoRemoveMultiset<String>() {
          @Override
          public int add(String element, int occurrences) {
            addCalls.incrementAndGet();
            return super.add(element, occurrences);

            

Reported by PMD.

guava-tests/benchmark/com/google/common/collect/SortedCopyBenchmark.java
15 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 38

               */
public class SortedCopyBenchmark {
  @Param({"1", "10", "1000", "1000000"})
  int size; // logarithmic triangular

  @Param boolean mutable;

  @Param InputOrder inputOrder;


            

Reported by PMD.

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

Line: 40

                @Param({"1", "10", "1000", "1000000"})
  int size; // logarithmic triangular

  @Param boolean mutable;

  @Param InputOrder inputOrder;

  enum InputOrder {
    SORTED {

            

Reported by PMD.

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

Line: 42

              
  @Param boolean mutable;

  @Param InputOrder inputOrder;

  enum InputOrder {
    SORTED {
      @Override
      void arrange(List<Integer> list) {

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 55

                    @Override
      void arrange(List<Integer> list) {
        Collections.sort(list);
        if (list.size() > 1) {
          int i = (list.size() - 1) / 2;
          Collections.swap(list, i, i + 1);
        }
      }
    },

            

Reported by PMD.

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

Line: 69

                  abstract void arrange(List<Integer> list);
  }

  private ImmutableList<Integer> input;

  @BeforeExperiment
  void setUp() {
    checkArgument(size > 0, "empty collection not supported");
    Set<Integer> set = new LinkedHashSet<>(size);

            

Reported by PMD.

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

Line: 71

              
  private ImmutableList<Integer> input;

  @BeforeExperiment
  void setUp() {
    checkArgument(size > 0, "empty collection not supported");
    Set<Integer> set = new LinkedHashSet<>(size);

    Random random = new Random();

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 91

                  // Yes, this could be done more elegantly
    if (mutable) {
      for (int i = 0; i < reps; i++) {
        List<Integer> copy = new ArrayList<>(input);
        Collections.sort(copy);
        dummy += copy.get(0);
      }
    } else {
      for (int i = 0; i < reps; i++) {

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 97

                    }
    } else {
      for (int i = 0; i < reps; i++) {
        List<Integer> copy = new ArrayList<>(input);
        Collections.sort(copy);
        dummy += ImmutableList.copyOf(copy).get(0);
      }
    }
    return dummy;

            

Reported by PMD.

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

Line: 99

                    for (int i = 0; i < reps; i++) {
        List<Integer> copy = new ArrayList<>(input);
        Collections.sort(copy);
        dummy += ImmutableList.copyOf(copy).get(0);
      }
    }
    return dummy;
  }


            

Reported by PMD.

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

Line: 110

                  int dummy = 0;
    if (mutable) {
      for (int i = 0; i < reps; i++) {
        dummy += ORDERING.sortedCopy(input).get(0);
      }
    } else {
      for (int i = 0; i < reps; i++) {
        dummy += ORDERING.immutableSortedCopy(input).get(0);
      }

            

Reported by PMD.

guava-tests/benchmark/com/google/common/math/StatsBenchmark.java
15 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 73

                }

  static class MeanAndVariance {
    private final double mean;
    private final double variance;

    MeanAndVariance(double mean, double variance) {
      this.mean = mean;
      this.variance = variance;

            

Reported by PMD.

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

Line: 74

              
  static class MeanAndVariance {
    private final double mean;
    private final double variance;

    MeanAndVariance(double mean, double variance) {
      this.mean = mean;
      this.variance = variance;
    }

            

Reported by PMD.

Ensure you override both equals() and hashCode()
Error

Line: 82

                  }

    @Override
    public int hashCode() {
      return Doubles.hashCode(mean) * 31 + Doubles.hashCode(variance);
    }
  }

  enum VarianceAlgorithm {

            

Reported by PMD.

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

Line: 144

                }

  @Param({"100", "10000"})
  int n;

  @Param MeanAlgorithm meanAlgorithm;
  @Param VarianceAlgorithm varianceAlgorithm;

  private double[][] values = new double[0x100][];

            

Reported by PMD.

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

Line: 146

                @Param({"100", "10000"})
  int n;

  @Param MeanAlgorithm meanAlgorithm;
  @Param VarianceAlgorithm varianceAlgorithm;

  private double[][] values = new double[0x100][];

  @BeforeExperiment

            

Reported by PMD.

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

Line: 147

                int n;

  @Param MeanAlgorithm meanAlgorithm;
  @Param VarianceAlgorithm varianceAlgorithm;

  private double[][] values = new double[0x100][];

  @BeforeExperiment
  void setUp() {

            

Reported by PMD.

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

Line: 149

                @Param MeanAlgorithm meanAlgorithm;
  @Param VarianceAlgorithm varianceAlgorithm;

  private double[][] values = new double[0x100][];

  @BeforeExperiment
  void setUp() {
    Random rng = new Random();
    for (int i = 0; i < 0x100; i++) {

            

Reported by PMD.

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

Line: 151

              
  private double[][] values = new double[0x100][];

  @BeforeExperiment
  void setUp() {
    Random rng = new Random();
    for (int i = 0; i < 0x100; i++) {
      values[i] = new double[n];
      for (int j = 0; j < n; j++) {

            

Reported by PMD.

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

Line: 166

                int meanAndVariance(int reps) {
    int tmp = 0;
    for (int i = 0; i < reps; i++) {
      tmp += varianceAlgorithm.variance(values[i & 0xFF], meanAlgorithm).hashCode();
    }
    return tmp;
  }
}

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 69

                    }
    };

    abstract double mean(double[] values);
  }

  static class MeanAndVariance {
    private final double mean;
    private final double variance;

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultisetIteratorTester.java
15 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)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetIteratorTester<E> extends AbstractMultisetTester<E> {
  @SuppressWarnings("unchecked")
  @CollectionFeature.Require({SUPPORTS_ITERATOR_REMOVE, KNOWN_ORDER})
  public void testRemovingIteratorKnownOrder() {
    new IteratorTester<E>(
        4,
        MODIFIABLE,

            

Reported by PMD.

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

Line: 42

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetIteratorTester<E> extends AbstractMultisetTester<E> {
  @SuppressWarnings("unchecked")
  @CollectionFeature.Require({SUPPORTS_ITERATOR_REMOVE, KNOWN_ORDER})
  public void testRemovingIteratorKnownOrder() {
    new IteratorTester<E>(
        4,
        MODIFIABLE,

            

Reported by PMD.

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

Line: 48

                  new IteratorTester<E>(
        4,
        MODIFIABLE,
        getSubjectGenerator().order(Arrays.asList(e0(), e1(), e1(), e2())),
        IteratorTester.KnownOrder.KNOWN_ORDER) {
      @Override
      protected Iterator<E> newTargetIterator() {
        return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
      }

            

Reported by PMD.

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

Line: 52

                      IteratorTester.KnownOrder.KNOWN_ORDER) {
      @Override
      protected Iterator<E> newTargetIterator() {
        return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
      }
    }.test();
  }

  @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 52

                      IteratorTester.KnownOrder.KNOWN_ORDER) {
      @Override
      protected Iterator<E> newTargetIterator() {
        return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
      }
    }.test();
  }

  @SuppressWarnings("unchecked")

            

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

                  }.test();
  }

  @SuppressWarnings("unchecked")
  @CollectionFeature.Require(value = SUPPORTS_ITERATOR_REMOVE, absent = KNOWN_ORDER)
  public void testRemovingIteratorUnknownOrder() {
    new IteratorTester<E>(
        4,
        MODIFIABLE,

            

Reported by PMD.

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

Line: 67

                      IteratorTester.KnownOrder.UNKNOWN_ORDER) {
      @Override
      protected Iterator<E> newTargetIterator() {
        return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
      }
    }.test();
  }

  @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 67

                      IteratorTester.KnownOrder.UNKNOWN_ORDER) {
      @Override
      protected Iterator<E> newTargetIterator() {
        return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
      }
    }.test();
  }

  @SuppressWarnings("unchecked")

            

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

                  }.test();
  }

  @SuppressWarnings("unchecked")
  @CollectionFeature.Require(value = KNOWN_ORDER, absent = SUPPORTS_ITERATOR_REMOVE)
  public void testIteratorKnownOrder() {
    new IteratorTester<E>(
        4,
        UNMODIFIABLE,

            

Reported by PMD.

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

Line: 78

                  new IteratorTester<E>(
        4,
        UNMODIFIABLE,
        getSubjectGenerator().order(Arrays.asList(e0(), e1(), e1(), e2())),
        IteratorTester.KnownOrder.KNOWN_ORDER) {
      @Override
      protected Iterator<E> newTargetIterator() {
        return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
      }

            

Reported by PMD.

android/guava/src/com/google/common/collect/ImmutableListMultimap.java
15 issues
This class has too many methods, consider refactoring it.
Design

Line: 50

              @GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
    implements ListMultimap<K, V> {

  /**
   * Returns the empty multimap.
   *
   * <p><b>Performance note:</b> the instance returned is a singleton.

            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 99

                }

  /** Returns an immutable multimap containing the given entries, in order. */
  public static <K, V> ImmutableListMultimap<K, V> of(
      K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
    ImmutableListMultimap.Builder<K, V> builder = ImmutableListMultimap.builder();
    builder.put(k1, v1);
    builder.put(k2, v2);
    builder.put(k3, v3);

            

Reported by PMD.

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

Line: 258

                  if (multimap instanceof ImmutableListMultimap) {
      @SuppressWarnings("unchecked") // safe since multimap is not writable
      ImmutableListMultimap<K, V> kvMultimap = (ImmutableListMultimap<K, V>) multimap;
      if (!kvMultimap.isPartialView()) {
        return kvMultimap;
      }
    }

    return fromMapEntries(multimap.asMap().entrySet(), null);

            

Reported by PMD.

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

Line: 263

                    }
    }

    return fromMapEntries(multimap.asMap().entrySet(), null);
  }

  /**
   * Returns an immutable multimap containing the specified entries. The returned multimap iterates
   * over keys in the order they were first encountered in the input, and the values for each key

            

Reported by PMD.

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

Line: 298

                        (valueComparator == null)
              ? ImmutableList.copyOf(values)
              : ImmutableList.sortedCopyOf(valueComparator, values);
      if (!list.isEmpty()) {
        builder.put(key, list);
        size += list.size();
      }
    }


            

Reported by PMD.

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

Line: 300

                            : ImmutableList.sortedCopyOf(valueComparator, values);
      if (!list.isEmpty()) {
        builder.put(key, list);
        size += list.size();
      }
    }

    return new ImmutableListMultimap<>(builder.build(), size);
  }

            

Reported by PMD.

Field inverse has the same name as a method
Error

Line: 325

                  return (list == null) ? ImmutableList.<V>of() : list;
  }

  @LazyInit @RetainedWith @CheckForNull private transient ImmutableListMultimap<V, K> inverse;

  /**
   * {@inheritDoc}
   *
   * <p>Because an inverse of a list multimap can contain multiple pairs with the same key and

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 422

                    throw (InvalidObjectException) new InvalidObjectException(e.getMessage()).initCause(e);
    }

    FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
    FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
  }

  @GwtIncompatible // Not needed in emulated source
  private static final long serialVersionUID = 0;

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 423

                  }

    FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
    FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
  }

  @GwtIncompatible // Not needed in emulated source
  private static final long serialVersionUID = 0;
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'key' (lines '292'-'292').
Error

Line: 292

                  int size = 0;

    for (Entry<? extends K, ? extends Collection<? extends V>> entry : mapEntries) {
      K key = entry.getKey();
      Collection<? extends V> values = entry.getValue();
      ImmutableList<V> list =
          (valueComparator == null)
              ? ImmutableList.copyOf(values)
              : ImmutableList.sortedCopyOf(valueComparator, values);

            

Reported by PMD.

android/guava/src/com/google/common/eventbus/EventBus.java
15 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 153

              
  private static final Logger logger = Logger.getLogger(EventBus.class.getName());

  private final String identifier;
  private final Executor executor;
  private final SubscriberExceptionHandler exceptionHandler;

  private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
  private final Dispatcher dispatcher;

            

Reported by PMD.

Field identifier has the same name as a method
Error

Line: 153

              
  private static final Logger logger = Logger.getLogger(EventBus.class.getName());

  private final String identifier;
  private final Executor executor;
  private final SubscriberExceptionHandler exceptionHandler;

  private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
  private final Dispatcher dispatcher;

            

Reported by PMD.

Field executor has the same name as a method
Error

Line: 154

                private static final Logger logger = Logger.getLogger(EventBus.class.getName());

  private final String identifier;
  private final Executor executor;
  private final SubscriberExceptionHandler exceptionHandler;

  private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
  private final Dispatcher dispatcher;


            

Reported by PMD.

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

Line: 154

                private static final Logger logger = Logger.getLogger(EventBus.class.getName());

  private final String identifier;
  private final Executor executor;
  private final SubscriberExceptionHandler exceptionHandler;

  private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
  private final Dispatcher dispatcher;


            

Reported by PMD.

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

Line: 155

              
  private final String identifier;
  private final Executor executor;
  private final SubscriberExceptionHandler exceptionHandler;

  private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
  private final Dispatcher dispatcher;

  /** Creates a new EventBus named "default". */

            

Reported by PMD.

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

Line: 157

                private final Executor executor;
  private final SubscriberExceptionHandler exceptionHandler;

  private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
  private final Dispatcher dispatcher;

  /** Creates a new EventBus named "default". */
  public EventBus() {
    this("default");

            

Reported by PMD.

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

Line: 158

                private final SubscriberExceptionHandler exceptionHandler;

  private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
  private final Dispatcher dispatcher;

  /** Creates a new EventBus named "default". */
  public EventBus() {
    this("default");
  }

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 224

                  checkNotNull(context);
    try {
      exceptionHandler.handleException(e, context);
    } catch (Throwable e2) {
      // if the handler threw an exception... well, just log it
      logger.log(
          Level.SEVERE,
          String.format(Locale.ROOT, "Exception %s thrown while handling exception: %s", e2, e),
          e2);

            

Reported by PMD.

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

Line: 274

              
  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this).addValue(identifier).toString();
  }

  /** Simple logging handler for subscriber exceptions. */
  static final class LoggingHandler implements SubscriberExceptionHandler {
    static final LoggingHandler INSTANCE = new LoggingHandler();

            

Reported by PMD.

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

Line: 274

              
  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this).addValue(identifier).toString();
  }

  /** Simple logging handler for subscriber exceptions. */
  static final class LoggingHandler implements SubscriberExceptionHandler {
    static final LoggingHandler INSTANCE = new LoggingHandler();

            

Reported by PMD.

android/guava/src/com/google/common/cache/AbstractCache.java
15 issues
The String literal 'GoodTime' appears 4 times in this file; the first occurrence is on line 169
Error

Line: 169

                   * @param loadTime the number of nanoseconds the cache spent computing or retrieving the new
     *     value
     */
    @SuppressWarnings("GoodTime") // should accept a java.time.Duration
    void recordLoadSuccess(long loadTime);

    /**
     * Records the failed load of a new entry. This should be called when a cache request causes an
     * entry to be loaded, but an exception is thrown while loading the entry. In contrast to {@link

            

Reported by PMD.

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

Line: 203

                 * @since 10.0
   */
  public static final class SimpleStatsCounter implements StatsCounter {
    private final LongAddable hitCount = LongAddables.create();
    private final LongAddable missCount = LongAddables.create();
    private final LongAddable loadSuccessCount = LongAddables.create();
    private final LongAddable loadExceptionCount = LongAddables.create();
    private final LongAddable totalLoadTime = LongAddables.create();
    private final LongAddable evictionCount = LongAddables.create();

            

Reported by PMD.

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

Line: 204

                 */
  public static final class SimpleStatsCounter implements StatsCounter {
    private final LongAddable hitCount = LongAddables.create();
    private final LongAddable missCount = LongAddables.create();
    private final LongAddable loadSuccessCount = LongAddables.create();
    private final LongAddable loadExceptionCount = LongAddables.create();
    private final LongAddable totalLoadTime = LongAddables.create();
    private final LongAddable evictionCount = LongAddables.create();


            

Reported by PMD.

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

Line: 205

                public static final class SimpleStatsCounter implements StatsCounter {
    private final LongAddable hitCount = LongAddables.create();
    private final LongAddable missCount = LongAddables.create();
    private final LongAddable loadSuccessCount = LongAddables.create();
    private final LongAddable loadExceptionCount = LongAddables.create();
    private final LongAddable totalLoadTime = LongAddables.create();
    private final LongAddable evictionCount = LongAddables.create();

    /** Constructs an instance with all counts initialized to zero. */

            

Reported by PMD.

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

Line: 206

                  private final LongAddable hitCount = LongAddables.create();
    private final LongAddable missCount = LongAddables.create();
    private final LongAddable loadSuccessCount = LongAddables.create();
    private final LongAddable loadExceptionCount = LongAddables.create();
    private final LongAddable totalLoadTime = LongAddables.create();
    private final LongAddable evictionCount = LongAddables.create();

    /** Constructs an instance with all counts initialized to zero. */
    public SimpleStatsCounter() {}

            

Reported by PMD.

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

Line: 207

                  private final LongAddable missCount = LongAddables.create();
    private final LongAddable loadSuccessCount = LongAddables.create();
    private final LongAddable loadExceptionCount = LongAddables.create();
    private final LongAddable totalLoadTime = LongAddables.create();
    private final LongAddable evictionCount = LongAddables.create();

    /** Constructs an instance with all counts initialized to zero. */
    public SimpleStatsCounter() {}


            

Reported by PMD.

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

Line: 208

                  private final LongAddable loadSuccessCount = LongAddables.create();
    private final LongAddable loadExceptionCount = LongAddables.create();
    private final LongAddable totalLoadTime = LongAddables.create();
    private final LongAddable evictionCount = LongAddables.create();

    /** Constructs an instance with all counts initialized to zero. */
    public SimpleStatsCounter() {}

    /** @since 11.0 */

            

Reported by PMD.

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

Line: 263

                  /** Increments all counters by the values in {@code other}. */
    public void incrementBy(StatsCounter other) {
      CacheStats otherStats = other.snapshot();
      hitCount.add(otherStats.hitCount());
      missCount.add(otherStats.missCount());
      loadSuccessCount.add(otherStats.loadSuccessCount());
      loadExceptionCount.add(otherStats.loadExceptionCount());
      totalLoadTime.add(otherStats.totalLoadTime());
      evictionCount.add(otherStats.evictionCount());

            

Reported by PMD.

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

Line: 264

                  public void incrementBy(StatsCounter other) {
      CacheStats otherStats = other.snapshot();
      hitCount.add(otherStats.hitCount());
      missCount.add(otherStats.missCount());
      loadSuccessCount.add(otherStats.loadSuccessCount());
      loadExceptionCount.add(otherStats.loadExceptionCount());
      totalLoadTime.add(otherStats.totalLoadTime());
      evictionCount.add(otherStats.evictionCount());
    }

            

Reported by PMD.

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

Line: 265

                    CacheStats otherStats = other.snapshot();
      hitCount.add(otherStats.hitCount());
      missCount.add(otherStats.missCount());
      loadSuccessCount.add(otherStats.loadSuccessCount());
      loadExceptionCount.add(otherStats.loadExceptionCount());
      totalLoadTime.add(otherStats.totalLoadTime());
      evictionCount.add(otherStats.evictionCount());
    }
  }

            

Reported by PMD.

android/guava/src/com/google/common/collect/ForwardingMultiset.java
15 issues
This class has too many methods, consider refactoring it.
Design

Line: 54

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingMultiset<E extends @Nullable Object> extends ForwardingCollection<E>
    implements Multiset<E> {

  /** Constructor for use by subclasses. */
  protected ForwardingMultiset() {}

  @Override

            

Reported by PMD.

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

Line: 64

              
  @Override
  public int count(@CheckForNull Object element) {
    return delegate().count(element);
  }

  @CanIgnoreReturnValue
  @Override
  public int add(@ParametricNullness E element, int occurrences) {

            

Reported by PMD.

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

Line: 70

                @CanIgnoreReturnValue
  @Override
  public int add(@ParametricNullness E element, int occurrences) {
    return delegate().add(element, occurrences);
  }

  @CanIgnoreReturnValue
  @Override
  public int remove(@CheckForNull Object element, int occurrences) {

            

Reported by PMD.

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

Line: 76

                @CanIgnoreReturnValue
  @Override
  public int remove(@CheckForNull Object element, int occurrences) {
    return delegate().remove(element, occurrences);
  }

  @Override
  public Set<E> elementSet() {
    return delegate().elementSet();

            

Reported by PMD.

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

Line: 81

              
  @Override
  public Set<E> elementSet() {
    return delegate().elementSet();
  }

  @Override
  public Set<Entry<E>> entrySet() {
    return delegate().entrySet();

            

Reported by PMD.

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

Line: 86

              
  @Override
  public Set<Entry<E>> entrySet() {
    return delegate().entrySet();
  }

  @Override
  public boolean equals(@CheckForNull Object object) {
    return object == this || delegate().equals(object);

            

Reported by PMD.

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

Line: 91

              
  @Override
  public boolean equals(@CheckForNull Object object) {
    return object == this || delegate().equals(object);
  }

  @Override
  public int hashCode() {
    return delegate().hashCode();

            

Reported by PMD.

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

Line: 96

              
  @Override
  public int hashCode() {
    return delegate().hashCode();
  }

  @CanIgnoreReturnValue
  @Override
  public int setCount(@ParametricNullness E element, int count) {

            

Reported by PMD.

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

Line: 102

                @CanIgnoreReturnValue
  @Override
  public int setCount(@ParametricNullness E element, int count) {
    return delegate().setCount(element, count);
  }

  @CanIgnoreReturnValue
  @Override
  public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {

            

Reported by PMD.

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

Line: 108

                @CanIgnoreReturnValue
  @Override
  public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
    return delegate().setCount(element, oldCount, newCount);
  }

  /**
   * A sensible definition of {@link #contains} in terms of {@link #count}. If you override {@link
   * #count}, you may wish to override {@link #contains} to forward to this implementation.

            

Reported by PMD.