The following issues were found

android/guava-tests/test/com/google/common/io/SourceSinkTester.java
10 issues
This class name ends with Test but contains no test cases
Error

Line: 39

               * @author Colin Decker
 */
@AndroidIncompatible // Android doesn't understand tests that lack default constructors.
public class SourceSinkTester<S, T, F extends SourceSinkFactory<S, T>> extends TestCase {

  static final String LOREM_IPSUM =
      "Lorem ipsum dolor sit amet, consectetur adipiscing "
          + "elit. Cras fringilla elit ac ipsum adipiscing vulputate. Maecenas in lorem nulla, ac "
          + "sollicitudin quam. Praesent neque elit, sodales quis vestibulum vel, pellentesque nec "

            

Reported by PMD.

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

Line: 74

                        .put("lorem ipsum", LOREM_IPSUM)
          .build();

  protected final F factory;
  protected final T data;
  protected final T expected;

  private final String suiteName;
  private final String caseDesc;

            

Reported by PMD.

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

Line: 75

                        .build();

  protected final F factory;
  protected final T data;
  protected final T expected;

  private final String suiteName;
  private final String caseDesc;


            

Reported by PMD.

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

Line: 76

              
  protected final F factory;
  protected final T data;
  protected final T expected;

  private final String suiteName;
  private final String caseDesc;

  SourceSinkTester(F factory, T data, String suiteName, String caseDesc, Method method) {

            

Reported by PMD.

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

Line: 78

                protected final T data;
  protected final T expected;

  private final String suiteName;
  private final String caseDesc;

  SourceSinkTester(F factory, T data, String suiteName, String caseDesc, Method method) {
    super(method.getName());
    this.factory = checkNotNull(factory);

            

Reported by PMD.

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

Line: 79

                protected final T expected;

  private final String suiteName;
  private final String caseDesc;

  SourceSinkTester(F factory, T data, String suiteName, String caseDesc, Method method) {
    super(method.getName());
    this.factory = checkNotNull(factory);
    this.data = checkNotNull(data);

            

Reported by PMD.

New exception is thrown in catch block, original stack trace may be lost
Design

Line: 104

                      }
      }.readLines();
    } catch (IOException e) {
      throw new AssertionError();
    }
  }

  @Override
  public void tearDown() throws IOException {

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 108

                  }
  }

  @Override
  public void tearDown() throws IOException {
    factory.tearDown();
  }

  static ImmutableList<Method> getTestMethods(Class<?> testClass) {

            

Reported by PMD.

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

Line: 118

                  for (Method method : testClass.getDeclaredMethods()) {
      if (Modifier.isPublic(method.getModifiers())
          && method.getReturnType() == void.class
          && method.getParameterTypes().length == 0
          && method.getName().startsWith("test")) {
        result.add(method);
      }
    }
    return ImmutableList.copyOf(result);

            

Reported by PMD.

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

Line: 119

                    if (Modifier.isPublic(method.getModifiers())
          && method.getReturnType() == void.class
          && method.getParameterTypes().length == 0
          && method.getName().startsWith("test")) {
        result.add(method);
      }
    }
    return ImmutableList.copyOf(result);
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
10 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: 33

               */
public class PatternFilenameFilterTest extends TestCase {

  public void testSyntaxException() {
    try {
      new PatternFilenameFilter("(");
      fail("expected exception");
    } catch (PatternSyntaxException expected) {
    }

            

Reported by PMD.

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

Line: 36

                public void testSyntaxException() {
    try {
      new PatternFilenameFilter("(");
      fail("expected exception");
    } catch (PatternSyntaxException expected) {
    }
  }

  public void testAccept() {

            

Reported by PMD.

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

Line: 41

                  }
  }

