The following issues were found

android/guava-tests/test/com/google/common/base/SuppliersTest.java
154 issues
Avoid throwing null pointer exceptions.
Design

Line: 63

                static class ThrowingSupplier implements Supplier<Integer> {
    @Override
    public Integer get() {
      throw new NullPointerException();
    }
  }

  static class SerializableCountingSupplier extends CountingSupplier implements Serializable {
    private static final long serialVersionUID = 0L;

            

Reported by PMD.

The class 'SuppliersTest' has a Modified Cyclomatic Complexity of 2 (Highest = 14).
Design

Line: 43

               * @author Harry Heymann
 */
@GwtCompatible(emulated = true)
public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override

            

Reported by PMD.

The class 'SuppliersTest' has a Standard Cyclomatic Complexity of 2 (Highest = 14).
Design

Line: 43

               * @author Harry Heymann
 */
@GwtCompatible(emulated = true)
public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override

            

Reported by PMD.

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

Line: 43

               * @author Harry Heymann
 */
@GwtCompatible(emulated = true)
public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override

            

Reported by PMD.

Avoid using redundant field initializer for 'calls'
Performance

Line: 46

              public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override
    public Integer get() {
      calls++;
      return calls * 10;

            

Reported by PMD.

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

Line: 46

              public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override
    public Integer get() {
      calls++;
      return calls * 10;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 77

              
  static void checkMemoize(CountingSupplier countingSupplier, Supplier<Integer> memoizedSupplier) {
    // the underlying supplier hasn't executed yet
    assertEquals(0, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

    // now it has
    assertEquals(1, countingSupplier.calls);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 79

                  // the underlying supplier hasn't executed yet
    assertEquals(0, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

    // now it has
    assertEquals(1, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 82

                  assertEquals(10, (int) memoizedSupplier.get());

    // now it has
    assertEquals(1, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

    // it still should only have executed once due to memoization
    assertEquals(1, countingSupplier.calls);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 84

                  // now it has
    assertEquals(1, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

    // it still should only have executed once due to memoization
    assertEquals(1, countingSupplier.calls);
  }


            

Reported by PMD.

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

Line: 38

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

  /**
   * Compare strings lengths, and if the lengths are equal compare the strings. A {@code null} is
   * less than any non-null value.
   */

            

Reported by PMD.

Use equals() to compare strings instead of '==' or '!='
Error

Line: 49

              
    @Override
    public int compare(String first, String second) {
      if (first == second) {
        return 0;
      } else if (first == null) {
        return -1;
      } else if (second == null) {
        return 1;

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 49

              
    @Override
    public int compare(String first, String second) {
      if (first == second) {
        return 0;
      } else if (first == null) {
        return -1;
      } else if (second == null) {
        return 1;

            

Reported by PMD.

Use equals() to compare strings instead of '==' or '!='
Error

Line: 55

                      return -1;
      } else if (second == null) {
        return 1;
      } else if (first.length() != second.length()) {
        return first.length() - second.length();
      } else {
        return first.compareTo(second);
      }
    }

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 55

                      return -1;
      } else if (second == null) {
        return 1;
      } else if (first.length() != second.length()) {
        return first.length() - second.length();
      } else {
        return first.compareTo(second);
      }
    }

            

Reported by PMD.

The String literal 'google' appears 17 times in this file; the first occurrence is on line 75
Error

Line: 75

                private TreeMultimap<String, Integer> createPopulate() {
    TreeMultimap<String, Integer> multimap =
        TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR);
    multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);

            

Reported by PMD.

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

Line: 75

                private TreeMultimap<String, Integer> createPopulate() {
    TreeMultimap<String, Integer> multimap =
        TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR);
    multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);

            

Reported by PMD.

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

Line: 76

                  TreeMultimap<String, Integer> multimap =
        TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR);
    multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);
    multimap.put("tree", null);

            

Reported by PMD.

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

Line: 77

                      TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR);
    multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);
    multimap.put("tree", null);
    return multimap;

            

Reported by PMD.

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

Line: 78

                  multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);
    multimap.put("tree", null);
    return multimap;
  }

            

Reported by PMD.

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

