The following issues were found

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

Line: 32

               */
public class IteratorBenchmark {
  @Param({"0", "1", "16", "256", "4096", "65536"})
  int size;

  // use concrete classes to remove any possible polymorphic overhead?
  Object[] array;
  ArrayList<Object> arrayList;
  LinkedList<Object> linkedList;

            

Reported by PMD.

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

Line: 35

                int size;

  // use concrete classes to remove any possible polymorphic overhead?
  Object[] array;
  ArrayList<Object> arrayList;
  LinkedList<Object> linkedList;

  @BeforeExperiment
  void setUp() {

            

Reported by PMD.

Avoid using implementation types like 'ArrayList'; use the interface instead
Design

Line: 36

              
  // use concrete classes to remove any possible polymorphic overhead?
  Object[] array;
  ArrayList<Object> arrayList;
  LinkedList<Object> linkedList;

  @BeforeExperiment
  void setUp() {
    array = new Object[size];

            

Reported by PMD.

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

Line: 36

              
  // use concrete classes to remove any possible polymorphic overhead?
  Object[] array;
  ArrayList<Object> arrayList;
  LinkedList<Object> linkedList;

  @BeforeExperiment
  void setUp() {
    array = new Object[size];

            

Reported by PMD.

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

Line: 37

                // use concrete classes to remove any possible polymorphic overhead?
  Object[] array;
  ArrayList<Object> arrayList;
  LinkedList<Object> linkedList;

  @BeforeExperiment
  void setUp() {
    array = new Object[size];
    arrayList = Lists.newArrayListWithCapacity(size);

            

Reported by PMD.

Avoid using implementation types like 'LinkedList'; use the interface instead
Design

Line: 37

                // use concrete classes to remove any possible polymorphic overhead?
  Object[] array;
  ArrayList<Object> arrayList;
  LinkedList<Object> linkedList;

  @BeforeExperiment
  void setUp() {
    array = new Object[size];
    arrayList = Lists.newArrayListWithCapacity(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: 39

                ArrayList<Object> arrayList;
  LinkedList<Object> linkedList;

  @BeforeExperiment
  void setUp() {
    array = new Object[size];
    arrayList = Lists.newArrayListWithCapacity(size);
    linkedList = Lists.newLinkedList();


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 46

                  linkedList = Lists.newLinkedList();

    for (int i = 0; i < size; i++) {
      Object value = new Object();
      array[i] = value;
      arrayList.add(value);
      linkedList.add(value);
    }
  }

            

Reported by PMD.

This for loop can be replaced by a foreach loop
Design

Line: 68

                int arrayIndexedLength(int reps) {
    int sum = 0;
    for (int i = 0; i < reps; i++) {
      for (int index = 0; index < array.length; index++) {
        sum += array[index].hashCode();
      }
    }
    return sum;
  }

            

Reported by PMD.

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

Line: 91

                  int sum = 0;
    for (int i = 0; i < reps; i++) {
      for (int index = 0; index < size; index++) {
        sum += arrayList.get(index).hashCode();
      }
    }
    return sum;
  }


            

Reported by PMD.

android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBenchmark.java
12 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

              public class MonitorBenchmark {

  @Param({"10", "100", "1000"})
  int capacity;

  @Param({"Array", "Priority"})
  String queueType;

  @Param boolean useMonitor;

            

Reported by PMD.

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

Line: 36

                int capacity;

  @Param({"Array", "Priority"})
  String queueType;

  @Param boolean useMonitor;

  private BlockingQueue<String> queue;
  private String[] strings;

            

Reported by PMD.

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

Line: 38

                @Param({"Array", "Priority"})
  String queueType;

  @Param boolean useMonitor;

  private BlockingQueue<String> queue;
  private String[] strings;

  @BeforeExperiment

            

Reported by PMD.

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

Line: 40

              
  @Param boolean useMonitor;

  private BlockingQueue<String> queue;
  private String[] strings;

  @BeforeExperiment
  @SuppressWarnings("unchecked")
  void setUp() throws Exception {

            

Reported by PMD.

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

Line: 41

                @Param boolean useMonitor;

  private BlockingQueue<String> queue;
  private String[] strings;

  @BeforeExperiment
  @SuppressWarnings("unchecked")
  void setUp() throws Exception {
    String prefix =

            

Reported by PMD.

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

Line: 43

                private BlockingQueue<String> queue;
  private String[] strings;

  @BeforeExperiment
  @SuppressWarnings("unchecked")
  void setUp() throws Exception {
    String prefix =
        (useMonitor ? "com.google.common.util.concurrent.MonitorBased" : "java.util.concurrent.");
    String className = prefix + queueType + "BlockingQueue";

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 45

              
  @BeforeExperiment
  @SuppressWarnings("unchecked")
  void setUp() throws Exception {
    String prefix =
        (useMonitor ? "com.google.common.util.concurrent.MonitorBased" : "java.util.concurrent.");
    String className = prefix + queueType + "BlockingQueue";
    Constructor<?> constructor = Class.forName(className).getConstructor(int.class);
    queue = (BlockingQueue<String>) constructor.newInstance(capacity);

            

Reported by PMD.

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

Line: 49

                  String prefix =
        (useMonitor ? "com.google.common.util.concurrent.MonitorBased" : "java.util.concurrent.");
    String className = prefix + queueType + "BlockingQueue";
    Constructor<?> constructor = Class.forName(className).getConstructor(int.class);
    queue = (BlockingQueue<String>) constructor.newInstance(capacity);

    strings = new String[capacity];
    for (int i = 0; i < capacity; i++) {
      strings[i] = String.valueOf(Math.random());

            

Reported by PMD.

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

Line: 50

                      (useMonitor ? "com.google.common.util.concurrent.MonitorBased" : "java.util.concurrent.");
    String className = prefix + queueType + "BlockingQueue";
    Constructor<?> constructor = Class.forName(className).getConstructor(int.class);
    queue = (BlockingQueue<String>) constructor.newInstance(capacity);

    strings = new String[capacity];
    for (int i = 0; i < capacity; i++) {
      strings[i] = String.valueOf(Math.random());
    }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'capacity' (lines '60'-'71').
Error

Line: 60

              
  @Benchmark
  void addsAndRemoves(int reps) {
    int capacity = this.capacity;
    BlockingQueue<String> queue = this.queue;
    String[] strings = this.strings;
    for (int i = 0; i < reps; i++) {
      for (int j = 0; j < capacity; j++) {
        queue.add(strings[j]);

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java
12 issues
Avoid unused local variables such as 'mutex'.
Design

Line: 81

                public static final class SynchronizedHashBiMapGenerator extends TestStringBiMapGenerator {
    @Override
    protected BiMap<String, String> create(Entry<String, String>[] entries) {
      Object mutex = new Object();
      BiMap<String, String> result = HashBiMap.create();
      for (Entry<String, String> entry : entries) {
        checkArgument(!result.containsKey(entry.getKey()));
        result.put(entry.getKey(), entry.getValue());
      }

            

Reported by PMD.

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

Line: 106

                }

  static class TestBiMap<K, V> extends TestMap<K, V> implements BiMap<K, V> {
    private final BiMap<K, V> delegate;

    public TestBiMap(BiMap<K, V> delegate, Object mutex) {
      super(delegate, mutex);
      this.delegate = delegate;
    }

            

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

                  private static final long serialVersionUID = 0;
  }

  public void testForcePut() {
    create().forcePut(null, null);
  }

  public void testInverse() {
    BiMap<String, Integer> bimap = create();

            

Reported by PMD.

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

Line: 135

                }

  public void testForcePut() {
    create().forcePut(null, null);
  }

  public void testInverse() {
    BiMap<String, Integer> bimap = create();
    BiMap<Integer, String> inverse = bimap.inverse();

            

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

                  create().forcePut(null, null);
  }

  public void testInverse() {
    BiMap<String, Integer> bimap = create();
    BiMap<Integer, String> inverse = bimap.inverse();
    assertSame(bimap, inverse.inverse());
    assertTrue(inverse instanceof SynchronizedBiMap);
    assertSame(mutex, ((SynchronizedBiMap<?, ?>) inverse).mutex);

            

Reported by PMD.

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

Line: 138

                  create().forcePut(null, null);
  }

  public void testInverse() {
    BiMap<String, Integer> bimap = create();
    BiMap<Integer, String> inverse = bimap.inverse();
    assertSame(bimap, inverse.inverse());
    assertTrue(inverse instanceof SynchronizedBiMap);
    assertSame(mutex, ((SynchronizedBiMap<?, ?>) inverse).mutex);

            

Reported by PMD.

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

Line: 140

              
  public void testInverse() {
    BiMap<String, Integer> bimap = create();
    BiMap<Integer, String> inverse = bimap.inverse();
    assertSame(bimap, inverse.inverse());
    assertTrue(inverse instanceof SynchronizedBiMap);
    assertSame(mutex, ((SynchronizedBiMap<?, ?>) inverse).mutex);
  }


            

Reported by PMD.

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

Line: 141

                public void testInverse() {
    BiMap<String, Integer> bimap = create();
    BiMap<Integer, String> inverse = bimap.inverse();
    assertSame(bimap, inverse.inverse());
    assertTrue(inverse instanceof SynchronizedBiMap);
    assertSame(mutex, ((SynchronizedBiMap<?, ?>) inverse).mutex);
  }

  @Override

            

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

                  assertSame(mutex, ((SynchronizedBiMap<?, ?>) inverse).mutex);
  }

  @Override
  public void testValues() {
    BiMap<String, Integer> map = create();
    Set<Integer> values = map.values();
    assertTrue(values instanceof SynchronizedSet);
    assertSame(mutex, ((SynchronizedSet<?>) values).mutex);

            

Reported by PMD.

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

Line: 147

                }

  @Override
  public void testValues() {
    BiMap<String, Integer> map = create();
    Set<Integer> values = map.values();
    assertTrue(values instanceof SynchronizedSet);
    assertSame(mutex, ((SynchronizedSet<?>) values).mutex);
  }

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/AbstractListIndexOfTester.java
12 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

                /** Override to return "indexOf" or "lastIndexOf()" for use in failure messages. */
  protected abstract String getMethodName();

  @CollectionSize.Require(absent = ZERO)
  public void testFind_yes() {
    assertEquals(
        getMethodName() + "(firstElement) should return 0", 0, find(getOrderedElements().get(0)));
  }


            

Reported by PMD.

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

Line: 45

                @CollectionSize.Require(absent = ZERO)
  public void testFind_yes() {
    assertEquals(
        getMethodName() + "(firstElement) should return 0", 0, find(getOrderedElements().get(0)));
  }

  public void testFind_no() {
    assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
  }

            

Reported by PMD.

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

Line: 48

                      getMethodName() + "(firstElement) should return 0", 0, find(getOrderedElements().get(0)));
  }

  public void testFind_no() {
    assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testFind_nullNotContainedButSupported() {

            

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(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testFind_nullNotContainedButSupported() {
    assertEquals(getMethodName() + "(nullNotPresent) should return -1", -1, find(null));
  }

  @CollectionFeature.Require(absent = ALLOWS_NULL_VALUES)

            

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

                  assertEquals(getMethodName() + "(nullNotPresent) should return -1", -1, find(null));
  }

  @CollectionFeature.Require(absent = ALLOWS_NULL_VALUES)
  public void testFind_nullNotContainedAndUnsupported() {
    try {
      assertEquals(getMethodName() + "(nullNotPresent) should return -1 or throw", -1, find(null));
    } catch (NullPointerException tolerated) {
    }

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 61

                public void testFind_nullNotContainedAndUnsupported() {
    try {
      assertEquals(getMethodName() + "(nullNotPresent) should return -1 or throw", -1, find(null));
    } catch (NullPointerException tolerated) {
    }
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 61

                public void testFind_nullNotContainedAndUnsupported() {
    try {
      assertEquals(getMethodName() + "(nullNotPresent) should return -1 or throw", -1, find(null));
    } catch (NullPointerException tolerated) {
    }
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

Avoid catching NullPointerException; consider removing the cause of the NPE.
Error

Line: 61

                public void testFind_nullNotContainedAndUnsupported() {
    try {
      assertEquals(getMethodName() + "(nullNotPresent) should return -1 or throw", -1, find(null));
    } catch (NullPointerException tolerated) {
    }
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 65

                  }
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testFind_nonNullWhenNullContained() {
    initCollectionWithNullElement();
    assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
  }

            

Reported by PMD.

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

Line: 72

                  assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
  }

  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testFind_nullContained() {
    initCollectionWithNullElement();
    assertEquals(
        getMethodName() + "(null) should return " + getNullLocation(),

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/features/FeatureUtil.java
12 issues
All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 41

               * @author George van den Driessche
 */
@GwtIncompatible
public class FeatureUtil {
  /** A cache of annotated objects (typically a Class or Method) to its set of annotations. */
  private static Map<AnnotatedElement, List<Annotation>> annotationCache = new HashMap<>();

  private static final Map<Class<?>, TesterRequirements> classTesterRequirementsCache =
      new HashMap<>();

            

Reported by PMD.

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

Line: 62

                  Queue<Feature<?>> queue = new ArrayDeque<>(features);
    while (!queue.isEmpty()) {
      Feature<?> feature = queue.remove();
      for (Feature<?> implied : feature.getImpliedFeatures()) {
        if (features.add(implied)) {
          queue.add(implied);
        }
      }
    }

            

Reported by PMD.

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

Line: 83

                  Queue<Feature<?>> queue = new ArrayDeque<>(features);
    while (!queue.isEmpty()) {
      Feature<?> feature = queue.remove();
      for (Feature<?> implied : feature.getImpliedFeatures()) {
        if (!features.contains(implied) && impliedSet.add(implied)) {
          queue.add(implied);
        }
      }
    }

            

Reported by PMD.

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

Line: 182

                  final Feature<?>[] presentFeatures;
    final Feature<?>[] absentFeatures;
    try {
      presentFeatures = (Feature[]) annotationClass.getMethod("value").invoke(testerAnnotation);
      absentFeatures = (Feature[]) annotationClass.getMethod("absent").invoke(testerAnnotation);
    } catch (Exception e) {
      throw new IllegalArgumentException("Error extracting features from tester annotation.", e);
    }
    Set<Feature<?>> allPresentFeatures =

            

Reported by PMD.

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

Line: 183

                  final Feature<?>[] absentFeatures;
    try {
      presentFeatures = (Feature[]) annotationClass.getMethod("value").invoke(testerAnnotation);
      absentFeatures = (Feature[]) annotationClass.getMethod("absent").invoke(testerAnnotation);
    } catch (Exception e) {
      throw new IllegalArgumentException("Error extracting features from tester annotation.", e);
    }
    Set<Feature<?>> allPresentFeatures =
        addImpliedFeatures(Helpers.<Feature<?>>copyToSet(presentFeatures));

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 184

                  try {
      presentFeatures = (Feature[]) annotationClass.getMethod("value").invoke(testerAnnotation);
      absentFeatures = (Feature[]) annotationClass.getMethod("absent").invoke(testerAnnotation);
    } catch (Exception e) {
      throw new IllegalArgumentException("Error extracting features from tester annotation.", e);
    }
    Set<Feature<?>> allPresentFeatures =
        addImpliedFeatures(Helpers.<Feature<?>>copyToSet(presentFeatures));
    Set<Feature<?>> allAbsentFeatures =

            

Reported by PMD.

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

Line: 236

                    if (annotations == null) {
        annotations = new ArrayList<>();
        for (Annotation a : classOrMethod.getDeclaredAnnotations()) {
          if (a.annotationType().isAnnotationPresent(TesterAnnotation.class)) {
            annotations.add(a);
          }
        }
        annotations = Collections.unmodifiableList(annotations);
        annotationCache.put(classOrMethod, annotations);

            

Reported by PMD.

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

Line: 266

                  Set<Feature<?>> moreAbsentFeatures = moreRequirements.getAbsentFeatures();
    checkConflict("absent", absentFeatures, "present", morePresentFeatures, source);
    checkConflict("present", presentFeatures, "absent", moreAbsentFeatures, source);
    presentFeatures.addAll(morePresentFeatures);
    absentFeatures.addAll(moreAbsentFeatures);
    return requirements;
  }

  // Used by incorporateRequirements() only

            

Reported by PMD.

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

Line: 267

                  checkConflict("absent", absentFeatures, "present", morePresentFeatures, source);
    checkConflict("present", presentFeatures, "absent", moreAbsentFeatures, source);
    presentFeatures.addAll(morePresentFeatures);
    absentFeatures.addAll(moreAbsentFeatures);
    return requirements;
  }

  // Used by incorporateRequirements() only
  private static void checkConflict(

            

Reported by PMD.

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

Line: 295

                /** Construct a new {@link java.util.Set} that is the intersection of the given sets. */
  public static <T> Set<T> intersection(Set<? extends T> set1, Set<? extends T> set2) {
    Set<T> result = Helpers.<T>copyToSet(set1);
    result.retainAll(set2);
    return result;
  }
}

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/TreeTraverserTest.java
12 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 35

              @GwtCompatible(emulated = true)
public class TreeTraverserTest extends TestCase {
  private static class Node {
    final char value;

    Node(char value) {
      this.value = value;
    }
  }

            

Reported by PMD.

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

Line: 43

                }

  private static final class Tree extends Node {
    final List<Tree> children;

    public Tree(char value, Tree... children) {
      super(value);
      this.children = Arrays.asList(children);
    }

            

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

                  return builder.toString();
  }

  public void testPreOrder() {
    assertThat(iterationOrder(ADAPTER.preOrderTraversal(h))).isEqualTo("hdabcegf");
  }

  public void testPostOrder() {
    assertThat(iterationOrder(ADAPTER.postOrderTraversal(h))).isEqualTo("abcdefgh");

            

Reported by PMD.

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

Line: 93

                }

  public void testPreOrder() {
    assertThat(iterationOrder(ADAPTER.preOrderTraversal(h))).isEqualTo("hdabcegf");
  }

  public void testPostOrder() {
    assertThat(iterationOrder(ADAPTER.postOrderTraversal(h))).isEqualTo("abcdefgh");
  }

            

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

                  assertThat(iterationOrder(ADAPTER.preOrderTraversal(h))).isEqualTo("hdabcegf");
  }

  public void testPostOrder() {
    assertThat(iterationOrder(ADAPTER.postOrderTraversal(h))).isEqualTo("abcdefgh");
  }

  public void testBreadthOrder() {
    assertThat(iterationOrder(ADAPTER.breadthFirstTraversal(h))).isEqualTo("hdegabcf");

            

Reported by PMD.

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

Line: 97

                }

  public void testPostOrder() {
    assertThat(iterationOrder(ADAPTER.postOrderTraversal(h))).isEqualTo("abcdefgh");
  }

  public void testBreadthOrder() {
    assertThat(iterationOrder(ADAPTER.breadthFirstTraversal(h))).isEqualTo("hdegabcf");
  }

            

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

                  assertThat(iterationOrder(ADAPTER.postOrderTraversal(h))).isEqualTo("abcdefgh");
  }

  public void testBreadthOrder() {
    assertThat(iterationOrder(ADAPTER.breadthFirstTraversal(h))).isEqualTo("hdegabcf");
  }

  public void testUsing() {
    assertThat(iterationOrder(ADAPTER_USING_USING.preOrderTraversal(h))).isEqualTo("hdabcegf");

            

Reported by PMD.

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

Line: 101

                }

  public void testBreadthOrder() {
    assertThat(iterationOrder(ADAPTER.breadthFirstTraversal(h))).isEqualTo("hdegabcf");
  }

  public void testUsing() {
    assertThat(iterationOrder(ADAPTER_USING_USING.preOrderTraversal(h))).isEqualTo("hdabcegf");
  }

            

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

                  assertThat(iterationOrder(ADAPTER.breadthFirstTraversal(h))).isEqualTo("hdegabcf");
  }

  public void testUsing() {
    assertThat(iterationOrder(ADAPTER_USING_USING.preOrderTraversal(h))).isEqualTo("hdabcegf");
  }

  @GwtIncompatible // NullPointerTester
  public void testNulls() {

            

Reported by PMD.

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

Line: 105

                }

  public void testUsing() {
    assertThat(iterationOrder(ADAPTER_USING_USING.preOrderTraversal(h))).isEqualTo("hdabcegf");
  }

  @GwtIncompatible // NullPointerTester
  public void testNulls() {
    NullPointerTester tester = new NullPointerTester();

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/MultimapContainsValueTester.java
12 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: 38

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapContainsValueTester<K, V>
    extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @CollectionSize.Require(absent = ZERO)
  public void testContainsValueYes() {
    assertTrue(multimap().containsValue(v0()));
  }

  public void testContainsValueNo() {

            

Reported by PMD.

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

Line: 40

                  extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @CollectionSize.Require(absent = ZERO)
  public void testContainsValueYes() {
    assertTrue(multimap().containsValue(v0()));
  }

  public void testContainsValueNo() {
    assertFalse(multimap().containsValue(v3()));
  }

            

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

                  assertTrue(multimap().containsValue(v0()));
  }

  public void testContainsValueNo() {
    assertFalse(multimap().containsValue(v3()));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 44

                }

  public void testContainsValueNo() {
    assertFalse(multimap().containsValue(v3()));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testContainsNullValueYes() {

            

Reported by PMD.

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

Line: 47

                  assertFalse(multimap().containsValue(v3()));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testContainsNullValueYes() {
    initMultimapWithNullValue();
    assertTrue(multimap().containsValue(null));
  }

            

Reported by PMD.

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

Line: 51

                @CollectionSize.Require(absent = ZERO)
  public void testContainsNullValueYes() {
    initMultimapWithNullValue();
    assertTrue(multimap().containsValue(null));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
  public void testContainsNullValueNo() {
    assertFalse(multimap().containsValue(null));

            

Reported by PMD.

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

Line: 54

                  assertTrue(multimap().containsValue(null));
  }

  @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
  public void testContainsNullValueNo() {
    assertFalse(multimap().containsValue(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_VALUE_QUERIES)

            

Reported by PMD.

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

Line: 56

              
  @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
  public void testContainsNullValueNo() {
    assertFalse(multimap().containsValue(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_VALUE_QUERIES)
  public void testContainsNullValueFails() {
    try {

            

Reported by PMD.

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

Line: 59

                  assertFalse(multimap().containsValue(null));
  }

  @MapFeature.Require(absent = ALLOWS_NULL_VALUE_QUERIES)
  public void testContainsNullValueFails() {
    try {
      multimap().containsValue(null);
      fail("Expected NullPointerException");
    } catch (NullPointerException expected) {

            

Reported by PMD.

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

Line: 62

                @MapFeature.Require(absent = ALLOWS_NULL_VALUE_QUERIES)
  public void testContainsNullValueFails() {
    try {
      multimap().containsValue(null);
      fail("Expected NullPointerException");
    } catch (NullPointerException expected) {
      // success
    }
  }

            

Reported by PMD.

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

Line: 44

                private static final int RANDOM_SEED = new Random().nextInt();

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

  private byte[] testBytes;

  @BeforeExperiment
  void setUp() {

            

Reported by PMD.

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

Line: 46

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

  private byte[] testBytes;

  @BeforeExperiment
  void setUp() {
    testBytes = new byte[size];
    new Random(RANDOM_SEED).nextBytes(testBytes);

            

Reported by PMD.

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

Line: 48

              
  private byte[] testBytes;

  @BeforeExperiment
  void setUp() {
    testBytes = new byte[size];
    new Random(RANDOM_SEED).nextBytes(testBytes);
  }


            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 62

                }

  @Benchmark
  byte crc32Checksum(int reps) throws Exception {
    byte result = 0x01;
    for (int i = 0; i < reps; i++) {
      CRC32 checksum = new CRC32();
      checksum.update(testBytes);
      result = (byte) (result ^ checksum.getValue());

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 65

                byte crc32Checksum(int reps) throws Exception {
    byte result = 0x01;
    for (int i = 0; i < reps; i++) {
      CRC32 checksum = new CRC32();
      checksum.update(testBytes);
      result = (byte) (result ^ checksum.getValue());
    }
    return result;
  }

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 80

                }

  @Benchmark
  byte adler32Checksum(int reps) throws Exception {
    byte result = 0x01;
    for (int i = 0; i < reps; i++) {
      Adler32 checksum = new Adler32();
      checksum.update(testBytes);
      result = (byte) (result ^ checksum.getValue());

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 83

                byte adler32Checksum(int reps) throws Exception {
    byte result = 0x01;
    for (int i = 0; i < reps; i++) {
      Adler32 checksum = new Adler32();
      checksum.update(testBytes);
      result = (byte) (result ^ checksum.getValue());
    }
    return result;
  }

            

Reported by PMD.

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

Line: 95

                private byte runHashFunction(int reps, HashFunction hashFunction) {
    byte result = 0x01;
    // Trick the JVM to prevent it from using the hash function non-polymorphically
    result ^= Hashing.crc32().hashInt(reps).asBytes()[0];
    result ^= Hashing.adler32().hashInt(reps).asBytes()[0];
    for (int i = 0; i < reps; i++) {
      result ^= hashFunction.hashBytes(testBytes).asBytes()[0];
    }
    return result;

            

Reported by PMD.

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

Line: 95

                private byte runHashFunction(int reps, HashFunction hashFunction) {
    byte result = 0x01;
    // Trick the JVM to prevent it from using the hash function non-polymorphically
    result ^= Hashing.crc32().hashInt(reps).asBytes()[0];
    result ^= Hashing.adler32().hashInt(reps).asBytes()[0];
    for (int i = 0; i < reps; i++) {
      result ^= hashFunction.hashBytes(testBytes).asBytes()[0];
    }
    return result;

            

Reported by PMD.

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

Line: 96

                  byte result = 0x01;
    // Trick the JVM to prevent it from using the hash function non-polymorphically
    result ^= Hashing.crc32().hashInt(reps).asBytes()[0];
    result ^= Hashing.adler32().hashInt(reps).asBytes()[0];
    for (int i = 0; i < reps; i++) {
      result ^= hashFunction.hashBytes(testBytes).asBytes()[0];
    }
    return result;
  }

            

Reported by PMD.

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

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetEqualsTester<E> extends AbstractMultisetTester<E> {
  public void testEqualsSameContents() {
    new EqualsTester()
        .addEqualityGroup(
            getMultiset(), getSubjectGenerator().create(getSampleElements().toArray()))
        .testEquals();
  }

            

Reported by PMD.

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

Line: 37

                public void testEqualsSameContents() {
    new EqualsTester()
        .addEqualityGroup(
            getMultiset(), getSubjectGenerator().create(getSampleElements().toArray()))
        .testEquals();
  }

  @CollectionSize.Require(absent = ZERO)
  public void testNotEqualsEmpty() {

            

Reported by PMD.

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

Line: 37

                public void testEqualsSameContents() {
    new EqualsTester()
        .addEqualityGroup(
            getMultiset(), getSubjectGenerator().create(getSampleElements().toArray()))
        .testEquals();
  }

  @CollectionSize.Require(absent = ZERO)
  public void testNotEqualsEmpty() {

            

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

                      .testEquals();
  }

  @CollectionSize.Require(absent = ZERO)
  public void testNotEqualsEmpty() {
    new EqualsTester()
        .addEqualityGroup(getMultiset())
        .addEqualityGroup(getSubjectGenerator().create())
        .testEquals();

            

Reported by PMD.

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

Line: 45

                public void testNotEqualsEmpty() {
    new EqualsTester()
        .addEqualityGroup(getMultiset())
        .addEqualityGroup(getSubjectGenerator().create())
        .testEquals();
  }

  public void testHashCodeMatchesEntrySet() {
    assertEquals(getMultiset().entrySet().hashCode(), getMultiset().hashCode());

            

Reported by PMD.

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

Line: 49

                      .testEquals();
  }

  public void testHashCodeMatchesEntrySet() {
    assertEquals(getMultiset().entrySet().hashCode(), getMultiset().hashCode());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)

            

Reported by PMD.

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

Line: 50

                }

  public void testHashCodeMatchesEntrySet() {
    assertEquals(getMultiset().entrySet().hashCode(), getMultiset().hashCode());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testEqualsMultisetWithNullValue() {

            

Reported by PMD.

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

Line: 50

                }

  public void testHashCodeMatchesEntrySet() {
    assertEquals(getMultiset().entrySet().hashCode(), getMultiset().hashCode());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testEqualsMultisetWithNullValue() {

            

Reported by PMD.

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

Line: 50

                }

  public void testHashCodeMatchesEntrySet() {
    assertEquals(getMultiset().entrySet().hashCode(), getMultiset().hashCode());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testEqualsMultisetWithNullValue() {

            

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

                  assertEquals(getMultiset().entrySet().hashCode(), getMultiset().hashCode());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  public void testEqualsMultisetWithNullValue() {
    new EqualsTester()
        .addEqualityGroup(getMultiset())
        .addEqualityGroup(

            

Reported by PMD.

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

Line: 50

                private static final Random random = new Random(42);

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

  @Param WhereToDiffer whereToDiffer;

  @Param EqualsImplementation equalsImpl;


            

Reported by PMD.

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

Line: 52

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

  @Param WhereToDiffer whereToDiffer;

  @Param EqualsImplementation equalsImpl;

  private enum WhereToDiffer {
    ONE_PERCENT_IN,

            

Reported by PMD.

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

Line: 54

              
  @Param WhereToDiffer whereToDiffer;

  @Param EqualsImplementation equalsImpl;

  private enum WhereToDiffer {
    ONE_PERCENT_IN,
    LAST_BYTE,
    NOT_AT_ALL;

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 66

                  ANDING_BOOLEANS {
      @Override
      boolean doEquals(byte[] a, byte[] b) {
        if (a.length != b.length) {
          return false;
        }
        boolean areEqual = true;
        for (int i = 0; i < a.length; i++) {
          areEqual &= (a[i] == b[i]);

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 79

                  XORING_TO_BYTE {
      @Override
      boolean doEquals(byte[] a, byte[] b) {
        if (a.length != b.length) {
          return false;
        }
        byte result = 0;
        for (int i = 0; i < a.length; i++) {
          result = (byte) (result | a[i] ^ b[i]);

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 92

                  XORING_TO_INT {
      @Override
      boolean doEquals(byte[] a, byte[] b) {
        if (a.length != b.length) {
          return false;
        }
        int result = 0;
        for (int i = 0; i < a.length; i++) {
          result |= a[i] ^ b[i];

            

Reported by PMD.

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

Line: 118

                  abstract boolean doEquals(byte[] a, byte[] b);
  }

  private byte[] testBytesA;
  private byte[] testBytesB;

  @BeforeExperiment
  void setUp() {
    testBytesA = new byte[size];

            

Reported by PMD.

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

Line: 119

                }

  private byte[] testBytesA;
  private byte[] testBytesB;

  @BeforeExperiment
  void setUp() {
    testBytesA = new byte[size];
    random.nextBytes(testBytesA);

            

Reported by PMD.

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

Line: 121

                private byte[] testBytesA;
  private byte[] testBytesB;

  @BeforeExperiment
  void setUp() {
    testBytesA = new byte[size];
    random.nextBytes(testBytesA);
    testBytesB = Arrays.copyOf(testBytesA, size);
    int indexToDifferAt = -1;

            

Reported by PMD.

Switch statements should have a default label
Design

Line: 127

                  random.nextBytes(testBytesA);
    testBytesB = Arrays.copyOf(testBytesA, size);
    int indexToDifferAt = -1;
    switch (whereToDiffer) {
      case ONE_PERCENT_IN:
        indexToDifferAt = (int) (size * 0.01);
        break;
      case LAST_BYTE:
        indexToDifferAt = size - 1;

            

Reported by PMD.