The following issues were found

android/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java
54 issues
JUnit tests should include assert() or fail()
Design

Line: 38

               */
@GwtCompatible(emulated = true)
public class FutureCallbackTest extends TestCase {
  public void testSameThreadSuccess() {
    SettableFuture<String> f = SettableFuture.create();
    MockCallback callback = new MockCallback("foo");
    addCallback(f, callback, directExecutor());
    f.set("foo");
  }

            

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

               */
@GwtCompatible(emulated = true)
public class FutureCallbackTest extends TestCase {
  public void testSameThreadSuccess() {
    SettableFuture<String> f = SettableFuture.create();
    MockCallback callback = new MockCallback("foo");
    addCallback(f, callback, directExecutor());
    f.set("foo");
  }

            

Reported by PMD.

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

Line: 40

              public class FutureCallbackTest extends TestCase {
  public void testSameThreadSuccess() {
    SettableFuture<String> f = SettableFuture.create();
    MockCallback callback = new MockCallback("foo");
    addCallback(f, callback, directExecutor());
    f.set("foo");
  }

  public void testExecutorSuccess() {

            

Reported by PMD.

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

Line: 42

                  SettableFuture<String> f = SettableFuture.create();
    MockCallback callback = new MockCallback("foo");
    addCallback(f, callback, directExecutor());
    f.set("foo");
  }

  public void testExecutorSuccess() {
    CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
    SettableFuture<String> f = SettableFuture.create();

            

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

                  f.set("foo");
  }

  public void testExecutorSuccess() {
    CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
    SettableFuture<String> f = SettableFuture.create();
    MockCallback callback = new MockCallback("foo");
    Futures.addCallback(f, callback, ex);
    f.set("foo");

            

Reported by PMD.

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

Line: 50

                  SettableFuture<String> f = SettableFuture.create();
    MockCallback callback = new MockCallback("foo");
    Futures.addCallback(f, callback, ex);
    f.set("foo");
    assertEquals(1, ex.runCount);
  }

  // Error cases
  public void testSameThreadExecutionException() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                  MockCallback callback = new MockCallback("foo");
    Futures.addCallback(f, callback, ex);
    f.set("foo");
    assertEquals(1, ex.runCount);
  }

  // Error cases
  public void testSameThreadExecutionException() {
    SettableFuture<String> f = SettableFuture.create();

            

Reported by PMD.

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

Line: 55

                }

  // Error cases
  public void testSameThreadExecutionException() {
    SettableFuture<String> f = SettableFuture.create();
    Exception e = new IllegalArgumentException("foo not found");
    MockCallback callback = new MockCallback(e);
    addCallback(f, callback, directExecutor());
    f.setException(e);

            

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

                }

  // Error cases
  public void testSameThreadExecutionException() {
    SettableFuture<String> f = SettableFuture.create();
    Exception e = new IllegalArgumentException("foo not found");
    MockCallback callback = new MockCallback(e);
    addCallback(f, callback, directExecutor());
    f.setException(e);

            

Reported by PMD.

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

Line: 60

                  Exception e = new IllegalArgumentException("foo not found");
    MockCallback callback = new MockCallback(e);
    addCallback(f, callback, directExecutor());
    f.setException(e);
  }

  public void testCancel() {
    SettableFuture<String> f = SettableFuture.create();
    FutureCallback<String> callback =

            

Reported by PMD.

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

Line: 36

               * @author Jige Yu
 */
@GwtCompatible(emulated = true)
public class FakeTickerTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicInstanceMethods(new FakeTicker());

            

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

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

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicInstanceMethods(new FakeTicker());
  }


            

Reported by PMD.

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

Line: 39

              public class FakeTickerTest extends TestCase {

  @GwtIncompatible // NullPointerTester
  public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicInstanceMethods(new FakeTicker());
  }

  @GwtIncompatible // java.time.Duration

            

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

                  tester.testAllPublicInstanceMethods(new FakeTicker());
  }

  @GwtIncompatible // java.time.Duration
  public void testAdvance() {
    FakeTicker ticker = new FakeTicker();
    assertEquals(0, ticker.read());
    assertSame(ticker, ticker.advance(10));
    assertEquals(10, ticker.read());

            

Reported by PMD.

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

Line: 45

                }