Line: 38

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

  /**
   * Compare strings lengths, and if the lengths are equal compare the strings. A {@code null} is
   * less than any non-null value.
   */

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 49

              
    @Override
    public int compare(String first, String second) {
      if (first == second) {
        return 0;
      } else if (first == null) {
        return -1;
      } else if (second == null) {
        return 1;

            

Reported by PMD.

Use equals() to compare strings instead of '==' or '!='
Error

Line: 49

              
    @Override
    public int compare(String first, String second) {
      if (first == second) {
        return 0;
      } else if (first == null) {
        return -1;
      } else if (second == null) {
        return 1;

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 55

                      return -1;
      } else if (second == null) {
        return 1;
      } else if (first.length() != second.length()) {
        return first.length() - second.length();
      } else {
        return first.compareTo(second);
      }
    }

            

Reported by PMD.

Use equals() to compare strings instead of '==' or '!='
Error

Line: 55

                      return -1;
      } else if (second == null) {
        return 1;
      } else if (first.length() != second.length()) {
        return first.length() - second.length();
      } else {
        return first.compareTo(second);
      }
    }

            

Reported by PMD.

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

Line: 75

                private TreeMultimap<String, Integer> createPopulate() {
    TreeMultimap<String, Integer> multimap =
        TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR);
    multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);

            

Reported by PMD.

The String literal 'google' appears 17 times in this file; the first occurrence is on line 75
Error

Line: 75

                private TreeMultimap<String, Integer> createPopulate() {
    TreeMultimap<String, Integer> multimap =
        TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR);
    multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);

            

Reported by PMD.

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

Line: 76

                  TreeMultimap<String, Integer> multimap =
        TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR);
    multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);
    multimap.put("tree", null);

            

Reported by PMD.

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

Line: 77

                      TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR);
    multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);
    multimap.put("tree", null);
    return multimap;

            

Reported by PMD.

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

Line: 78

                  multimap.put("google", 2);
    multimap.put("google", 6);
    multimap.put(null, 3);
    multimap.put(null, 1);
    multimap.put(null, 7);
    multimap.put("tree", 0);
    multimap.put("tree", null);
    return multimap;
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/StringsTest.java
152 issues
This class has too many methods, consider refactoring it.
Design

Line: 32

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }

            

Reported by PMD.

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

Line: 33

               */
@GwtCompatible(emulated = true)
public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }


            

Reported by PMD.

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

Line: 33

               */
@GwtCompatible(emulated = true)
public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

              @GwtCompatible(emulated = true)
public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

              public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

                public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));

            

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

                  assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));
    assertEquals("a", Strings.emptyToNull("a"));
  }


            

Reported by PMD.

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

Line: 39

                  assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));
    assertEquals("a", Strings.emptyToNull("a"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));
    assertEquals("a", Strings.emptyToNull("a"));
  }

  public void testIsNullOrEmpty() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

              
  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));
    assertEquals("a", Strings.emptyToNull("a"));
  }

  public void testIsNullOrEmpty() {
    assertTrue(Strings.isNullOrEmpty(null));

            

Reported by PMD.

guava-tests/test/com/google/common/base/StringsTest.java
152 issues
This class has too many methods, consider refactoring it.
Design

Line: 32

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }

            

Reported by PMD.

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

Line: 33

               */
@GwtCompatible(emulated = true)
public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }


            

Reported by PMD.

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

Line: 33

               */
@GwtCompatible(emulated = true)
public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

              @GwtCompatible(emulated = true)
public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

              public class StringsTest extends TestCase {
  public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

                public void testNullToEmpty() {
    assertEquals("", Strings.nullToEmpty(null));
    assertEquals("", Strings.nullToEmpty(""));
    assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));

            

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

                  assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));
    assertEquals("a", Strings.emptyToNull("a"));
  }


            

Reported by PMD.

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

