The following issues were found

guava-tests/test/com/google/common/cache/CacheReferencesTest.java
65 issues
Do not explicitly trigger a garbage collection.
Error

Line: 137

                  // wait up to 5s
    byte[] filler = new byte[1024];
    for (int i = 0; i < 500; i++) {
      System.gc();

      CacheTesting.drainReferenceQueues(cache);
      if (cache.size() == 1) {
        break;
      }

            

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

                      });
  }

  public void testContainsKeyAndValue() {
    for (LoadingCache<Key, String> cache : caches()) {
      // maintain strong refs so these won't be collected, regardless of cache's key/value strength
      Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));

            

Reported by PMD.

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

Line: 63

                      });
  }

  public void testContainsKeyAndValue() {
    for (LoadingCache<Key, String> cache : caches()) {
      // maintain strong refs so these won't be collected, regardless of cache's key/value strength
      Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 66

                public void testContainsKeyAndValue() {
    for (LoadingCache<Key, String> cache : caches()) {
      // maintain strong refs so these won't be collected, regardless of cache's key/value strength
      Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 68

                    // maintain strong refs so these won't be collected, regardless of cache's key/value strength
      Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 69

                    Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }


            

Reported by PMD.

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

Line: 69

                    Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 70

                    String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }

  public void testClear() {

            

Reported by PMD.

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

Line: 70

                    String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }

  public void testClear() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 71

                    assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }

  public void testClear() {
    for (LoadingCache<Key, String> cache : caches()) {

            

Reported by PMD.

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

Line: 46

               *
 * @author Dimitris Andreou
 */
public class StripedTest extends TestCase {
  private static List<Striped<?>> strongImplementations() {
    return ImmutableList.of(
        Striped.readWriteLock(100),
        Striped.readWriteLock(256),
        Striped.lock(100),

            

Reported by PMD.

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

Line: 118

                  return concat(strongImplementations(), weakImplementations());
  }

  public void testNull() throws Exception {
    for (Striped<?> striped : allImplementations()) {
      new NullPointerTester().testAllPublicInstanceMethods(striped);
    }
  }


            

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

                  return concat(strongImplementations(), weakImplementations());
  }

  public void testNull() throws Exception {
    for (Striped<?> striped : allImplementations()) {
      new NullPointerTester().testAllPublicInstanceMethods(striped);
    }
  }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 120

              
  public void testNull() throws Exception {
    for (Striped<?> striped : allImplementations()) {
      new NullPointerTester().testAllPublicInstanceMethods(striped);
    }
  }

  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations

            

Reported by PMD.

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

Line: 124

                  }
  }

  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);

            

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

                  }
  }

  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);

            

Reported by PMD.

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

Line: 126

              
  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 126

              
  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 127

                public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);
  }



            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 127

                public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);
  }



            

Reported by PMD.

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

Line: 46

               *
 * @author Dimitris Andreou
 */
public class StripedTest extends TestCase {
  private static List<Striped<?>> strongImplementations() {
    return ImmutableList.of(
        Striped.readWriteLock(100),
        Striped.readWriteLock(256),
        Striped.lock(100),

            

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

                  return concat(strongImplementations(), weakImplementations());
  }

  public void testNull() throws Exception {
    for (Striped<?> striped : allImplementations()) {
      new NullPointerTester().testAllPublicInstanceMethods(striped);
    }
  }


            

Reported by PMD.

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

Line: 118

                  return concat(strongImplementations(), weakImplementations());
  }

  public void testNull() throws Exception {
    for (Striped<?> striped : allImplementations()) {
      new NullPointerTester().testAllPublicInstanceMethods(striped);
    }
  }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 120

              
  public void testNull() throws Exception {
    for (Striped<?> striped : allImplementations()) {
      new NullPointerTester().testAllPublicInstanceMethods(striped);
    }
  }

  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations

            

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

                  }
  }

  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);

            

Reported by PMD.

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

