The following issues were found

android/guava/src/com/google/common/collect/StandardTable.java
122 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.alwaysTrue;
import static com.google.common.base.Predicates.equalTo;
import static com.google.common.base.Predicates.in;

            

Reported by PMD.

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

Line: 68

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
  @GwtTransient final Map<R, Map<C, V>> backingMap;
  @GwtTransient final Supplier<? extends Map<C, V>> factory;

  StandardTable(Map<R, Map<C, V>> backingMap, Supplier<? extends Map<C, V>> factory) {
    this.backingMap = backingMap;

            

Reported by PMD.

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

Line: 69

              @GwtCompatible
@ElementTypesAreNonnullByDefault
class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
  @GwtTransient final Map<R, Map<C, V>> backingMap;
  @GwtTransient final Supplier<? extends Map<C, V>> factory;

  StandardTable(Map<R, Map<C, V>> backingMap, Supplier<? extends Map<C, V>> factory) {
    this.backingMap = backingMap;
    this.factory = factory;

            

Reported by PMD.

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

Line: 70

              @ElementTypesAreNonnullByDefault
class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
  @GwtTransient final Map<R, Map<C, V>> backingMap;
  @GwtTransient final Supplier<? extends Map<C, V>> factory;

  StandardTable(Map<R, Map<C, V>> backingMap, Supplier<? extends Map<C, V>> factory) {
    this.backingMap = backingMap;
    this.factory = factory;
  }

            

Reported by PMD.

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

Line: 150

                  checkNotNull(rowKey);
    checkNotNull(columnKey);
    checkNotNull(value);
    return getOrCreate(rowKey).put(columnKey, value);
  }

  @CanIgnoreReturnValue
  @Override
  @CheckForNull

            

Reported by PMD.

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

Line: 164

                  if (map == null) {
      return null;
    }
    V value = map.remove(columnKey);
    if (map.isEmpty()) {
      backingMap.remove(rowKey);
    }
    return value;
  }

            

Reported by PMD.

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

Line: 165

                    return null;
    }
    V value = map.remove(columnKey);
    if (map.isEmpty()) {
      backingMap.remove(rowKey);
    }
    return value;
  }


            

Reported by PMD.

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