  @GwtIncompatible // java.time.Duration
  public void testAdvance() {
    FakeTicker ticker = new FakeTicker();
    assertEquals(0, ticker.read());
    assertSame(ticker, ticker.advance(10));
    assertEquals(10, ticker.read());
    ticker.advance(1, TimeUnit.MILLISECONDS);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

                @GwtIncompatible // java.time.Duration
  public void testAdvance() {
    FakeTicker ticker = new FakeTicker();
    assertEquals(0, ticker.read());
    assertSame(ticker, ticker.advance(10));
    assertEquals(10, ticker.read());
    ticker.advance(1, TimeUnit.MILLISECONDS);
    assertEquals(1000010L, ticker.read());
    ticker.advance(java.time.Duration.ofMillis(1));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 48

                public void testAdvance() {
    FakeTicker ticker = new FakeTicker();
    assertEquals(0, ticker.read());
    assertSame(ticker, ticker.advance(10));
    assertEquals(10, ticker.read());
    ticker.advance(1, TimeUnit.MILLISECONDS);
    assertEquals(1000010L, ticker.read());
    ticker.advance(java.time.Duration.ofMillis(1));
    assertEquals(2000010L, ticker.read());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                  FakeTicker ticker = new FakeTicker();
    assertEquals(0, ticker.read());
    assertSame(ticker, ticker.advance(10));
    assertEquals(10, ticker.read());
    ticker.advance(1, TimeUnit.MILLISECONDS);
    assertEquals(1000010L, ticker.read());
    ticker.advance(java.time.Duration.ofMillis(1));
    assertEquals(2000010L, ticker.read());
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                  assertSame(ticker, ticker.advance(10));
    assertEquals(10, ticker.read());
    ticker.advance(1, TimeUnit.MILLISECONDS);
    assertEquals(1000010L, ticker.read());
    ticker.advance(java.time.Duration.ofMillis(1));
    assertEquals(2000010L, ticker.read());
  }

  public void testAutoIncrementStep_returnsSameInstance() {

            

Reported by PMD.

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

Line: 52

                  assertEquals(10, ticker.read());
    ticker.advance(1, TimeUnit.MILLISECONDS);
    assertEquals(1000010L, ticker.read());
    ticker.advance(java.time.Duration.ofMillis(1));
    assertEquals(2000010L, ticker.read());
  }

  public void testAutoIncrementStep_returnsSameInstance() {
    FakeTicker ticker = new FakeTicker();

            

Reported by PMD.

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

Line: 46

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {

  private SortedMap<K, V> navigableMap;
  private Entry<K, V> a;
  private Entry<K, V> c;


            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {

  private SortedMap<K, V> navigableMap;
  private Entry<K, V> a;
  private Entry<K, V> c;

  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 49

              public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {

  private SortedMap<K, V> navigableMap;
  private Entry<K, V> a;
  private Entry<K, V> c;

  @Override
  public void setUp() throws Exception {
    super.setUp();

            

Reported by PMD.

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

Line: 50

              
  private SortedMap<K, V> navigableMap;
  private Entry<K, V> a;
  private Entry<K, V> c;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    navigableMap = (SortedMap<K, V>) getMap();

            

Reported by PMD.

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

Line: 52

                private Entry<K, V> a;
  private Entry<K, V> c;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    navigableMap = (SortedMap<K, V>) getMap();
    List<Entry<K, V>> entries =
        Helpers.copyToList(

            

Reported by PMD.

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

Line: 58

                  navigableMap = (SortedMap<K, V>) getMap();
    List<Entry<K, V>> entries =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {

            

Reported by PMD.

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

Line: 59

                  List<Entry<K, V>> entries =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {
      a = entries.get(0);

            

Reported by PMD.

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

Line: 59

                  List<Entry<K, V>> entries =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {
      a = entries.get(0);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 63

                  Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {
      a = entries.get(0);
      if (entries.size() >= 3) {
        c = entries.get(2);
      }
    }

            

Reported by PMD.

Substitute calls to size() == 0 (or size() != 0, size() > 0, size() < 1) with calls to isEmpty()
Design

Line: 63

                  Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {
      a = entries.get(0);
      if (entries.size() >= 3) {
        c = entries.get(2);
      }
    }

            

Reported by PMD.

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

Line: 45

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class EnumMultisetTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(

            

Reported by PMD.

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

Line: 47

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

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(enumMultisetGenerator())
            .withFeatures(

            

Reported by PMD.

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

Line: 51

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(enumMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SUPPORTS_ITERATOR_REMOVE,

            

Reported by PMD.

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

Line: 51

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(enumMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SUPPORTS_ITERATOR_REMOVE,

            

Reported by PMD.

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

Line: 51

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(enumMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SUPPORTS_ITERATOR_REMOVE,

            

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

                  FEMALE
  }

  public void testClassCreate() {
    Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));

            

Reported by PMD.

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

Line: 89

                  FEMALE
  }

  public void testClassCreate() {
    Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));

            

Reported by PMD.

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

Line: 91

              
  public void testClassCreate() {
    Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));
    assertEquals(1, ms.count(Color.YELLOW));
    assertEquals(2, ms.count(Color.RED));

            

Reported by PMD.

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

Line: 92

                public void testClassCreate() {
    Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));
    assertEquals(1, ms.count(Color.YELLOW));
    assertEquals(2, ms.count(Color.RED));
  }

            

Reported by PMD.

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

Line: 93

                  Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));
    assertEquals(1, ms.count(Color.YELLOW));
    assertEquals(2, ms.count(Color.RED));
  }


            

Reported by PMD.

guava-tests/test/com/google/common/graph/GraphPropertiesTest.java
53 issues
This class has too many methods, consider refactoring it.
Design

Line: 31

              /** Tests for {@link Graphs#hasCycle(Graph)} and {@link Graphs#hasCycle(Network)}. */
// TODO(user): Consider moving this to GraphsTest.
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
  ImmutableList<MutableGraph<Integer>> graphsToTest;
  Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;

            

Reported by PMD.

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

Line: 32

              // TODO(user): Consider moving this to GraphsTest.
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
  ImmutableList<MutableGraph<Integer>> graphsToTest;
  Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;

            

Reported by PMD.

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

Line: 33

              @RunWith(JUnit4.class)
public class GraphPropertiesTest {
  ImmutableList<MutableGraph<Integer>> graphsToTest;
  Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;

            

Reported by PMD.

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

Line: 34

              public class GraphPropertiesTest {
  ImmutableList<MutableGraph<Integer>> graphsToTest;
  Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;


            

Reported by PMD.

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

Line: 36

                Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;

  @Before
  public void init() {

            

Reported by PMD.

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

Line: 37

                Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;

  @Before
  public void init() {
    MutableGraph<Integer> mutableDirectedGraph =

            

Reported by PMD.

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

Line: 38

              
  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;

  @Before
  public void init() {
    MutableGraph<Integer> mutableDirectedGraph =
        GraphBuilder.directed().allowsSelfLoops(true).build();

            

Reported by PMD.

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

Line: 43

                @Before
  public void init() {
    MutableGraph<Integer> mutableDirectedGraph =
        GraphBuilder.directed().allowsSelfLoops(true).build();
    MutableGraph<Integer> mutableUndirectedGraph =
        GraphBuilder.undirected().allowsSelfLoops(true).build();
    graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
    directedGraph = mutableDirectedGraph;
    undirectedGraph = mutableUndirectedGraph;

            

Reported by PMD.

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

Line: 43

                @Before
  public void init() {
    MutableGraph<Integer> mutableDirectedGraph =
        GraphBuilder.directed().allowsSelfLoops(true).build();
    MutableGraph<Integer> mutableUndirectedGraph =
        GraphBuilder.undirected().allowsSelfLoops(true).build();
    graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
    directedGraph = mutableDirectedGraph;
    undirectedGraph = mutableUndirectedGraph;

            

Reported by PMD.

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

Line: 45

                  MutableGraph<Integer> mutableDirectedGraph =
        GraphBuilder.directed().allowsSelfLoops(true).build();
    MutableGraph<Integer> mutableUndirectedGraph =
        GraphBuilder.undirected().allowsSelfLoops(true).build();
    graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
    directedGraph = mutableDirectedGraph;
    undirectedGraph = mutableUndirectedGraph;

    MutableNetwork<Integer, String> mutableDirectedNetwork =

            

Reported by PMD.

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

Line: 45

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class EnumMultisetTest extends TestCase {

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(

            

Reported by PMD.

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

Line: 47

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

  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(enumMultisetGenerator())
            .withFeatures(

            

Reported by PMD.

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

Line: 51

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(enumMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SUPPORTS_ITERATOR_REMOVE,

            

Reported by PMD.

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

Line: 51

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(enumMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SUPPORTS_ITERATOR_REMOVE,

            

Reported by PMD.

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

Line: 51

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(enumMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SUPPORTS_ITERATOR_REMOVE,

            

Reported by PMD.

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

Line: 89

                  FEMALE
  }

  public void testClassCreate() {
    Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));

            

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

                  FEMALE
  }

  public void testClassCreate() {
    Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));

            

Reported by PMD.

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

Line: 91

              
  public void testClassCreate() {
    Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));
    assertEquals(1, ms.count(Color.YELLOW));
    assertEquals(2, ms.count(Color.RED));

            

Reported by PMD.

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

Line: 92

                public void testClassCreate() {
    Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));
    assertEquals(1, ms.count(Color.YELLOW));
    assertEquals(2, ms.count(Color.RED));
  }

            

Reported by PMD.

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

Line: 93

                  Multiset<Color> ms = EnumMultiset.create(Color.class);
    ms.add(Color.RED);
    ms.add(Color.YELLOW);
    ms.add(Color.RED);
    assertEquals(0, ms.count(Color.BLUE));
    assertEquals(1, ms.count(Color.YELLOW));
    assertEquals(2, ms.count(Color.RED));
  }


            

Reported by PMD.

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

Line: 46

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {

  private SortedMap<K, V> navigableMap;
  private Entry<K, V> a;
  private Entry<K, V> c;


            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {

  private SortedMap<K, V> navigableMap;
  private Entry<K, V> a;
  private Entry<K, V> c;

  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 49

              public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {

  private SortedMap<K, V> navigableMap;
  private Entry<K, V> a;
  private Entry<K, V> c;

  @Override
  public void setUp() throws Exception {
    super.setUp();

            

Reported by PMD.

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

Line: 50

              
  private SortedMap<K, V> navigableMap;
  private Entry<K, V> a;
  private Entry<K, V> c;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    navigableMap = (SortedMap<K, V>) getMap();

            

Reported by PMD.

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

Line: 52

                private Entry<K, V> a;
  private Entry<K, V> c;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    navigableMap = (SortedMap<K, V>) getMap();
    List<Entry<K, V>> entries =
        Helpers.copyToList(

            

Reported by PMD.

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

Line: 58

                  navigableMap = (SortedMap<K, V>) getMap();
    List<Entry<K, V>> entries =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {

            

Reported by PMD.

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

Line: 59

                  List<Entry<K, V>> entries =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {
      a = entries.get(0);

            

Reported by PMD.

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

Line: 59

                  List<Entry<K, V>> entries =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {
      a = entries.get(0);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 63

                  Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {
      a = entries.get(0);
      if (entries.size() >= 3) {
        c = entries.get(2);
      }
    }

            

Reported by PMD.

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

Line: 63

                  Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));

    // some tests assume SEVERAL == 3
    if (entries.size() >= 1) {
      a = entries.get(0);
      if (entries.size() >= 3) {
        c = entries.get(2);
      }
    }

            

Reported by PMD.

guava/src/com/google/common/collect/ImmutableMap.java
53 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.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;

            

Reported by PMD.

Possible God Class (WMC=73, ATFD=7, TCC=0.676%)
Design

Line: 69

              @GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {

  /**
   * Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
   * and values are the result of applying the provided mapping functions to the input elements.
   * Entries appear in the result {@code ImmutableMap} in encounter order.

            

Reported by PMD.

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

Line: 69

              @GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {

  /**
   * Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
   * and values are the result of applying the provided mapping functions to the input elements.
   * Entries appear in the result {@code ImmutableMap} in encounter order.

            

Reported by PMD.

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

Line: 115

                 *
   * <p><b>Performance note:</b> the instance returned is a singleton.
   */
  @SuppressWarnings("unchecked")
  public static <K, V> ImmutableMap<K, V> of() {
    return (ImmutableMap<K, V>) RegularImmutableMap.EMPTY;
  }

  /**

            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 162

                 *
   * @throws IllegalArgumentException if duplicate keys are provided
   */
  public static <K, V> ImmutableMap<K, V> of(
      K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
    return RegularImmutableMap.fromEntries(
        entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
  }


            

Reported by PMD.

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

Line: 387

                        entries = Arrays.copyOf(entries, size);
        }
        Arrays.sort(
            entries, 0, size, Ordering.from(valueComparator).onResultOf(Maps.<V>valueFunction()));
      }
      switch (size) {
        case 0:
          return of();
        case 1:

            

Reported by PMD.

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

Line: 395

                      case 1:
          // requireNonNull is safe because the first `size` elements have been filled in.
          Entry<K, V> onlyEntry = requireNonNull(entries[0]);
          return of(onlyEntry.getKey(), onlyEntry.getValue());
        default:
          entriesUsed = true;
          return RegularImmutableMap.fromEntryArray(size, entries);
      }
    }

            

Reported by PMD.

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

Line: 395

                      case 1:
          // requireNonNull is safe because the first `size` elements have been filled in.
          Entry<K, V> onlyEntry = requireNonNull(entries[0]);
          return of(onlyEntry.getKey(), onlyEntry.getValue());
        default:
          entriesUsed = true;
          return RegularImmutableMap.fromEntryArray(size, entries);
      }
    }

            

Reported by PMD.

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

Line: 412

                      case 1:
          // requireNonNull is safe because the first `size` elements have been filled in.
          Entry<K, V> onlyEntry = requireNonNull(entries[0]);
          return of(onlyEntry.getKey(), onlyEntry.getValue());
        default:
          entriesUsed = true;
          return JdkBackedImmutableMap.create(size, entries);
      }
    }

            

Reported by PMD.

android/guava-tests/test/com/google/common/graph/GraphPropertiesTest.java
53 issues
This class has too many methods, consider refactoring it.
Design

Line: 31

              /** Tests for {@link Graphs#hasCycle(Graph)} and {@link Graphs#hasCycle(Network)}. */
// TODO(user): Consider moving this to GraphsTest.
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
  ImmutableList<MutableGraph<Integer>> graphsToTest;
  Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;

            

Reported by PMD.

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

Line: 32

              // TODO(user): Consider moving this to GraphsTest.
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
  ImmutableList<MutableGraph<Integer>> graphsToTest;
  Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;

            

Reported by PMD.

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

Line: 33

              @RunWith(JUnit4.class)
public class GraphPropertiesTest {
  ImmutableList<MutableGraph<Integer>> graphsToTest;
  Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;

            

Reported by PMD.

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

Line: 34

              public class GraphPropertiesTest {
  ImmutableList<MutableGraph<Integer>> graphsToTest;
  Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;


            

Reported by PMD.

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

Line: 36

                Graph<Integer> directedGraph;
  Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;

  @Before
  public void init() {

            

Reported by PMD.

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

Line: 37

                Graph<Integer> undirectedGraph;

  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;

  @Before
  public void init() {
    MutableGraph<Integer> mutableDirectedGraph =

            

Reported by PMD.

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

Line: 38

              
  ImmutableList<MutableNetwork<Integer, String>> networksToTest;
  Network<Integer, String> directedNetwork;
  Network<Integer, String> undirectedNetwork;

  @Before
  public void init() {
    MutableGraph<Integer> mutableDirectedGraph =
        GraphBuilder.directed().allowsSelfLoops(true).build();

            

Reported by PMD.

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

Line: 43

                @Before
  public void init() {
    MutableGraph<Integer> mutableDirectedGraph =
        GraphBuilder.directed().allowsSelfLoops(true).build();
    MutableGraph<Integer> mutableUndirectedGraph =
        GraphBuilder.undirected().allowsSelfLoops(true).build();
    graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
    directedGraph = mutableDirectedGraph;
    undirectedGraph = mutableUndirectedGraph;

            

Reported by PMD.

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

Line: 43

                @Before
  public void init() {
    MutableGraph<Integer> mutableDirectedGraph =
        GraphBuilder.directed().allowsSelfLoops(true).build();
    MutableGraph<Integer> mutableUndirectedGraph =
        GraphBuilder.undirected().allowsSelfLoops(true).build();
    graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
    directedGraph = mutableDirectedGraph;
    undirectedGraph = mutableUndirectedGraph;

            

Reported by PMD.

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

Line: 45

                  MutableGraph<Integer> mutableDirectedGraph =
        GraphBuilder.directed().allowsSelfLoops(true).build();
    MutableGraph<Integer> mutableUndirectedGraph =
        GraphBuilder.undirected().allowsSelfLoops(true).build();
    graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
    directedGraph = mutableDirectedGraph;
    undirectedGraph = mutableUndirectedGraph;

    MutableNetwork<Integer, String> mutableDirectedNetwork =

            

Reported by PMD.

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

Line: 48

              @GwtCompatible
@ElementTypesAreNonnullByDefault
class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
  final Multimap<K, V> unfiltered;
  final Predicate<? super Entry<K, V>> predicate;

  FilteredEntryMultimap(Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
    this.unfiltered = checkNotNull(unfiltered);

            

Reported by PMD.

Field unfiltered has the same name as a method
Error

Line: 49

              @ElementTypesAreNonnullByDefault
class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
  final Multimap<K, V> unfiltered;
  final Predicate<? super Entry<K, V>> predicate;

  FilteredEntryMultimap(Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
    this.unfiltered = checkNotNull(unfiltered);
    this.predicate = checkNotNull(predicate);

            

Reported by PMD.

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

Line: 49

              @ElementTypesAreNonnullByDefault
class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
  final Multimap<K, V> unfiltered;
  final Predicate<? super Entry<K, V>> predicate;

  FilteredEntryMultimap(Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
    this.unfiltered = checkNotNull(unfiltered);
    this.predicate = checkNotNull(predicate);

            

Reported by PMD.

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

Line: 50

              class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
    extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
  final Multimap<K, V> unfiltered;
  final Predicate<? super Entry<K, V>> predicate;

  FilteredEntryMultimap(Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
    this.unfiltered = checkNotNull(unfiltered);
    this.predicate = checkNotNull(predicate);
  }

            

Reported by PMD.

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

Line: 69

              
  @Override
  public int size() {
    return entries().size();
  }

  private boolean satisfies(@ParametricNullness K key, @ParametricNullness V value) {
    return predicate.apply(Maps.immutableEntry(key, value));
  }

            

Reported by PMD.

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

Line: 77

                }

  final class ValuePredicate implements Predicate<V> {
    @ParametricNullness private final K key;

    ValuePredicate(@ParametricNullness K key) {
      this.key = key;
    }


            

Reported by PMD.

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

Line: 100

              
  @Override
  public boolean containsKey(@CheckForNull Object key) {
    return asMap().get(key) != null;
  }

  @Override
  public Collection<V> removeAll(@CheckForNull Object key) {
    return MoreObjects.firstNonNull(asMap().remove(key), unmodifiableEmptyCollection());

            

Reported by PMD.

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

Line: 105

              
  @Override
  public Collection<V> removeAll(@CheckForNull Object key) {
    return MoreObjects.firstNonNull(asMap().remove(key), unmodifiableEmptyCollection());
  }

  Collection<V> unmodifiableEmptyCollection() {
    // These return false, rather than throwing a UOE, on remove calls.
    return (unfiltered instanceof SetMultimap)

            

Reported by PMD.

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

Line: 117

              
  @Override
  public void clear() {
    entries().clear();
  }

  @Override
  public Collection<V> get(@ParametricNullness final K key) {
    return filterCollection(unfiltered.get(key), new ValuePredicate(key));

            

Reported by PMD.

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

Line: 147

              
  @Override
  Set<K> createKeySet() {
    return asMap().keySet();
  }

  boolean removeEntriesIf(Predicate<? super Entry<K, Collection<V>>> predicate) {
    Iterator<Entry<K, Collection<V>>> entryIterator = unfiltered.asMap().entrySet().iterator();
    boolean changed = false;

            

Reported by PMD.