Line: 124

                  }
  }

  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 126

              
  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);
  }


            

Reported by PMD.

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

Line: 126

              
  public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 127

                public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);
  }



            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 127

                public void testSizes() {
    // not bothering testing all variations, since we know they share implementations
    assertTrue(Striped.lock(100).size() >= 100);
    assertTrue(Striped.lock(256).size() == 256);
    assertTrue(Striped.lazyWeakLock(100).size() >= 100);
    assertTrue(Striped.lazyWeakLock(256).size() == 256);
  }



            

Reported by PMD.

guava-tests/test/com/google/common/base/EquivalenceTest.java
65 issues
Avoid using equals() to compare against null
Error

Line: 74

                      .addEqualityGroup(LENGTH_EQUIVALENCE.wrap("hi"), LENGTH_EQUIVALENCE.wrap("yo"))
        .addEqualityGroup(LENGTH_EQUIVALENCE.wrap(null), LENGTH_EQUIVALENCE.wrap(null))
        .addEqualityGroup(Equivalence.equals().wrap("hello"))
        .addEqualityGroup(Equivalence.equals().wrap(null))
        .testEquals();
  }

  public void testWrap_get() {
    String test = "test";

            

Reported by PMD.

Avoid using equals() to compare against null
Error

Line: 126

                  assertTrue(equalTo1.apply("1"));
    assertFalse(equalTo1.apply("2"));
    assertFalse(equalTo1.apply(null));
    Predicate<Object> isNull = Equivalence.equals().equivalentTo(null);
    assertFalse(isNull.apply("1"));
    assertFalse(isNull.apply("2"));
    assertTrue(isNull.apply(null));

    new EqualsTester()

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 140

              
  public void testEqualsEquivalent() {
    EquivalenceTester.of(Equivalence.equals())
        .addEquivalenceGroup(new Integer(42), 42)
        .addEquivalenceGroup("a")
        .test();
  }

  public void testIdentityEquivalent() {

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 147

              
  public void testIdentityEquivalent() {
    EquivalenceTester.of(Equivalence.identity())
        .addEquivalenceGroup(new Integer(42))
        .addEquivalenceGroup(new Integer(42))
        .addEquivalenceGroup("a")
        .test();
  }


            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 148

                public void testIdentityEquivalent() {
    EquivalenceTester.of(Equivalence.identity())
        .addEquivalenceGroup(new Integer(42))
        .addEquivalenceGroup(new Integer(42))
        .addEquivalenceGroup("a")
        .test();
  }

  public void testEquals() {

            

Reported by PMD.

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

Line: 35

               * @author Jige Yu
 */
@GwtCompatible(emulated = true)
public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("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: 36

               */
@GwtCompatible(emulated = true)
public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("a"))
        .addEquivalenceGroup(ImmutableList.of("b"))

            

Reported by PMD.

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

Line: 37

              @GwtCompatible(emulated = true)
public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("a"))
        .addEquivalenceGroup(ImmutableList.of("b"))
        .addEquivalenceGroup(ImmutableList.of("a", "b"), ImmutableList.of("a", "b"))

            

Reported by PMD.

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

Line: 38

              public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("a"))
        .addEquivalenceGroup(ImmutableList.of("b"))
        .addEquivalenceGroup(ImmutableList.of("a", "b"), ImmutableList.of("a", "b"))
        .test();

            

Reported by PMD.

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

Line: 38

              public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("a"))
        .addEquivalenceGroup(ImmutableList.of("b"))
        .addEquivalenceGroup(ImmutableList.of("a", "b"), ImmutableList.of("a", "b"))
        .test();

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/CacheReferencesTest.java
65 issues
Do not explicitly trigger a garbage collection.
Error