Line: 174

                @CanIgnoreReturnValue
  private Map<R, V> removeColumn(@CheckForNull Object column) {
    Map<R, V> output = new LinkedHashMap<>();
    Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
    while (iterator.hasNext()) {
      Entry<R, Map<C, V>> entry = iterator.next();
      V value = entry.getValue().remove(column);
      if (value != null) {
        output.put(entry.getKey(), value);

            

Reported by PMD.

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

Line: 177

                  Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
    while (iterator.hasNext()) {
      Entry<R, Map<C, V>> entry = iterator.next();
      V value = entry.getValue().remove(column);
      if (value != null) {
        output.put(entry.getKey(), value);
        if (entry.getValue().isEmpty()) {
          iterator.remove();
        }

            

Reported by PMD.

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

Line: 177

                  Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
    while (iterator.hasNext()) {
      Entry<R, Map<C, V>> entry = iterator.next();
      V value = entry.getValue().remove(column);
      if (value != null) {
        output.put(entry.getKey(), value);
        if (entry.getValue().isEmpty()) {
          iterator.remove();
        }

            

Reported by PMD.

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

Line: 37

               * @author Jared Levy
 */
@GwtCompatible
public class MapsTransformValuesUnmodifiableIteratorTest extends MapInterfaceTest<String, String> {
  // TODO(jlevy): Move shared code of this class and MapsTransformValuesTest
  // to a superclass.

  public MapsTransformValuesUnmodifiableIteratorTest() {
    super(true, true, false /*supportsPut*/, true, true, false);

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 46

                }

  private static class UnmodifiableIteratorMap<K, V> extends ForwardingMap<K, V> {
    final Map<K, V> delegate;

    UnmodifiableIteratorMap(Map<K, V> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

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

Line: 46

                }

  private static class UnmodifiableIteratorMap<K, V> extends ForwardingMap<K, V> {
    final Map<K, V> delegate;

    UnmodifiableIteratorMap(Map<K, V> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

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

Line: 67

              
        @Override
        public Iterator<K> iterator() {
          return Iterators.unmodifiableIterator(delegate.keySet().iterator());
        }

        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.keySet().removeAll(c);

            

Reported by PMD.

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

Line: 72

              
        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.keySet().removeAll(c);
        }

        @Override
        public boolean retainAll(Collection<?> c) {
          return delegate.keySet().retainAll(c);

            

Reported by PMD.

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

Line: 77

              
        @Override
        public boolean retainAll(Collection<?> c) {
          return delegate.keySet().retainAll(c);
        }
      };
    }

    @Override

            

Reported by PMD.

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

Line: 92

              
        @Override
        public Iterator<V> iterator() {
          return Iterators.unmodifiableIterator(delegate.values().iterator());
        }

        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.values().removeAll(c);

            

Reported by PMD.

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

Line: 97

              
        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.values().removeAll(c);
        }

        @Override
        public boolean retainAll(Collection<?> c) {
          return delegate.values().retainAll(c);

            

Reported by PMD.

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

Line: 102

              
        @Override
        public boolean retainAll(Collection<?> c) {
          return delegate.values().retainAll(c);
        }
      };
    }

    @Override

            

Reported by PMD.

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

Line: 117

              
        @Override
        public Iterator<Entry<K, V>> iterator() {
          return Iterators.unmodifiableIterator(delegate.entrySet().iterator());
        }

        @Override
        public boolean removeAll(Collection<?> c) {
          return delegate.entrySet().removeAll(c);

            

Reported by PMD.

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

Line: 51

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class Collections2Test extends TestCase {
  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite(Collections2Test.class.getSimpleName());
    suite.addTest(testsForFilter());
    suite.addTest(testsForFilterAll());

            

Reported by PMD.

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

Line: 52

               */
@GwtCompatible(emulated = true)
public class Collections2Test extends TestCase {
  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite(Collections2Test.class.getSimpleName());
    suite.addTest(testsForFilter());
    suite.addTest(testsForFilterAll());
    suite.addTest(testsForFilterLinkedList());

            

Reported by PMD.

The String literal 'yyy' appears 5 times in this file; the first occurrence is on line 69
Error

Line: 69

                    new Predicate<String>() {
        @Override
        public boolean apply(String input) {
          return !"yyy".equals(input) && !"zzz".equals(input);
        }
      };

  static final Predicate<String> LENGTH_1 =
      new Predicate<String>() {

            

Reported by PMD.

The String literal 'zzz' appears 5 times in this file; the first occurrence is on line 69
Error

Line: 69

                    new Predicate<String>() {
        @Override
        public boolean apply(String input) {
          return !"yyy".equals(input) && !"zzz".equals(input);
        }
      };

  static final Predicate<String> LENGTH_1 =
      new Predicate<String>() {

            

Reported by PMD.

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

Line: 85

                    new Predicate<String>() {
        @Override
        public boolean apply(String input) {
          return asList('a', 'e', 'i', 'o', 'u').contains(input.charAt(0));
        }
      };

  @GwtIncompatible // suite
  private static Test testsForFilter() {

            

Reported by PMD.

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

Line: 96

                            @Override
              public Collection<String> create(String[] elements) {
                List<String> unfiltered = newArrayList();
                unfiltered.add("yyy");
                Collections.addAll(unfiltered, elements);
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
              }
            })

            

Reported by PMD.

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

Line: 98

                              List<String> unfiltered = newArrayList();
                unfiltered.add("yyy");
                Collections.addAll(unfiltered, elements);
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
              }
            })
        .named("Collections2.filter")
        .withFeatures(

            

Reported by PMD.

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

Line: 140

                            @Override
              public Collection<String> create(String[] elements) {
                List<String> unfiltered = newLinkedList();
                unfiltered.add("yyy");
                Collections.addAll(unfiltered, elements);
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
              }
            })

            

Reported by PMD.

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

Line: 142

                              List<String> unfiltered = newLinkedList();
                unfiltered.add("yyy");
                Collections.addAll(unfiltered, elements);
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
              }
            })
        .named("Collections2.filter")
        .withFeatures(

            

Reported by PMD.

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

Line: 163

                            @Override
              public Collection<String> create(String[] elements) {
                List<String> unfiltered = newArrayList();
                unfiltered.add("yyy");
                unfiltered.addAll(ImmutableList.copyOf(elements));
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, LENGTH_1);
              }
            })

            

Reported by PMD.

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

Line: 35

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class ObjectArraysTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(ObjectArrays.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: 37

              @GwtCompatible(emulated = true)
public class ObjectArraysTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(ObjectArrays.class);
  }


            

Reported by PMD.

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

Line: 38

              public class ObjectArraysTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(ObjectArrays.class);
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)

            

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

                  tester.testAllPublicStaticMethods(ObjectArrays.class);
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }

            