  public void testAccept() {
    File dir = new File("foo");
    FilenameFilter filter = new PatternFilenameFilter("a+");
    assertTrue(filter.accept(dir, "a"));
    assertTrue(filter.accept(dir, "aaaa"));
    assertFalse(filter.accept(dir, "b"));

            

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

                  }
  }

  public void testAccept() {
    File dir = new File("foo");
    FilenameFilter filter = new PatternFilenameFilter("a+");
    assertTrue(filter.accept(dir, "a"));
    assertTrue(filter.accept(dir, "aaaa"));
    assertFalse(filter.accept(dir, "b"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

                public void testAccept() {
    File dir = new File("foo");
    FilenameFilter filter = new PatternFilenameFilter("a+");
    assertTrue(filter.accept(dir, "a"));
    assertTrue(filter.accept(dir, "aaaa"));
    assertFalse(filter.accept(dir, "b"));

    // Show that dir is ignored
    assertTrue(filter.accept(null, "a"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  File dir = new File("foo");
    FilenameFilter filter = new PatternFilenameFilter("a+");
    assertTrue(filter.accept(dir, "a"));
    assertTrue(filter.accept(dir, "aaaa"));
    assertFalse(filter.accept(dir, "b"));

    // Show that dir is ignored
    assertTrue(filter.accept(null, "a"));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                  FilenameFilter filter = new PatternFilenameFilter("a+");
    assertTrue(filter.accept(dir, "a"));
    assertTrue(filter.accept(dir, "aaaa"));
    assertFalse(filter.accept(dir, "b"));

    // Show that dir is ignored
    assertTrue(filter.accept(null, "a"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                  assertFalse(filter.accept(dir, "b"));

    // Show that dir is ignored
    assertTrue(filter.accept(null, "a"));
  }

  public void testNulls() throws Exception {
    NullPointerTester tester = new NullPointerTester();


            

Reported by PMD.

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

Line: 52

                  assertTrue(filter.accept(null, "a"));
  }

  public void testNulls() throws Exception {
    NullPointerTester tester = new NullPointerTester();

    tester.testConstructors(PatternFilenameFilter.class, Visibility.PACKAGE);
    tester.testStaticMethods(PatternFilenameFilter.class, Visibility.PACKAGE); // currently none


            

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

                  assertTrue(filter.accept(null, "a"));
  }

  public void testNulls() throws Exception {
    NullPointerTester tester = new NullPointerTester();

    tester.testConstructors(PatternFilenameFilter.class, Visibility.PACKAGE);
    tester.testStaticMethods(PatternFilenameFilter.class, Visibility.PACKAGE); // currently none


            

Reported by PMD.

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

Line: 36

               * @author Michael Lancaster
 */
public class FlushablesTest extends TestCase {
  private Flushable mockFlushable;

  public void testFlush_clean() throws IOException {
    // make sure that no exception is thrown regardless of value of
    // 'swallowException' when the mock does not throw an exception.
    setupFlushable(false);

            

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

              public class FlushablesTest extends TestCase {
  private Flushable mockFlushable;

  public void testFlush_clean() throws IOException {
    // make sure that no exception is thrown regardless of value of
    // 'swallowException' when the mock does not throw an exception.
    setupFlushable(false);
    doFlush(mockFlushable, false, false);


            

Reported by PMD.

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

Line: 38

              public class FlushablesTest extends TestCase {
  private Flushable mockFlushable;

  public void testFlush_clean() throws IOException {
    // make sure that no exception is thrown regardless of value of
    // 'swallowException' when the mock does not throw an exception.
    setupFlushable(false);
    doFlush(mockFlushable, false, false);


            

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

                  doFlush(mockFlushable, true, false);
  }

  public void testFlush_flushableWithEatenException() throws IOException {
    // make sure that no exception is thrown if 'swallowException' is true
    // when the mock does throw an exception on flush.
    setupFlushable(true);
    doFlush(mockFlushable, true, false);
  }

            

Reported by PMD.

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

Line: 48

                  doFlush(mockFlushable, true, false);
  }

  public void testFlush_flushableWithEatenException() throws IOException {
    // make sure that no exception is thrown if 'swallowException' is true
    // when the mock does throw an exception on flush.
    setupFlushable(true);
    doFlush(mockFlushable, true, false);
  }

            

Reported by PMD.

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

Line: 55

                  doFlush(mockFlushable, true, false);
  }

  public void testFlush_flushableWithThrownException() throws IOException {
    // make sure that the exception is thrown if 'swallowException' is false
    // when the mock does throw an exception on flush.
    setupFlushable(true);
    doFlush(mockFlushable, false, true);
  }

            

Reported by PMD.

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

Line: 55

                  doFlush(mockFlushable, true, false);
  }

  public void testFlush_flushableWithThrownException() throws IOException {
    // make sure that the exception is thrown if 'swallowException' is false
    // when the mock does throw an exception on flush.
    setupFlushable(true);
    doFlush(mockFlushable, false, true);
  }

            

Reported by PMD.

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

Line: 62

                  doFlush(mockFlushable, false, true);
  }

  public void testFlushQuietly_flushableWithEatenException() throws IOException {
    // make sure that no exception is thrown by flushQuietly when the mock does
    // throw an exception on flush.
    setupFlushable(true);
    Flushables.flushQuietly(mockFlushable);
  }

            

Reported by PMD.

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

Line: 62

                  doFlush(mockFlushable, false, true);
  }

  public void testFlushQuietly_flushableWithEatenException() throws IOException {
    // make sure that no exception is thrown by flushQuietly when the mock does
    // throw an exception on flush.
    setupFlushable(true);
    Flushables.flushQuietly(mockFlushable);
  }

            

Reported by PMD.

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

Line: 97

                      fail("Threw exception");
      }
    }
    verify(flushable).flush();
  }
}

            

Reported by PMD.

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

Line: 41

               * @author Louis Wasserman
 */
public class ForwardingSortedMultisetTest extends TestCase {
  static class StandardImplForwardingSortedMultiset<E> extends ForwardingSortedMultiset<E> {
    private final SortedMultiset<E> backingMultiset;

    StandardImplForwardingSortedMultiset(SortedMultiset<E> backingMultiset) {
      this.backingMultiset = backingMultiset;
    }

            

Reported by PMD.

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

Line: 42

               */
public class ForwardingSortedMultisetTest extends TestCase {
  static class StandardImplForwardingSortedMultiset<E> extends ForwardingSortedMultiset<E> {
    private final SortedMultiset<E> backingMultiset;

    StandardImplForwardingSortedMultiset(SortedMultiset<E> backingMultiset) {
      this.backingMultiset = backingMultiset;
    }


            

Reported by PMD.

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

Line: 59

              
        @Override
        Iterator<Entry<E>> entryIterator() {
          return backingMultiset.descendingMultiset().entrySet().iterator();
        }
      };
    }

    @Override

            

Reported by PMD.

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

Line: 59

              
        @Override
        Iterator<Entry<E>> entryIterator() {
          return backingMultiset.descendingMultiset().entrySet().iterator();
        }
      };
    }

    @Override

            

Reported by PMD.

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

Line: 176

                  }
  }

  public static Test suite() {
    TestSuite suite = new TestSuite();

    suite.addTestSuite(ForwardingSortedMultisetTest.class);
    suite.addTest(
        SortedMultisetTestSuiteBuilder.using(

            

Reported by PMD.

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

Line: 191

              
                  @Override
                  public List<String> order(List<String> insertionOrder) {
                    return Ordering.natural().sortedCopy(insertionOrder);
                  }
                })
            .named("ForwardingSortedMultiset with standard impls")
            .withFeatures(
                CollectionSize.ANY,

            

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

                  return suite;
  }

  @SuppressWarnings({"rawtypes", "unchecked"})
  public void testForwarding() {
    new ForwardingWrapperTester()
        .testForwarding(
            SortedMultiset.class,
            new Function<SortedMultiset, SortedMultiset>() {

            

Reported by PMD.

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

Line: 206

                }

  @SuppressWarnings({"rawtypes", "unchecked"})
  public void testForwarding() {
    new ForwardingWrapperTester()
        .testForwarding(
            SortedMultiset.class,
            new Function<SortedMultiset, SortedMultiset>() {
              @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: 218

                          });
  }

  public void testEquals() {
    SortedMultiset<String> set1 = ImmutableSortedMultiset.of("one");
    SortedMultiset<String> set2 = ImmutableSortedMultiset.of("two");
    new EqualsTester()
        .addEqualityGroup(set1, wrap(set1), wrap(set1))
        .addEqualityGroup(set2, wrap(set2))

            

Reported by PMD.

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

Line: 218

                          });
  }

  public void testEquals() {
    SortedMultiset<String> set1 = ImmutableSortedMultiset.of("one");
    SortedMultiset<String> set2 = ImmutableSortedMultiset.of("two");
    new EqualsTester()
        .addEqualityGroup(set1, wrap(set1), wrap(set1))
        .addEqualityGroup(set2, wrap(set2))

            

Reported by PMD.

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

Line: 32

               * @author Nicholaus Shupe
 */
class CollectionBenchmarkSampleData {
  private final boolean isUserTypeFast;
  private final SpecialRandom random;
  private final double hitRate;
  private final int size;

  private final Set<Element> valuesInSet;

            

Reported by PMD.

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

Line: 33

               */
class CollectionBenchmarkSampleData {
  private final boolean isUserTypeFast;
  private final SpecialRandom random;
  private final double hitRate;
  private final int size;

  private final Set<Element> valuesInSet;
  private final Element[] queries;

            

Reported by PMD.

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

Line: 34

              class CollectionBenchmarkSampleData {
  private final boolean isUserTypeFast;
  private final SpecialRandom random;
  private final double hitRate;
  private final int size;

  private final Set<Element> valuesInSet;
  private final Element[] queries;


            

Reported by PMD.

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

Line: 35

                private final boolean isUserTypeFast;
  private final SpecialRandom random;
  private final double hitRate;
  private final int size;

  private final Set<Element> valuesInSet;
  private final Element[] queries;

  CollectionBenchmarkSampleData(int size) {

            

Reported by PMD.

Returning 'queries' may expose an internal array.
Design

Line: 60

                }

  Element[] getQueries() {
    return queries;
  }

  private Element[] createQueries(Set<Element> elementsInSet, int numQueries) {
    List<Element> queryList = Lists.newArrayListWithCapacity(numQueries);


            

Reported by PMD.

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

Line: 79

                    }
      List<Element> tmp = Lists.newArrayList(elementsInSet);
      Collections.shuffle(tmp, random);
      queryList.addAll(tmp.subList(0, extras));
    }

    // now add bad queries
    while (queryList.size() < numQueries) {
      Element candidate = newElement();

            

Reported by PMD.

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

Line: 83

                  }

    // now add bad queries
    while (queryList.size() < numQueries) {
      Element candidate = newElement();
      if (!elementsInSet.contains(candidate)) {
        queryList.add(candidate);
      }
    }

            

Reported by PMD.

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

Line: 95

              
  private Set<Element> createData() {
    Set<Element> set = Sets.newHashSetWithExpectedSize(size);
    while (set.size() < size) {
      set.add(newElement());
    }
    return set;
  }


            

Reported by PMD.

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

Line: 107

                }

  static class Element implements Comparable<Element> {
    final int hash;

    Element(int hash) {
      this.hash = hash;
    }


            

Reported by PMD.

Found 'DU'-anomaly for variable 'numGoodQueries' (lines '66'-'91').
Error

Line: 66

                private Element[] createQueries(Set<Element> elementsInSet, int numQueries) {
    List<Element> queryList = Lists.newArrayListWithCapacity(numQueries);

    int numGoodQueries = (int) (numQueries * hitRate + 0.5);

    // add good queries
    int size = elementsInSet.size();
    if (size > 0) {
      int minCopiesOfEachGoodQuery = numGoodQueries / size;

            

Reported by PMD.

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

Line: 35

                // Start at 4.88 then multiply by 2*2^phi <evil cackle> - The goal is be uniform
  // yet visit a variety of "values-relative-to-the-next-power-of-2"
  @Param({"5", "30", "180", "1100", "6900", "43000", "260000"}) // "1600000", "9800000"
  private int size;

  // TODO(kevinb): look at exact (==) hits vs. equals() hits?
  @Param({"0.2", "0.8"})
  private double hitRate;


            

Reported by PMD.

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

Line: 39

              
  // TODO(kevinb): look at exact (==) hits vs. equals() hits?
  @Param({"0.2", "0.8"})
  private double hitRate;

  @Param("true")
  private boolean isUserTypeFast;

  // "" means no fixed seed

            

Reported by PMD.

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

Line: 42

                private double hitRate;

  @Param("true")
  private boolean isUserTypeFast;

  // "" means no fixed seed
  @Param("")
  private SpecialRandom random;


            

Reported by PMD.

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

Line: 46

              
  // "" means no fixed seed
  @Param("")
  private SpecialRandom random;

  @Param({"HashSetImpl", "ImmutableSetImpl"})
  private SetImpl impl;

  // the following must be set during setUp

            

Reported by PMD.

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

Line: 49

                private SpecialRandom random;

  @Param({"HashSetImpl", "ImmutableSetImpl"})
  private SetImpl impl;

  // the following must be set during setUp
  private Element[] queries;
  private Set<Element> setToTest;


            

Reported by PMD.

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

Line: 52

                private SetImpl impl;

  // the following must be set during setUp
  private Element[] queries;
  private Set<Element> setToTest;

  @BeforeExperiment
  void setUp() {
    CollectionBenchmarkSampleData sampleData =

            

Reported by PMD.

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

Line: 53

              
  // the following must be set during setUp
  private Element[] queries;
  private Set<Element> setToTest;

  @BeforeExperiment
  void setUp() {
    CollectionBenchmarkSampleData sampleData =
        new CollectionBenchmarkSampleData(isUserTypeFast, random, hitRate, 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: 55

                private Element[] queries;
  private Set<Element> setToTest;

  @BeforeExperiment
  void setUp() {
    CollectionBenchmarkSampleData sampleData =
        new CollectionBenchmarkSampleData(isUserTypeFast, random, hitRate, size);

    this.setToTest = (Set<Element>) impl.create(sampleData.getValuesInSet());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'set' (lines '68'-'78').
Error

Line: 68

                boolean contains(int reps) {
    // Paranoia: acting on hearsay that accessing fields might be slow
    // Should write a benchmark to test that!
    Set<Element> set = setToTest;
    Element[] queries = this.queries;

    int mask = queries.length - 1;

    boolean dummy = false;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'mask' (lines '71'-'78').
Error

Line: 71

                  Set<Element> set = setToTest;
    Element[] queries = this.queries;

    int mask = queries.length - 1;

    boolean dummy = false;
    for (int i = 0; i < reps; i++) {
      dummy ^= set.contains(queries[i & mask]);
    }

            

Reported by PMD.

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

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapToStringTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @CollectionSize.Require(ZERO)
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringEmpty() {
    assertEquals("{}", multimap().toString());
  }


            

Reported by PMD.

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

Line: 41

                @CollectionSize.Require(ZERO)
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringEmpty() {
    assertEquals("{}", multimap().toString());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringSingleton() {

            

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

                  assertEquals("{}", multimap().toString());
  }

  @CollectionSize.Require(ONE)
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringSingleton() {
    assertEquals("{" + k0() + "=[" + v0() + "]}", multimap().toString());
  }


            

Reported by PMD.

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

Line: 47

                @CollectionSize.Require(ONE)
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringSingleton() {
    assertEquals("{" + k0() + "=[" + v0() + "]}", multimap().toString());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  @MapFeature.Require(ALLOWS_NULL_KEYS)

            

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

                  assertEquals("{" + k0() + "=[" + v0() + "]}", multimap().toString());
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  @MapFeature.Require(ALLOWS_NULL_KEYS)
  public void testToStringWithNullKey() {
    initMultimapWithNullKey();
    testToStringMatchesAsMap();

            

Reported by PMD.

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

Line: 58

                  testToStringMatchesAsMap();
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  @MapFeature.Require(ALLOWS_NULL_VALUES)
  public void testToStringWithNullValue() {
    initMultimapWithNullValue();
    testToStringMatchesAsMap();

            

Reported by PMD.

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

Line: 66

                  testToStringMatchesAsMap();
  }

  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringMatchesAsMap() {
    assertEquals(multimap().asMap().toString(), multimap().toString());
  }
}

            

Reported by PMD.

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

Line: 68

              
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringMatchesAsMap() {
    assertEquals(multimap().asMap().toString(), multimap().toString());
  }
}

            

Reported by PMD.

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

Line: 68

              
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringMatchesAsMap() {
    assertEquals(multimap().asMap().toString(), multimap().toString());
  }
}

            

Reported by PMD.

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

Line: 68

              
  @CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
  public void testToStringMatchesAsMap() {
    assertEquals(multimap().asMap().toString(), multimap().toString());
  }
}

            

Reported by PMD.

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

Line: 44

                      });
  }

  private final boolean allowsSelfLoops;
  private final boolean allowsParallelEdges;
  private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;

            

Reported by PMD.

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

Line: 45

                }

  private final boolean allowsSelfLoops;
  private final boolean allowsParallelEdges;
  private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;


            

Reported by PMD.

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

Line: 46

              
  private final boolean allowsSelfLoops;
  private final boolean allowsParallelEdges;
  private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;

  public StandardImmutableDirectedNetworkTest(

            

Reported by PMD.

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

Line: 47

                private final boolean allowsSelfLoops;
  private final boolean allowsParallelEdges;
  private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;

  public StandardImmutableDirectedNetworkTest(
      boolean allowsSelfLoops,

            

Reported by PMD.

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

Line: 49

                private final ElementOrder<Integer> nodeOrder;
  private final ElementOrder<String> edgeOrder;

  private ImmutableNetwork.Builder<Integer, String> networkBuilder;

  public StandardImmutableDirectedNetworkTest(
      boolean allowsSelfLoops,
      boolean allowsParallelEdges,
      ElementOrder<Integer> nodeOrder,

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

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

Line: 65

                @Override
  Network<Integer, String> createGraph() {
    networkBuilder =
        NetworkBuilder.directed()
            .allowsSelfLoops(allowsSelfLoops)
            .allowsParallelEdges(allowsParallelEdges)
            .nodeOrder(nodeOrder)
            .edgeOrder(edgeOrder)
            .immutable();

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/testers/ListRetainAllTester.java
10 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: 41

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListRetainAllTester<E> extends AbstractListTester<E> {
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = {ZERO, ONE})
  public void testRetainAll_duplicatesKept() {
    E[] array = createSamplesArray();
    array[1] = e0();
    collection = getSubjectGenerator().create(array);

            

Reported by PMD.

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

Line: 46

                public void testRetainAll_duplicatesKept() {
    E[] array = createSamplesArray();
    array[1] = e0();
    collection = getSubjectGenerator().create(array);
    assertFalse(
        "containsDuplicates.retainAll(superset) should return false",
        collection.retainAll(MinimalCollection.of(createSamplesArray())));
    expectContents(array);
  }

            

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

                  expectContents(array);
  }

  @SuppressWarnings("unchecked")
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(SEVERAL)
  public void testRetainAll_duplicatesRemoved() {
    E[] array = createSamplesArray();
    array[1] = e0();

            

Reported by PMD.

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

Line: 59

                public void testRetainAll_duplicatesRemoved() {
    E[] array = createSamplesArray();
    array[1] = e0();
    collection = getSubjectGenerator().create(array);
    assertTrue(
        "containsDuplicates.retainAll(subset) should return true",
        collection.retainAll(MinimalCollection.of(e2())));
    expectContents(e2());
  }

            

Reported by PMD.

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

Line: 66

                  expectContents(e2());
  }

  @SuppressWarnings("unchecked")
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(SEVERAL)
  public void testRetainAll_countIgnored() {
    resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0()));
    assertTrue(getList().retainAll(Arrays.asList(e0(), e1())));

            

Reported by PMD.

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

Line: 69

                @SuppressWarnings("unchecked")
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(SEVERAL)
  public void testRetainAll_countIgnored() {
    resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0()));
    assertTrue(getList().retainAll(Arrays.asList(e0(), e1())));
    assertContentsInOrder(getList(), e0(), e1(), e0());
  }
}

            

Reported by PMD.

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

Line: 70

                @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(SEVERAL)
  public void testRetainAll_countIgnored() {
    resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0()));
    assertTrue(getList().retainAll(Arrays.asList(e0(), e1())));
    assertContentsInOrder(getList(), e0(), e1(), e0());
  }
}

            

Reported by PMD.

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

Line: 71

                @CollectionSize.Require(SEVERAL)
  public void testRetainAll_countIgnored() {
    resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0()));
    assertTrue(getList().retainAll(Arrays.asList(e0(), e1())));
    assertContentsInOrder(getList(), e0(), e1(), e0());
  }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '44'-'45').
Error

Line: 44

                @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = {ZERO, ONE})
  public void testRetainAll_duplicatesKept() {
    E[] array = createSamplesArray();
    array[1] = e0();
    collection = getSubjectGenerator().create(array);
    assertFalse(
        "containsDuplicates.retainAll(superset) should return false",
        collection.retainAll(MinimalCollection.of(createSamplesArray())));

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '57'-'58').
Error

Line: 57

                @CollectionFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(SEVERAL)
  public void testRetainAll_duplicatesRemoved() {
    E[] array = createSamplesArray();
    array[1] = e0();
    collection = getSubjectGenerator().create(array);
    assertTrue(
        "containsDuplicates.retainAll(subset) should return true",
        collection.retainAll(MinimalCollection.of(e2())));

            

Reported by PMD.

android/guava-tests/benchmark/com/google/common/base/EnumsBenchmark.java
10 issues
Avoid really long classes.
Design

Line: 27

              import java.util.List;

@SuppressWarnings("unused") // Nested enums used reflectively in setUp.
public class EnumsBenchmark {

  @Param({"Small", "Medium", "Large"})
  String enumSize;

  @Param({"0.2", "0.8"})

            

Reported by PMD.

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

Line: 30

              public class EnumsBenchmark {

  @Param({"Small", "Medium", "Large"})
  String enumSize;

  @Param({"0.2", "0.8"})
  float hitRate;

  private Class<? extends Enum> enumType;

            

Reported by PMD.

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

Line: 33

                String enumSize;

  @Param({"0.2", "0.8"})
  float hitRate;

  private Class<? extends Enum> enumType;
  private String[] sampleData;

  @BeforeExperiment

            

Reported by PMD.

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

Line: 35

                @Param({"0.2", "0.8"})
  float hitRate;

  private Class<? extends Enum> enumType;
  private String[] sampleData;

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

            

Reported by PMD.

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

Line: 36

                float hitRate;

  private Class<? extends Enum> enumType;
  private String[] sampleData;

  @BeforeExperiment
  @SuppressWarnings("unchecked")
  void setUp() throws ClassNotFoundException {
    Preconditions.checkArgument(hitRate >= 0 && hitRate <= 1, "hitRate must be in the range [0,1]");

            

Reported by PMD.

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

Line: 38

                private Class<? extends Enum> enumType;
  private String[] sampleData;

  @BeforeExperiment
  @SuppressWarnings("unchecked")
  void setUp() throws ClassNotFoundException {
    Preconditions.checkArgument(hitRate >= 0 && hitRate <= 1, "hitRate must be in the range [0,1]");

    enumType =

            

Reported by PMD.

This call to Collection.toArray() may be optimizable
Performance

Line: 64

                  sampleDataList.addAll(hits);
    sampleDataList.addAll(misses);
    Collections.shuffle(sampleDataList);
    sampleData = sampleDataList.toArray(new String[sampleDataList.size()]);
  }

  @Benchmark
  boolean getIfPresent(int repetitions) {
    boolean retVal = false;

            

Reported by PMD.

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

Line: 71

                boolean getIfPresent(int repetitions) {
    boolean retVal = false;
    for (int i = 0; i < repetitions; ++i) {
      retVal &= Enums.getIfPresent(enumType, sampleData[i & 255]).isPresent();
    }
    return retVal;
  }

  private enum SmallEnum {

            

Reported by PMD.

Avoid really long classes.
Design

Line: 185

                  X99
  }

  private enum LargeEnum {
    X0,
    X1,
    X2,
    X3,
    X4,

            

Reported by PMD.

Found 'DU'-anomaly for variable 'allConstants' (lines '47'-'65').
Error

Line: 47

                      (Class<? extends Enum>)
            Class.forName(EnumsBenchmark.class.getCanonicalName() + "$" + enumSize + "Enum");

    Enum<?>[] allConstants = enumType.getEnumConstants();
    List<String> hits = new ArrayList<>();
    for (int i = 0; i < hitRate * 256 / 3; ++i) {
      hits.add(allConstants[0].name());
      hits.add(allConstants[allConstants.length / 2].name());
      hits.add(allConstants[allConstants.length - 1].name());

            

Reported by PMD.