Line: 137

                  // wait up to 5s
    byte[] filler = new byte[1024];
    for (int i = 0; i < 500; i++) {
      System.gc();

      CacheTesting.drainReferenceQueues(cache);
      if (cache.size() == 1) {
        break;
      }

            

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

                      });
  }

  public void testContainsKeyAndValue() {
    for (LoadingCache<Key, String> cache : caches()) {
      // maintain strong refs so these won't be collected, regardless of cache's key/value strength
      Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));

            

Reported by PMD.

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

Line: 63

                      });
  }

  public void testContainsKeyAndValue() {
    for (LoadingCache<Key, String> cache : caches()) {
      // maintain strong refs so these won't be collected, regardless of cache's key/value strength
      Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 66

                public void testContainsKeyAndValue() {
    for (LoadingCache<Key, String> cache : caches()) {
      // maintain strong refs so these won't be collected, regardless of cache's key/value strength
      Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 68

                    // maintain strong refs so these won't be collected, regardless of cache's key/value strength
      Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 69

                    Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }


            

Reported by PMD.

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

Line: 69

                    Key key = new Key(1);
      String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 70

                    String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }

  public void testClear() {

            

Reported by PMD.

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

Line: 70

                    String value = key.toString();
      assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }

  public void testClear() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 71

                    assertSame(value, cache.getUnchecked(key));
      assertTrue(cache.asMap().containsKey(key));
      assertTrue(cache.asMap().containsValue(value));
      assertEquals(1, cache.size());
    }
  }

  public void testClear() {
    for (LoadingCache<Key, String> cache : caches()) {

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/EquivalenceTest.java
65 issues
Avoid using equals() to compare against null
Error

Line: 74

                      .addEqualityGroup(LENGTH_EQUIVALENCE.wrap("hi"), LENGTH_EQUIVALENCE.wrap("yo"))
        .addEqualityGroup(LENGTH_EQUIVALENCE.wrap(null), LENGTH_EQUIVALENCE.wrap(null))
        .addEqualityGroup(Equivalence.equals().wrap("hello"))
        .addEqualityGroup(Equivalence.equals().wrap(null))
        .testEquals();
  }

  public void testWrap_get() {
    String test = "test";

            

Reported by PMD.

Avoid using equals() to compare against null
Error

Line: 126

                  assertTrue(equalTo1.apply("1"));
    assertFalse(equalTo1.apply("2"));
    assertFalse(equalTo1.apply(null));
    Predicate<Object> isNull = Equivalence.equals().equivalentTo(null);
    assertFalse(isNull.apply("1"));
    assertFalse(isNull.apply("2"));
    assertTrue(isNull.apply(null));

    new EqualsTester()

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 140

              
  public void testEqualsEquivalent() {
    EquivalenceTester.of(Equivalence.equals())
        .addEquivalenceGroup(new Integer(42), 42)
        .addEquivalenceGroup("a")
        .test();
  }

  public void testIdentityEquivalent() {

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 147

              
  public void testIdentityEquivalent() {
    EquivalenceTester.of(Equivalence.identity())
        .addEquivalenceGroup(new Integer(42))
        .addEquivalenceGroup(new Integer(42))
        .addEquivalenceGroup("a")
        .test();
  }


            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 148

                public void testIdentityEquivalent() {
    EquivalenceTester.of(Equivalence.identity())
        .addEquivalenceGroup(new Integer(42))
        .addEquivalenceGroup(new Integer(42))
        .addEquivalenceGroup("a")
        .test();
  }

  public void testEquals() {

            

Reported by PMD.

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

Line: 35

               * @author Jige Yu
 */
@GwtCompatible(emulated = true)
public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("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: 36

               */
@GwtCompatible(emulated = true)
public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("a"))
        .addEquivalenceGroup(ImmutableList.of("b"))

            

Reported by PMD.

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

Line: 37

              @GwtCompatible(emulated = true)
public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("a"))
        .addEquivalenceGroup(ImmutableList.of("b"))
        .addEquivalenceGroup(ImmutableList.of("a", "b"), ImmutableList.of("a", "b"))

            

Reported by PMD.

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

Line: 38

              public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("a"))
        .addEquivalenceGroup(ImmutableList.of("b"))
        .addEquivalenceGroup(ImmutableList.of("a", "b"), ImmutableList.of("a", "b"))
        .test();

            

Reported by PMD.

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

Line: 38

              public class EquivalenceTest extends TestCase {
  @SuppressWarnings("unchecked") // varargs
  public void testPairwiseEquivalent() {
    EquivalenceTester.of(Equivalence.equals().<String>pairwise())
        .addEquivalenceGroup(ImmutableList.<String>of())
        .addEquivalenceGroup(ImmutableList.of("a"))
        .addEquivalenceGroup(ImmutableList.of("b"))
        .addEquivalenceGroup(ImmutableList.of("a", "b"), ImmutableList.of("a", "b"))
        .test();

            

Reported by PMD.

android/guava/src/com/google/common/base/CharMatcher.java
65 issues
Avoid reassigning parameters such as 'inMatchingGroup'
Design

Line: 887

                    int end,
      char replacement,
      StringBuilder builder,
      boolean inMatchingGroup) {
    for (int i = start; i < end; i++) {
      char c = sequence.charAt(i);
      if (matches(c)) {
        if (!inMatchingGroup) {
          builder.append(replacement);

            

Reported by PMD.

Avoid reassigning parameters such as 'inMatchingGroup'
Design

Line: 887

                    int end,
      char replacement,
      StringBuilder builder,
      boolean inMatchingGroup) {
    for (int i = start; i < end; i++) {
      char c = sequence.charAt(i);
      if (matches(c)) {
        if (!inMatchingGroup) {
          builder.append(replacement);

            

Reported by PMD.

Avoid reassigning parameters such as 'c'
Design

Line: 926

                 * Returns the Java Unicode escape sequence for the given {@code char}, in the form "\u12AB" where
   * "12AB" is the four hexadecimal digits representing the 16-bit code unit.
   */
  private static String showCharacter(char c) {
    String hex = "0123456789ABCDEF";
    char[] tmp = {'\\', 'u', '\0', '\0', '\0', '\0'};
    for (int i = 0; i < 4; i++) {
      tmp[5 - i] = hex.charAt(c & 0xF);
      c = (char) (c >> 4);

            

Reported by PMD.

Avoid reassigning parameters such as 'table'
Design

Line: 986

              
    private final BitSet table;

    private BitSetMatcher(BitSet table, String description) {
      super(description);
      if (table.length() + Long.SIZE < table.size()) {
        table = (BitSet) table.clone();
        // If only we could actually call BitSet.trimToSize() ourselves...
      }

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.base;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;


            

Reported by PMD.

The class 'CharMatcher' has a total cyclomatic complexity of 105 (highest 7).
Design

Line: 65

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
  /*
   *           N777777777NO
   *         N7777777777777N
   *        M777777777777777N
   *        $N877777777D77777M

            

Reported by PMD.

Avoid really long classes.
Design

Line: 65

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
  /*
   *           N777777777NO
   *         N7777777777777N
   *        M777777777777777N
   *        $N877777777D77777M

            

Reported by PMD.

Possible God Class (WMC=105, ATFD=23, TCC=0.000%)
Design

Line: 65

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
  /*
   *           N777777777NO
   *         N7777777777777N
   *        M777777777777777N
   *        $N877777777D77777M

            

Reported by PMD.

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

Line: 65

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
  /*
   *           N777777777NO
   *         N7777777777777N
   *        M777777777777777N
   *        $N877777777D77777M

            

Reported by PMD.

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

Line: 332

                 * character sequence. Returns a bogus matcher if the sequence contains supplementary characters.
   */
  public static CharMatcher noneOf(CharSequence sequence) {
    return anyOf(sequence).negate();
  }

  /**
   * Returns a {@code char} matcher that matches any character in a given BMP range (both endpoints
   * are inclusive). For example, to match any lowercase letter of the English alphabet, use {@code

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java
65 issues
Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 42

               * @author Louis Wasserman
 */
public class SynchronizedNavigableSetTest extends TestCase {
  private static final Object MUTEX = new Integer(1); // something Serializable

  @SuppressWarnings("unchecked")
  protected <E> NavigableSet<E> create() {
    TestSet<E> inner =
        new TestSet<>(new TreeSet<E>((Comparator<E>) Ordering.natural().nullsFirst()), MUTEX);

            

Reported by PMD.

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

Line: 47

                @SuppressWarnings("unchecked")
  protected <E> NavigableSet<E> create() {
    TestSet<E> inner =
        new TestSet<>(new TreeSet<E>((Comparator<E>) Ordering.natural().nullsFirst()), MUTEX);
    NavigableSet<E> outer = Synchronized.navigableSet(inner, MUTEX);
    return outer;
  }

  static class TestSet<E> extends SynchronizedSetTest.TestSet<E> implements NavigableSet<E> {

            

Reported by PMD.

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

Line: 52

                  return outer;
  }

  static class TestSet<E> extends SynchronizedSetTest.TestSet<E> implements NavigableSet<E> {

    TestSet(NavigableSet<E> delegate, Object mutex) {
      super(delegate, mutex);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 65

              
    @Override
    public E ceiling(E e) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().ceiling(e);
    }

    @Override
    public Iterator<E> descendingIterator() {

            

Reported by PMD.

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

Line: 66

                  @Override
    public E ceiling(E e) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().ceiling(e);
    }

    @Override
    public Iterator<E> descendingIterator() {
      return delegate().descendingIterator();

            

Reported by PMD.

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

Line: 71

              
    @Override
    public Iterator<E> descendingIterator() {
      return delegate().descendingIterator();
    }

    @Override
    public NavigableSet<E> descendingSet() {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 76

              
    @Override
    public NavigableSet<E> descendingSet() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().descendingSet();
    }

    @Override
    public E floor(E e) {

            

Reported by PMD.

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

Line: 77

                  @Override
    public NavigableSet<E> descendingSet() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().descendingSet();
    }

    @Override
    public E floor(E e) {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 82

              
    @Override
    public E floor(E e) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().floor(e);
    }

    @Override
    public NavigableSet<E> headSet(E toElement, boolean inclusive) {

            

Reported by PMD.

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

Line: 83

                  @Override
    public E floor(E e) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().floor(e);
    }

    @Override
    public NavigableSet<E> headSet(E toElement, boolean inclusive) {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

guava/src/com/google/common/base/CharMatcher.java
64 issues
Avoid reassigning parameters such as 'inMatchingGroup'
Design

Line: 888

                    int end,
      char replacement,
      StringBuilder builder,
      boolean inMatchingGroup) {
    for (int i = start; i < end; i++) {
      char c = sequence.charAt(i);
      if (matches(c)) {
        if (!inMatchingGroup) {
          builder.append(replacement);

            

Reported by PMD.

Avoid reassigning parameters such as 'inMatchingGroup'
Design

Line: 888

                    int end,
      char replacement,
      StringBuilder builder,
      boolean inMatchingGroup) {
    for (int i = start; i < end; i++) {
      char c = sequence.charAt(i);
      if (matches(c)) {
        if (!inMatchingGroup) {
          builder.append(replacement);

            

Reported by PMD.

Avoid reassigning parameters such as 'c'
Design

Line: 927

                 * Returns the Java Unicode escape sequence for the given {@code char}, in the form "\u12AB" where
   * "12AB" is the four hexadecimal digits representing the 16-bit code unit.
   */
  private static String showCharacter(char c) {
    String hex = "0123456789ABCDEF";
    char[] tmp = {'\\', 'u', '\0', '\0', '\0', '\0'};
    for (int i = 0; i < 4; i++) {
      tmp[5 - i] = hex.charAt(c & 0xF);
      c = (char) (c >> 4);

            

Reported by PMD.

Avoid reassigning parameters such as 'table'
Design

Line: 987

              
    private final BitSet table;

    private BitSetMatcher(BitSet table, String description) {
      super(description);
      if (table.length() + Long.SIZE < table.size()) {
        table = (BitSet) table.clone();
        // If only we could actually call BitSet.trimToSize() ourselves...
      }

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.base;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;


            

Reported by PMD.

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

Line: 65

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
  /*
   *           N777777777NO
   *         N7777777777777N
   *        M777777777777777N
   *        $N877777777D77777M

            

Reported by PMD.

The class 'CharMatcher' has a total cyclomatic complexity of 105 (highest 7).
Design

Line: 65

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
  /*
   *           N777777777NO
   *         N7777777777777N
   *        M777777777777777N
   *        $N877777777D77777M

            

Reported by PMD.

Avoid really long classes.
Design

Line: 65

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
  /*
   *           N777777777NO
   *         N7777777777777N
   *        M777777777777777N
   *        $N877777777D77777M

            

Reported by PMD.

Possible God Class (WMC=105, ATFD=23, TCC=0.000%)
Design

Line: 65

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
  /*
   *           N777777777NO
   *         N7777777777777N
   *        M777777777777777N
   *        $N877777777D77777M

            

Reported by PMD.

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

Line: 332

                 * character sequence. Returns a bogus matcher if the sequence contains supplementary characters.
   */
  public static CharMatcher noneOf(CharSequence sequence) {
    return anyOf(sequence).negate();
  }

  /**
   * Returns a {@code char} matcher that matches any character in a given BMP range (both endpoints
   * are inclusive). For example, to match any lowercase letter of the English alphabet, use {@code

            

Reported by PMD.

guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java
64 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 46

                @SuppressWarnings("unchecked")
  protected <E> NavigableSet<E> create() {
    TestSet<E> inner =
        new TestSet<>(new TreeSet<E>((Comparator<E>) Ordering.natural().nullsFirst()), null);
    NavigableSet<E> outer = Synchronized.navigableSet(inner, null);
    inner.mutex = outer;
    return outer;
  }


            

Reported by PMD.

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

Line: 52

                  return outer;
  }

  static class TestSet<E> extends SynchronizedSetTest.TestSet<E> implements NavigableSet<E> {

    TestSet(NavigableSet<E> delegate, Object mutex) {
      super(delegate, mutex);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 65

              
    @Override
    public E ceiling(E e) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().ceiling(e);
    }

    @Override
    public Iterator<E> descendingIterator() {

            

Reported by PMD.

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

Line: 66

                  @Override
    public E ceiling(E e) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().ceiling(e);
    }

    @Override
    public Iterator<E> descendingIterator() {
      return delegate().descendingIterator();

            

Reported by PMD.

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

Line: 71

              
    @Override
    public Iterator<E> descendingIterator() {
      return delegate().descendingIterator();
    }

    @Override
    public NavigableSet<E> descendingSet() {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 76

              
    @Override
    public NavigableSet<E> descendingSet() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().descendingSet();
    }

    @Override
    public E floor(E e) {

            

Reported by PMD.

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

Line: 77

                  @Override
    public NavigableSet<E> descendingSet() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().descendingSet();
    }

    @Override
    public E floor(E e) {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 82

              
    @Override
    public E floor(E e) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().floor(e);
    }

    @Override
    public NavigableSet<E> headSet(E toElement, boolean inclusive) {

            

Reported by PMD.

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

Line: 83

                  @Override
    public E floor(E e) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().floor(e);
    }

    @Override
    public NavigableSet<E> headSet(E toElement, boolean inclusive) {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 88

              
    @Override
    public NavigableSet<E> headSet(E toElement, boolean inclusive) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate().headSet(toElement, inclusive);
    }

    @Override
    public SortedSet<E> headSet(E toElement) {

            

Reported by PMD.