Reported by PMD.

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

Line: 44

                }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {

            

Reported by PMD.

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

Line: 46

                @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {

            

Reported by PMD.

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

Line: 47

                public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {
    String[] array = ObjectArrays.newArray(String.class, 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: 50

                  assertThat(empty).isEmpty();
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {
    String[] array = ObjectArrays.newArray(String.class, 2);
    assertEquals(String[].class, array.getClass());
    assertThat(array).hasLength(2);
    assertNull(array[0]);

            

Reported by PMD.

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

Line: 51

                }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {
    String[] array = ObjectArrays.newArray(String.class, 2);
    assertEquals(String[].class, array.getClass());
    assertThat(array).hasLength(2);
    assertNull(array[0]);
  }

            

Reported by PMD.

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

Line: 35

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class ObjectArraysTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(ObjectArrays.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: 37

              @GwtCompatible(emulated = true)
public class ObjectArraysTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(ObjectArrays.class);
  }


            

Reported by PMD.

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

Line: 38

              public class ObjectArraysTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(ObjectArrays.class);
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)

            

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

                  tester.testAllPublicStaticMethods(ObjectArrays.class);
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }

            

Reported by PMD.

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

Line: 44

                }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }


            

Reported by PMD.

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

Line: 46

                @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {

            

Reported by PMD.

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

Line: 47

                public void testNewArray_fromClass_Empty() {
    String[] empty = ObjectArrays.newArray(String.class, 0);
    assertEquals(String[].class, empty.getClass());
    assertThat(empty).isEmpty();
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {
    String[] array = ObjectArrays.newArray(String.class, 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: 50

                  assertThat(empty).isEmpty();
  }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {
    String[] array = ObjectArrays.newArray(String.class, 2);
    assertEquals(String[].class, array.getClass());
    assertThat(array).hasLength(2);
    assertNull(array[0]);

            

Reported by PMD.

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

Line: 51

                }

  @GwtIncompatible // ObjectArrays.newArray(Class, int)
  public void testNewArray_fromClass_Nonempty() {
    String[] array = ObjectArrays.newArray(String.class, 2);
    assertEquals(String[].class, array.getClass());
    assertThat(array).hasLength(2);
    assertNull(array[0]);
  }

            

Reported by PMD.

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

Line: 51

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class Collections2Test extends TestCase {
  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite(Collections2Test.class.getSimpleName());
    suite.addTest(testsForFilter());
    suite.addTest(testsForFilterAll());

            

Reported by PMD.

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

Line: 52

               */
@GwtCompatible(emulated = true)
public class Collections2Test extends TestCase {
  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite(Collections2Test.class.getSimpleName());
    suite.addTest(testsForFilter());
    suite.addTest(testsForFilterAll());
    suite.addTest(testsForFilterLinkedList());

            

Reported by PMD.

The String literal 'zzz' appears 5 times in this file; the first occurrence is on line 69
Error

Line: 69

                    new Predicate<String>() {
        @Override
        public boolean apply(String input) {
          return !"yyy".equals(input) && !"zzz".equals(input);
        }
      };

  static final Predicate<String> LENGTH_1 =
      new Predicate<String>() {

            

Reported by PMD.

The String literal 'yyy' appears 5 times in this file; the first occurrence is on line 69
Error

Line: 69

                    new Predicate<String>() {
        @Override
        public boolean apply(String input) {
          return !"yyy".equals(input) && !"zzz".equals(input);
        }
      };

  static final Predicate<String> LENGTH_1 =
      new Predicate<String>() {

            

Reported by PMD.

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

Line: 85

                    new Predicate<String>() {
        @Override
        public boolean apply(String input) {
          return asList('a', 'e', 'i', 'o', 'u').contains(input.charAt(0));
        }
      };

  @GwtIncompatible // suite
  private static Test testsForFilter() {

            

Reported by PMD.

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

Line: 96

                            @Override
              public Collection<String> create(String[] elements) {
                List<String> unfiltered = newArrayList();
                unfiltered.add("yyy");
                Collections.addAll(unfiltered, elements);
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
              }
            })

            

Reported by PMD.

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

Line: 98

                              List<String> unfiltered = newArrayList();
                unfiltered.add("yyy");
                Collections.addAll(unfiltered, elements);
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
              }
            })
        .named("Collections2.filter")
        .withFeatures(

            

Reported by PMD.

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

Line: 140

                            @Override
              public Collection<String> create(String[] elements) {
                List<String> unfiltered = newLinkedList();
                unfiltered.add("yyy");
                Collections.addAll(unfiltered, elements);
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
              }
            })

            

Reported by PMD.

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

Line: 142

                              List<String> unfiltered = newLinkedList();
                unfiltered.add("yyy");
                Collections.addAll(unfiltered, elements);
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
              }
            })
        .named("Collections2.filter")
        .withFeatures(

            

Reported by PMD.

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

Line: 163

                            @Override
              public Collection<String> create(String[] elements) {
                List<String> unfiltered = newArrayList();
                unfiltered.add("yyy");
                unfiltered.addAll(ImmutableList.copyOf(elements));
                unfiltered.add("zzz");
                return Collections2.filter(unfiltered, LENGTH_1);
              }
            })

            