Line: 39

                  assertEquals("a", Strings.nullToEmpty("a"));
  }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));
    assertEquals("a", Strings.emptyToNull("a"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                }

  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));
    assertEquals("a", Strings.emptyToNull("a"));
  }

  public void testIsNullOrEmpty() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

              
  public void testEmptyToNull() {
    assertNull(Strings.emptyToNull(null));
    assertNull(Strings.emptyToNull(""));
    assertEquals("a", Strings.emptyToNull("a"));
  }

  public void testIsNullOrEmpty() {
    assertTrue(Strings.isNullOrEmpty(null));

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java
151 issues
This class has too many methods, consider refactoring it.
Design

Line: 42

              import junit.framework.TestCase;

/** Tests for {@link ExecutionSequencer} */
public class ExecutionSequencerTest extends TestCase {

  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;

            

Reported by PMD.

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

Line: 42

              import junit.framework.TestCase;

/** Tests for {@link ExecutionSequencer} */
public class ExecutionSequencerTest extends TestCase {

  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;

            

Reported by PMD.

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

Line: 42

              import junit.framework.TestCase;

/** Tests for {@link ExecutionSequencer} */
public class ExecutionSequencerTest extends TestCase {

  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;

            

Reported by PMD.

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

Line: 44

              /** Tests for {@link ExecutionSequencer} */
public class ExecutionSequencerTest extends TestCase {

  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;


            

Reported by PMD.

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

Line: 46

              
  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;

  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 47

                ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;

  @Override
  public void setUp() throws Exception {
    executor = Executors.newCachedThreadPool();

            

Reported by PMD.

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

Line: 48

              
  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;

  @Override
  public void setUp() throws Exception {
    executor = Executors.newCachedThreadPool();
    serializer = ExecutionSequencer.create();

            

Reported by PMD.

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

Line: 50

                private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;

  @Override
  public void setUp() throws Exception {
    executor = Executors.newCachedThreadPool();
    serializer = ExecutionSequencer.create();
    firstFuture = SettableFuture.create();
    firstCallable = new TestCallable(firstFuture);

            

Reported by PMD.

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

Line: 58

                  firstCallable = new TestCallable(firstFuture);
  }

  @Override
  public void tearDown() throws Exception {
    executor.shutdown();
  }

  public void testCallableStartsAfterFirstFutureCompletes() {

            

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

                  executor.shutdown();
  }

  public void testCallableStartsAfterFirstFutureCompletes() {
    @SuppressWarnings({"unused", "nullness"})
    Future<?> possiblyIgnoredError = serializer.submitAsync(firstCallable, directExecutor());
    TestCallable secondCallable = new TestCallable(Futures.<Void>immediateFuture(null));
    @SuppressWarnings({"unused", "nullness"})
    Future<?> possiblyIgnoredError1 = serializer.submitAsync(secondCallable, directExecutor());

            

Reported by PMD.

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

Line: 51

              @SuppressWarnings("unchecked") // too many "unchecked generic array creations"
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListSubListTester<E> extends AbstractListTester<E> {
  public void testSubList_startNegative() {
    try {
      getList().subList(-1, 0);
      fail("subList(-1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {

            

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

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListSubListTester<E> extends AbstractListTester<E> {
  public void testSubList_startNegative() {
    try {
      getList().subList(-1, 0);
      fail("subList(-1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {
    }

            

Reported by PMD.

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

Line: 54

              public class ListSubListTester<E> extends AbstractListTester<E> {
  public void testSubList_startNegative() {
    try {
      getList().subList(-1, 0);
      fail("subList(-1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {
    }
  }


            

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

                  }
  }

  public void testSubList_endTooLarge() {
    try {
      getList().subList(0, getNumElements() + 1);
      fail("subList(0, size + 1) should throw");
    } catch (IndexOutOfBoundsException expected) {
    }

            

Reported by PMD.

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

Line: 62

              
  public void testSubList_endTooLarge() {
    try {
      getList().subList(0, getNumElements() + 1);
      fail("subList(0, size + 1) should throw");
    } catch (IndexOutOfBoundsException expected) {
    }
  }


            

Reported by PMD.

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

Line: 68

                  }
  }

  public void testSubList_startGreaterThanEnd() {
    try {
      getList().subList(1, 0);
      fail("subList(1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {
    } catch (IllegalArgumentException expected) {

            

Reported by PMD.

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

Line: 70

              
  public void testSubList_startGreaterThanEnd() {
    try {
      getList().subList(1, 0);
      fail("subList(1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {
    } catch (IllegalArgumentException expected) {
      /*
       * The subList() docs claim that this should be an

            

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

                  }
  }

  public void testSubList_empty() {
    assertEquals("subList(0, 0) should be empty", emptyList(), getList().subList(0, 0));
  }

  public void testSubList_entireList() {
    assertEquals(

            

Reported by PMD.

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

Line: 84

                }

  public void testSubList_empty() {
    assertEquals("subList(0, 0) should be empty", emptyList(), getList().subList(0, 0));
  }

  public void testSubList_entireList() {
    assertEquals(
        "subList(0, size) should be equal to the original list",

            

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

                  assertEquals("subList(0, 0) should be empty", emptyList(), getList().subList(0, 0));
  }

  public void testSubList_entireList() {
    assertEquals(
        "subList(0, size) should be equal to the original list",
        getList(),
        getList().subList(0, getNumElements()));
  }

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java
151 issues
This class has too many methods, consider refactoring it.
Design

Line: 42

              import junit.framework.TestCase;

/** Tests for {@link ExecutionSequencer} */
public class ExecutionSequencerTest extends TestCase {

  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;

            

Reported by PMD.

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

Line: 42

              import junit.framework.TestCase;

/** Tests for {@link ExecutionSequencer} */
public class ExecutionSequencerTest extends TestCase {

  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;

            

Reported by PMD.

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

Line: 42

              import junit.framework.TestCase;

/** Tests for {@link ExecutionSequencer} */
public class ExecutionSequencerTest extends TestCase {

  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;

            

Reported by PMD.

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

Line: 44

              /** Tests for {@link ExecutionSequencer} */
public class ExecutionSequencerTest extends TestCase {

  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;


            

Reported by PMD.

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

Line: 46

              
  ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;

  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 47

                ExecutorService executor;

  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;

  @Override
  public void setUp() throws Exception {
    executor = Executors.newCachedThreadPool();

            

Reported by PMD.

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

Line: 48

              
  private ExecutionSequencer serializer;
  private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;

  @Override
  public void setUp() throws Exception {
    executor = Executors.newCachedThreadPool();
    serializer = ExecutionSequencer.create();

            

Reported by PMD.

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

Line: 50

                private SettableFuture<Void> firstFuture;
  private TestCallable firstCallable;

  @Override
  public void setUp() throws Exception {
    executor = Executors.newCachedThreadPool();
    serializer = ExecutionSequencer.create();
    firstFuture = SettableFuture.create();
    firstCallable = new TestCallable(firstFuture);

            

Reported by PMD.

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

Line: 58

                  firstCallable = new TestCallable(firstFuture);
  }

  @Override
  public void tearDown() throws Exception {
    executor.shutdown();
  }

  public void testCallableStartsAfterFirstFutureCompletes() {

            

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

                  executor.shutdown();
  }

  public void testCallableStartsAfterFirstFutureCompletes() {
    @SuppressWarnings({"unused", "nullness"})
    Future<?> possiblyIgnoredError = serializer.submitAsync(firstCallable, directExecutor());
    TestCallable secondCallable = new TestCallable(Futures.<Void>immediateFuture(null));
    @SuppressWarnings({"unused", "nullness"})
    Future<?> possiblyIgnoredError1 = serializer.submitAsync(secondCallable, directExecutor());

            

Reported by PMD.

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

Line: 51

              @SuppressWarnings("unchecked") // too many "unchecked generic array creations"
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListSubListTester<E> extends AbstractListTester<E> {
  public void testSubList_startNegative() {
    try {
      getList().subList(-1, 0);
      fail("subList(-1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {

            

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

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListSubListTester<E> extends AbstractListTester<E> {
  public void testSubList_startNegative() {
    try {
      getList().subList(-1, 0);
      fail("subList(-1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {
    }

            

Reported by PMD.

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

Line: 54

              public class ListSubListTester<E> extends AbstractListTester<E> {
  public void testSubList_startNegative() {
    try {
      getList().subList(-1, 0);
      fail("subList(-1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {
    }
  }


            

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

                  }
  }

  public void testSubList_endTooLarge() {
    try {
      getList().subList(0, getNumElements() + 1);
      fail("subList(0, size + 1) should throw");
    } catch (IndexOutOfBoundsException expected) {
    }

            

Reported by PMD.

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

Line: 62

              
  public void testSubList_endTooLarge() {
    try {
      getList().subList(0, getNumElements() + 1);
      fail("subList(0, size + 1) should throw");
    } catch (IndexOutOfBoundsException expected) {
    }
  }


            

Reported by PMD.

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

Line: 68

                  }
  }

  public void testSubList_startGreaterThanEnd() {
    try {
      getList().subList(1, 0);
      fail("subList(1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {
    } catch (IllegalArgumentException expected) {

            

Reported by PMD.

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

Line: 70

              
  public void testSubList_startGreaterThanEnd() {
    try {
      getList().subList(1, 0);
      fail("subList(1, 0) should throw");
    } catch (IndexOutOfBoundsException expected) {
    } catch (IllegalArgumentException expected) {
      /*
       * The subList() docs claim that this should be an

            

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

                  }
  }

  public void testSubList_empty() {
    assertEquals("subList(0, 0) should be empty", emptyList(), getList().subList(0, 0));
  }

  public void testSubList_entireList() {
    assertEquals(

            

Reported by PMD.

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

Line: 84

                }

  public void testSubList_empty() {
    assertEquals("subList(0, 0) should be empty", emptyList(), getList().subList(0, 0));
  }

  public void testSubList_entireList() {
    assertEquals(
        "subList(0, size) should be equal to the original list",

            

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

                  assertEquals("subList(0, 0) should be empty", emptyList(), getList().subList(0, 0));
  }

  public void testSubList_entireList() {
    assertEquals(
        "subList(0, size) should be equal to the original list",
        getList(),
        getList().subList(0, getNumElements()));
  }

            

Reported by PMD.

guava-tests/test/com/google/common/primitives/BytesTest.java
150 issues
Avoid reassigning parameters such as 'input'
Design

Line: 250

                  testReverse(new byte[] {-1, 1, -2, 2}, new byte[] {2, -2, 1, -1});
  }

  private static void testReverse(byte[] input, byte[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    Bytes.reverse(input);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'input'
Design

Line: 256

                  assertTrue(Arrays.equals(expectedOutput, input));
  }

  private static void testReverse(byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) {
    input = Arrays.copyOf(input, input.length);
    Bytes.reverse(input, fromIndex, toIndex);
    assertTrue(Arrays.equals(expectedOutput, input));
  }


            

Reported by PMD.

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

Line: 35

               * @author Kevin Bourrillion
 */
@GwtCompatible(emulated = true)
public class BytesTest extends TestCase {
  private static final byte[] EMPTY = {};
  private static final byte[] ARRAY1 = {(byte) 1};
  private static final byte[] ARRAY234 = {(byte) 2, (byte) 3, (byte) 4};

  private static final byte[] VALUES = {Byte.MIN_VALUE, -1, 0, 1, Byte.MAX_VALUE};

            

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

              
  private static final byte[] VALUES = {Byte.MIN_VALUE, -1, 0, 1, Byte.MAX_VALUE};

  public void testHashCode() {
    for (byte value : VALUES) {
      assertEquals(((Byte) value).hashCode(), Bytes.hashCode(value));
    }
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

              
  public void testHashCode() {
    for (byte value : VALUES) {
      assertEquals(((Byte) value).hashCode(), Bytes.hashCode(value));
    }
  }

  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));

            

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

                  }
  }

  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));

            

Reported by PMD.

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

Line: 48

                  }
  }

  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                }

  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));
    assertTrue(Bytes.contains(ARRAY234, (byte) 3));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 50

              
  public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));
    assertTrue(Bytes.contains(ARRAY234, (byte) 3));
    assertTrue(Bytes.contains(ARRAY234, (byte) 4));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                public void testContains() {
    assertFalse(Bytes.contains(EMPTY, (byte) 1));
    assertFalse(Bytes.contains(ARRAY1, (byte) 2));
    assertFalse(Bytes.contains(ARRAY234, (byte) 1));
    assertTrue(Bytes.contains(new byte[] {(byte) -1}, (byte) -1));
    assertTrue(Bytes.contains(ARRAY234, (byte) 2));
    assertTrue(Bytes.contains(ARRAY234, (byte) 3));
    assertTrue(Bytes.contains(ARRAY234, (byte) 4));
  }

            

Reported by PMD.