Reported by PMD.

guava-testlib/test/com/google/common/testing/FreshValueGeneratorTest.java
117 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.testing;

import com.google.common.base.CharMatcher;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Joiner;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import com.google.common.base.CharMatcher;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Joiner;

            

Reported by PMD.

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

Line: 17

               * limitations under the License.
 */

package com.google.common.testing;

import com.google.common.base.CharMatcher;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Joiner;

            

Reported by PMD.

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

Line: 119

               *
 * @author Ben Yu
 */
public class FreshValueGeneratorTest extends TestCase {

  @AndroidIncompatible // problem with equality of Type objects?
  public void testFreshInstance() {
    assertFreshInstances(
        String.class,

            

Reported by PMD.

Possible God Class (WMC=74, ATFD=100, TCC=0.000%)
Design

Line: 119

               *
 * @author Ben Yu
 */
public class FreshValueGeneratorTest extends TestCase {

  @AndroidIncompatible // problem with equality of Type objects?
  public void testFreshInstance() {
    assertFreshInstances(
        String.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: 121

               */
public class FreshValueGeneratorTest extends TestCase {

  @AndroidIncompatible // problem with equality of Type objects?
  public void testFreshInstance() {
    assertFreshInstances(
        String.class,
        CharSequence.class,
        Appendable.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: 197

                      int[].class);
  }

  public void testStringArray() {
    FreshValueGenerator generator = new FreshValueGenerator();
    String[] a1 = generator.generateFresh(String[].class);
    String[] a2 = generator.generateFresh(String[].class);
    assertFalse(a1[0].equals(a2[0]));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 201

                  FreshValueGenerator generator = new FreshValueGenerator();
    String[] a1 = generator.generateFresh(String[].class);
    String[] a2 = generator.generateFresh(String[].class);
    assertFalse(a1[0].equals(a2[0]));
  }

  public void testPrimitiveArray() {
    FreshValueGenerator generator = new FreshValueGenerator();
    int[] a1 = generator.generateFresh(int[].class);

            

Reported by PMD.

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

Line: 204

                  assertFalse(a1[0].equals(a2[0]));
  }

  public void testPrimitiveArray() {
    FreshValueGenerator generator = new FreshValueGenerator();
    int[] a1 = generator.generateFresh(int[].class);
    int[] a2 = generator.generateFresh(int[].class);
    assertTrue(a1[0] != a2[0]);
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 208

                  FreshValueGenerator generator = new FreshValueGenerator();
    int[] a1 = generator.generateFresh(int[].class);
    int[] a2 = generator.generateFresh(int[].class);
    assertTrue(a1[0] != a2[0]);
  }

  public void testRange() {
    assertFreshInstance(new TypeToken<Range<String>>() {});
  }

            

Reported by PMD.

android/guava/src/com/google/common/collect/TreeRangeMap.java
117 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.compose;
import static com.google.common.base.Predicates.in;

            

Reported by PMD.

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

Line: 55

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

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

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

            

Reported by PMD.

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

Line: 57

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

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

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


            

Reported by PMD.

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

Line: 69

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

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

            

Reported by PMD.

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

Line: 108

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

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

            

Reported by PMD.

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

Line: 116

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

            

Reported by PMD.

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

Line: 116

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

            

Reported by PMD.

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

Line: 162

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

            

Reported by PMD.

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

Line: 162

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

            

Reported by PMD.

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

Line: 163

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


            

Reported by PMD.

guava/src/com/google/common/util/concurrent/Monitor.java
116 issues
Avoid reassigning parameters such as 'nanos'
Design

Line: 1210

              
  /** Caller should check before calling that guard is not satisfied. */
  @GuardedBy("lock")
  private boolean awaitNanos(Guard guard, long nanos, boolean signalBeforeWaiting)
      throws InterruptedException {
    boolean firstTime = true;
    try {
      do {
        if (nanos <= 0L) {

            

Reported by PMD.

The class 'Monitor' has a total cyclomatic complexity of 148 (highest 14).
Design

Line: 207

              @GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
  // TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
  // TODO(user): "Port" jsr166 tests for ReentrantLock.
  //
  // TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
  //    by making the monitor implicit, and to eliminate other sources of IMSE.

            

Reported by PMD.

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

Line: 207

              @GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
  // TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
  // TODO(user): "Port" jsr166 tests for ReentrantLock.
  //
  // TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
  //    by making the monitor implicit, and to eliminate other sources of IMSE.

            

Reported by PMD.

Avoid really long classes.
Design

Line: 207

              @GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
  // TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
  // TODO(user): "Port" jsr166 tests for ReentrantLock.
  //
  // TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
  //    by making the monitor implicit, and to eliminate other sources of IMSE.

            

Reported by PMD.

Possible God Class (WMC=148, ATFD=73, TCC=28.401%)
Design

Line: 207

              @GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
  // TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
  // TODO(user): "Port" jsr166 tests for ReentrantLock.
  //
  // TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
  //    by making the monitor implicit, and to eliminate other sources of IMSE.

            

Reported by PMD.

The class 'Monitor' has a Modified Cyclomatic Complexity of 3 (Highest = 12).
Design

Line: 207

              @GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
  // TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
  // TODO(user): "Port" jsr166 tests for ReentrantLock.
  //
  // TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
  //    by making the monitor implicit, and to eliminate other sources of IMSE.

            

Reported by PMD.

The class 'Monitor' has a Standard Cyclomatic Complexity of 3 (Highest = 12).
Design

Line: 207

              @GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
  // TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
  // TODO(user): "Port" jsr166 tests for ReentrantLock.
  //
  // TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
  //    by making the monitor implicit, and to eliminate other sources of IMSE.

            

Reported by PMD.

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

Line: 310

                @Beta
  public abstract static class Guard {

    @Weak final Monitor monitor;
    final Condition condition;

    @GuardedBy("monitor.lock")
    int waiterCount = 0;


            

Reported by PMD.

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

Line: 311

                public abstract static class Guard {

    @Weak final Monitor monitor;
    final Condition condition;

    @GuardedBy("monitor.lock")
    int waiterCount = 0;

    /** The next active guard */

            

Reported by PMD.

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

Line: 314

                  final Condition condition;

    @GuardedBy("monitor.lock")
    int waiterCount = 0;

    /** The next active guard */
    @GuardedBy("monitor.lock")
    @CheckForNull
    Guard next;

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
115 issues
Avoid throwing raw exception types.
Design

Line: 157

                        @Override
          public void run() {
            numCalls.incrementAndGet();
            throw new RuntimeException("FAKE EXCEPTION!");
          }
        };

    e.execute(runMe);
    e.execute(runMe);

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 299

                            try {
                barrier.await();
              } catch (Exception e) {
                throw new RuntimeException(e);
              }
            }
          };
      executor.execute(errorTask);
      service.execute(barrierTask); // submit directly to the service

            

Reported by PMD.

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

Line: 46

               *
 * @author JJ Furman
 */
public class SequentialExecutorTest extends TestCase {

  private static class FakeExecutor implements Executor {
    Queue<Runnable> tasks = Queues.newArrayDeque();

    @Override

            

Reported by PMD.

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

Line: 49

              public class SequentialExecutorTest extends TestCase {

  private static class FakeExecutor implements Executor {
    Queue<Runnable> tasks = Queues.newArrayDeque();

    @Override
    public void execute(Runnable command) {
      tasks.add(command);
    }

            

Reported by PMD.

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

Line: 62

              
    void runNext() {
      assertTrue("expected at least one task to run", hasNext());
      tasks.remove().run();
    }

    void runAll() {
      while (hasNext()) {
        runNext();

            

Reported by PMD.

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

Line: 72

                  }
  }

  private FakeExecutor fakePool;
  private SequentialExecutor e;

  @Override
  public void setUp() {
    fakePool = new FakeExecutor();

            

Reported by PMD.

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

Line: 73

                }

  private FakeExecutor fakePool;
  private SequentialExecutor e;

  @Override
  public void setUp() {
    fakePool = new FakeExecutor();
    e = new SequentialExecutor(fakePool);

            

Reported by PMD.

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

Line: 75

                private FakeExecutor fakePool;
  private SequentialExecutor e;

  @Override
  public void setUp() {
    fakePool = new FakeExecutor();
    e = new SequentialExecutor(fakePool);
  }


            

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

                  e = new SequentialExecutor(fakePool);
  }

  public void testConstructingWithNullExecutor_fails() {
    try {
      new SequentialExecutor(null);
      fail("Should have failed with NullPointerException.");
    } catch (NullPointerException expected) {
    }

            

Reported by PMD.

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

Line: 84

                public void testConstructingWithNullExecutor_fails() {
    try {
      new SequentialExecutor(null);
      fail("Should have failed with NullPointerException.");
    } catch (NullPointerException expected) {
    }
  }

  public void testBasics() {

            

Reported by PMD.