The following issues were found

guava-tests/test/com/google/common/collect/StreamsTest.java
204 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.collect;

import static com.google.common.collect.Streams.stream;

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;

            

Reported by PMD.

Possible God Class (WMC=54, ATFD=58, TCC=0.000%)
Design

Line: 43

              
/** Unit test for {@link Streams}. */
@GwtCompatible(emulated = true)
public class StreamsTest extends TestCase {
  /*
   * Full and proper black-box testing of a Stream-returning method is extremely involved, and is
   * overkill when nearly all Streams are produced using well-tested JDK calls. So, we cheat and
   * just test that the toArray() contents are as expected.
   */

            

Reported by PMD.

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

Line: 43

              
/** Unit test for {@link Streams}. */
@GwtCompatible(emulated = true)
public class StreamsTest extends TestCase {
  /*
   * Full and proper black-box testing of a Stream-returning method is extremely involved, and is
   * overkill when nearly all Streams are produced using well-tested JDK calls. So, we cheat and
   * just test that the toArray() contents are as 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: 49

                 * overkill when nearly all Streams are produced using well-tested JDK calls. So, we cheat and
   * just test that the toArray() contents are as expected.
   */
  public void testStream_nonCollection() {
    assertThat(stream(FluentIterable.of())).isEmpty();
    assertThat(stream(FluentIterable.of("a"))).containsExactly("a");
    assertThat(stream(FluentIterable.of(1, 2, 3)).filter(n -> n > 1)).containsExactly(2, 3);
  }


            

Reported by PMD.

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

Line: 49

                 * overkill when nearly all Streams are produced using well-tested JDK calls. So, we cheat and
   * just test that the toArray() contents are as expected.
   */
  public void testStream_nonCollection() {
    assertThat(stream(FluentIterable.of())).isEmpty();
    assertThat(stream(FluentIterable.of("a"))).containsExactly("a");
    assertThat(stream(FluentIterable.of(1, 2, 3)).filter(n -> n > 1)).containsExactly(2, 3);
  }


            

Reported by PMD.

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

Line: 50

                 * just test that the toArray() contents are as expected.
   */
  public void testStream_nonCollection() {
    assertThat(stream(FluentIterable.of())).isEmpty();
    assertThat(stream(FluentIterable.of("a"))).containsExactly("a");
    assertThat(stream(FluentIterable.of(1, 2, 3)).filter(n -> n > 1)).containsExactly(2, 3);
  }

  @SuppressWarnings("deprecation")

            

Reported by PMD.

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

Line: 51

                 */
  public void testStream_nonCollection() {
    assertThat(stream(FluentIterable.of())).isEmpty();
    assertThat(stream(FluentIterable.of("a"))).containsExactly("a");
    assertThat(stream(FluentIterable.of(1, 2, 3)).filter(n -> n > 1)).containsExactly(2, 3);
  }

  @SuppressWarnings("deprecation")
  public void testStream_collection() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 52

                public void testStream_nonCollection() {
    assertThat(stream(FluentIterable.of())).isEmpty();
    assertThat(stream(FluentIterable.of("a"))).containsExactly("a");
    assertThat(stream(FluentIterable.of(1, 2, 3)).filter(n -> n > 1)).containsExactly(2, 3);
  }

  @SuppressWarnings("deprecation")
  public void testStream_collection() {
    assertThat(stream(Arrays.asList())).isEmpty();

            

Reported by PMD.

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

Line: 52

                public void testStream_nonCollection() {
    assertThat(stream(FluentIterable.of())).isEmpty();
    assertThat(stream(FluentIterable.of("a"))).containsExactly("a");
    assertThat(stream(FluentIterable.of(1, 2, 3)).filter(n -> n > 1)).containsExactly(2, 3);
  }

  @SuppressWarnings("deprecation")
  public void testStream_collection() {
    assertThat(stream(Arrays.asList())).isEmpty();

            

Reported by PMD.

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

Line: 52

                public void testStream_nonCollection() {
    assertThat(stream(FluentIterable.of())).isEmpty();
    assertThat(stream(FluentIterable.of("a"))).containsExactly("a");
    assertThat(stream(FluentIterable.of(1, 2, 3)).filter(n -> n > 1)).containsExactly(2, 3);
  }

  @SuppressWarnings("deprecation")
  public void testStream_collection() {
    assertThat(stream(Arrays.asList())).isEmpty();

            

Reported by PMD.

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

Line: 54

               * @author Jared Levy
 */
@GwtCompatible(emulated = true)
public class LinkedHashMultimapTest 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: 56

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

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

            

Reported by PMD.

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

Line: 87

                  return suite;
  }

  public void testValueSetHashTableExpansion() {
    LinkedHashMultimap<String, Integer> multimap = LinkedHashMultimap.create();
    for (int z = 1; z <= 100; z++) {
      multimap.put("a", z);
      // The Eclipse compiler (and hence GWT) rejects a parameterized cast.
      @SuppressWarnings("unchecked")

            

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

                  return suite;
  }

  public void testValueSetHashTableExpansion() {
    LinkedHashMultimap<String, Integer> multimap = LinkedHashMultimap.create();
    for (int z = 1; z <= 100; z++) {
      multimap.put("a", z);
      // The Eclipse compiler (and hence GWT) rejects a parameterized cast.
      @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 94

                    // The Eclipse compiler (and hence GWT) rejects a parameterized cast.
      @SuppressWarnings("unchecked")
      LinkedHashMultimap<String, Integer>.ValueSet valueSet =
          (LinkedHashMultimap.ValueSet) multimap.backingMap().get("a");
      assertEquals(z, valueSet.size());
      assertFalse(
          Hashing.needsResizing(
              valueSet.size(),
              valueSet.hashTable.length,

            

Reported by PMD.

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

Line: 95

                    @SuppressWarnings("unchecked")
      LinkedHashMultimap<String, Integer>.ValueSet valueSet =
          (LinkedHashMultimap.ValueSet) multimap.backingMap().get("a");
      assertEquals(z, valueSet.size());
      assertFalse(
          Hashing.needsResizing(
              valueSet.size(),
              valueSet.hashTable.length,
              LinkedHashMultimap.VALUE_SET_LOAD_FACTOR));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 95

                    @SuppressWarnings("unchecked")
      LinkedHashMultimap<String, Integer>.ValueSet valueSet =
          (LinkedHashMultimap.ValueSet) multimap.backingMap().get("a");
      assertEquals(z, valueSet.size());
      assertFalse(
          Hashing.needsResizing(
              valueSet.size(),
              valueSet.hashTable.length,
              LinkedHashMultimap.VALUE_SET_LOAD_FACTOR));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 96

                    LinkedHashMultimap<String, Integer>.ValueSet valueSet =
          (LinkedHashMultimap.ValueSet) multimap.backingMap().get("a");
      assertEquals(z, valueSet.size());
      assertFalse(
          Hashing.needsResizing(
              valueSet.size(),
              valueSet.hashTable.length,
              LinkedHashMultimap.VALUE_SET_LOAD_FACTOR));
    }

            

Reported by PMD.

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

Line: 98

                    assertEquals(z, valueSet.size());
      assertFalse(
          Hashing.needsResizing(
              valueSet.size(),
              valueSet.hashTable.length,
              LinkedHashMultimap.VALUE_SET_LOAD_FACTOR));
    }
  }


            

Reported by PMD.

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

Line: 106

              
  private Multimap<String, Integer> initializeMultimap5() {
    Multimap<String, Integer> multimap = LinkedHashMultimap.create();
    multimap.put("foo", 5);
    multimap.put("bar", 4);
    multimap.put("foo", 3);
    multimap.put("cow", 2);
    multimap.put("bar", 1);
    return multimap;

            

Reported by PMD.

guava-tests/test/com/google/common/cache/CacheManualTest.java
203 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 26

              /** @author Charles Fry */
public class CacheManualTest extends TestCase {

  public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());

            

Reported by PMD.

The method 'testGetIfPresent()' has a NCSS line count of 65.
Design

Line: 26

              /** @author Charles Fry */
public class CacheManualTest extends TestCase {

  public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());

            

Reported by PMD.

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

Line: 26

              /** @author Charles Fry */
public class CacheManualTest extends TestCase {

  public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());

            

Reported by PMD.

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

Line: 28

              
  public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());


            

Reported by PMD.

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

Line: 29

                public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                  Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();
    Object two = new Object();

            

Reported by PMD.

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

Line: 30

                  Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();
    Object two = new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                  CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();
    Object two = new Object();


            

Reported by PMD.

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

Line: 31

                  CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();
    Object two = new Object();


            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/CacheManualTest.java
203 issues
The method 'testGetIfPresent()' has a NCSS line count of 65.
Design

Line: 26

              /** @author Charles Fry */
public class CacheManualTest extends TestCase {

  public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());

            

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

              /** @author Charles Fry */
public class CacheManualTest extends TestCase {

  public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());

            

Reported by PMD.

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

Line: 26

              /** @author Charles Fry */
public class CacheManualTest extends TestCase {

  public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());

            

Reported by PMD.

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

Line: 28

              
  public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());


            

Reported by PMD.

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

Line: 29

                public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                public void testGetIfPresent() {
    Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                  Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();
    Object two = new Object();

            

Reported by PMD.

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

Line: 30

                  Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
    CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();
    Object two = new Object();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                  CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();
    Object two = new Object();


            

Reported by PMD.

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

Line: 31

                  CacheStats stats = cache.stats();
    assertEquals(0, stats.missCount());
    assertEquals(0, stats.loadSuccessCount());
    assertEquals(0, stats.loadExceptionCount());
    assertEquals(0, stats.hitCount());

    Object one = new Object();
    Object two = new Object();


            

Reported by PMD.

android/guava-tests/test/com/google/common/reflect/ClassPathTest.java
202 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 520

              
    Closer closer = Closer.create();
    try {
      FileOutputStream fileOut = closer.register(new FileOutputStream(jarFile));
      JarOutputStream jarOut = closer.register(new JarOutputStream(fileOut));
      for (String entry : entries) {
        jarOut.putNextEntry(new ZipEntry(entry));
        Resources.copy(ClassPathTest.class.getResource(entry), jarOut);
        jarOut.closeEntry();

            

Reported by PMD.

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

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.common.reflect;

import static com.google.common.base.Charsets.US_ASCII;
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
import static com.google.common.truth.Truth.assertThat;

            

Reported by PMD.

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

Line: 54

              import org.junit.Test;

/** Functional tests of {@link ClassPath}. */
public class ClassPathTest extends TestCase {
  private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
  private static final File FILE = new File(".");

  public void testEquals() {
    new EqualsTester()

            

Reported by PMD.

Possible God Class (WMC=72, ATFD=90, TCC=0.649%)
Design

Line: 54

              import org.junit.Test;

/** Functional tests of {@link ClassPath}. */
public class ClassPathTest extends TestCase {
  private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
  private static final File FILE = new File(".");

  public void testEquals() {
    new EqualsTester()

            

Reported by PMD.

Avoid unused private fields such as 'log'.
Design

Line: 55

              
/** Functional tests of {@link ClassPath}. */
public class ClassPathTest extends TestCase {
  private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
  private static final File FILE = new File(".");

  public void testEquals() {
    new EqualsTester()
        .addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))

            

Reported by PMD.

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

Line: 58

                private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
  private static final File FILE = new File(".");

  public void testEquals() {
    new EqualsTester()
        .addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
        .addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
        .addEqualityGroup(
            new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),

            

Reported by PMD.

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

Line: 58

                private static final Logger log = Logger.getLogger(ClassPathTest.class.getName());
  private static final File FILE = new File(".");

  public void testEquals() {
    new EqualsTester()
        .addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
        .addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
        .addEqualityGroup(
            new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),

            

Reported by PMD.

In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.
Error

Line: 61

                public void testEquals() {
    new EqualsTester()
        .addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
        .addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
        .addEqualityGroup(
            new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),
            new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()))
        .addEqualityGroup(new ResourceInfo(FILE, "x.txt", getClass().getClassLoader()))
        .testEquals();

            

Reported by PMD.

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

Line: 61

                public void testEquals() {
    new EqualsTester()
        .addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
        .addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
        .addEqualityGroup(
            new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),
            new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()))
        .addEqualityGroup(new ResourceInfo(FILE, "x.txt", getClass().getClassLoader()))
        .testEquals();

            

Reported by PMD.

In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.
Error

Line: 63

                      .addEqualityGroup(classInfo(ClassPathTest.class), classInfo(ClassPathTest.class))
        .addEqualityGroup(classInfo(Test.class), classInfo(Test.class, getClass().getClassLoader()))
        .addEqualityGroup(
            new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()),
            new ResourceInfo(FILE, "a/b/c.txt", getClass().getClassLoader()))
        .addEqualityGroup(new ResourceInfo(FILE, "x.txt", getClass().getClassLoader()))
        .testEquals();
  }


            

Reported by PMD.

guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java
197 issues
Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 342

              
    ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.
    assertTrue(s1 != s2); // Stating the obvious.

    multiset.add(s1);

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 343

                  ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.
    assertTrue(s1 != s2); // Stating the obvious.

    multiset.add(s1);
    assertTrue(multiset.contains(s1));

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 378

              
    ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.

    multiset.add(s1);
    assertTrue(multiset.contains(s1));

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 379

                  ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.

    multiset.add(s1);
    assertTrue(multiset.contains(s1));
    assertTrue(multiset.contains(s2));

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 424

                  ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);
    multiset = reserializeAndAssert(multiset);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.
    assertTrue(s1 != s2); // Stating the obvious.

    multiset.add(s1);

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 425

                  multiset = reserializeAndAssert(multiset);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.
    assertTrue(s1 != s2); // Stating the obvious.

    multiset.add(s1);
    assertTrue(multiset.contains(s1));

            

Reported by PMD.

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

Line: 49

               * @author Cliff L. Biffle
 * @author mike nonemacher
 */
public class ConcurrentHashMultisetTest extends TestCase {

  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(concurrentHashMultisetGenerator())

            

Reported by PMD.

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

Line: 51

               */
public class ConcurrentHashMultisetTest extends TestCase {

  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(concurrentHashMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,

            

Reported by PMD.

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

Line: 54

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(concurrentHashMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.ALLOWS_NULL_QUERIES)

            

Reported by PMD.

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

Line: 54

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(concurrentHashMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.ALLOWS_NULL_QUERIES)

            

Reported by PMD.

guava-tests/test/com/google/common/base/FunctionsTest.java
197 issues
Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 48

              
  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));
  }

  @GwtIncompatible // SerializableTester
  public void testIdentitySerializable() {
    checkCanReserializeSingleton(Functions.identity());

            

Reported by PMD.

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

Line: 48

              
  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));
  }

  @GwtIncompatible // SerializableTester
  public void testIdentitySerializable() {
    checkCanReserializeSingleton(Functions.identity());

            

Reported by PMD.

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

Line: 38

               * @author Vlad Patryshev
 */
@GwtCompatible(emulated = true)
public class FunctionsTest extends TestCase {

  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));

            

Reported by PMD.

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

Line: 40

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

  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("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: 40

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

  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

              
  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();

            

Reported by PMD.

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

Line: 42

              
  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

                public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));

            

Reported by PMD.

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

Line: 43

                public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));

            

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

                  assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));
  }

  @GwtIncompatible // SerializableTester

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/FunctionsTest.java
197 issues
Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 48

              
  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));
  }

  @GwtIncompatible // SerializableTester
  public void testIdentitySerializable() {
    checkCanReserializeSingleton(Functions.identity());

            

Reported by PMD.

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

Line: 48

              
  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));
  }

  @GwtIncompatible // SerializableTester
  public void testIdentitySerializable() {
    checkCanReserializeSingleton(Functions.identity());

            

Reported by PMD.

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

Line: 38

               * @author Vlad Patryshev
 */
@GwtCompatible(emulated = true)
public class FunctionsTest extends TestCase {

  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("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: 40

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

  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }


            

Reported by PMD.

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

Line: 40

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

  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }


            

Reported by PMD.

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

Line: 42

              
  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

              
  public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

                public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));

            

Reported by PMD.

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

Line: 43

                public void testIdentity_same() {
    Function<String, String> identity = Functions.identity();
    assertNull(identity.apply(null));
    assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));

            

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

                  assertSame("foo", identity.apply("foo"));
  }

  public void testIdentity_notSame() {
    Function<Long, Long> identity = Functions.identity();
    assertNotSame(new Long(135135L), identity.apply(new Long(135135L)));
  }

  @GwtIncompatible // SerializableTester

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java
197 issues
Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 342

              
    ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.
    assertTrue(s1 != s2); // Stating the obvious.

    multiset.add(s1);

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 343

                  ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.
    assertTrue(s1 != s2); // Stating the obvious.

    multiset.add(s1);
    assertTrue(multiset.contains(s1));

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 378

              
    ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.

    multiset.add(s1);
    assertTrue(multiset.contains(s1));

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 379

                  ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.

    multiset.add(s1);
    assertTrue(multiset.contains(s1));
    assertTrue(multiset.contains(s2));

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 424

                  ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);
    multiset = reserializeAndAssert(multiset);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.
    assertTrue(s1 != s2); // Stating the obvious.

    multiset.add(s1);

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 425

                  multiset = reserializeAndAssert(multiset);

    String s1 = new String("a");
    String s2 = new String("a");
    assertEquals(s1, s2); // Stating the obvious.
    assertTrue(s1 != s2); // Stating the obvious.

    multiset.add(s1);
    assertTrue(multiset.contains(s1));

            

Reported by PMD.

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

Line: 49

               * @author Cliff L. Biffle
 * @author mike nonemacher
 */
public class ConcurrentHashMultisetTest extends TestCase {

  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(concurrentHashMultisetGenerator())

            

Reported by PMD.

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

Line: 51

               */
public class ConcurrentHashMultisetTest extends TestCase {

  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(concurrentHashMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,

            

Reported by PMD.

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

Line: 54

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(concurrentHashMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.ALLOWS_NULL_QUERIES)

            

Reported by PMD.

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

Line: 54

                public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(
        MultisetTestSuiteBuilder.using(concurrentHashMultisetGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.GENERAL_PURPOSE,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.ALLOWS_NULL_QUERIES)

            

Reported by PMD.

guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java
194 issues
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.math;

import static com.google.common.math.StatsTesting.ALLOWED_ERROR;
import static com.google.common.math.StatsTesting.ALL_MANY_VALUES;
import static com.google.common.math.StatsTesting.EMPTY_STATS_ITERABLE;
import static com.google.common.math.StatsTesting.MANY_VALUES;

            

Reported by PMD.

The class 'PairedStatsAccumulatorTest' has a Modified Cyclomatic Complexity of 4 (Highest = 13).
Design

Line: 60

               *
 * @author Pete Gillin
 */
public class PairedStatsAccumulatorTest extends TestCase {

  private PairedStatsAccumulator emptyAccumulator;
  private PairedStatsAccumulator emptyAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator oneValueAccumulator;
  private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;

            

Reported by PMD.

The class 'PairedStatsAccumulatorTest' has a Standard Cyclomatic Complexity of 4 (Highest = 13).
Design

Line: 60

               *
 * @author Pete Gillin
 */
public class PairedStatsAccumulatorTest extends TestCase {

  private PairedStatsAccumulator emptyAccumulator;
  private PairedStatsAccumulator emptyAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator oneValueAccumulator;
  private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;

            

Reported by PMD.

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

Line: 62

               */
public class PairedStatsAccumulatorTest extends TestCase {

  private PairedStatsAccumulator emptyAccumulator;
  private PairedStatsAccumulator emptyAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator oneValueAccumulator;
  private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator twoValuesAccumulator;
  private PairedStatsAccumulator twoValuesAccumulatorByAddAllPartitionedPairedStats;

            

Reported by PMD.

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

Line: 63

              public class PairedStatsAccumulatorTest extends TestCase {

  private PairedStatsAccumulator emptyAccumulator;
  private PairedStatsAccumulator emptyAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator oneValueAccumulator;
  private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator twoValuesAccumulator;
  private PairedStatsAccumulator twoValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator manyValuesAccumulator;

            

Reported by PMD.

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

Line: 64

              
  private PairedStatsAccumulator emptyAccumulator;
  private PairedStatsAccumulator emptyAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator oneValueAccumulator;
  private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator twoValuesAccumulator;
  private PairedStatsAccumulator twoValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator manyValuesAccumulator;
  private PairedStatsAccumulator manyValuesAccumulatorByAddAllPartitionedPairedStats;

            

Reported by PMD.

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

Line: 65

                private PairedStatsAccumulator emptyAccumulator;
  private PairedStatsAccumulator emptyAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator oneValueAccumulator;
  private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator twoValuesAccumulator;
  private PairedStatsAccumulator twoValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator manyValuesAccumulator;
  private PairedStatsAccumulator manyValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator horizontalValuesAccumulator;

            

Reported by PMD.

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

Line: 66

                private PairedStatsAccumulator emptyAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator oneValueAccumulator;
  private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator twoValuesAccumulator;
  private PairedStatsAccumulator twoValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator manyValuesAccumulator;
  private PairedStatsAccumulator manyValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator horizontalValuesAccumulator;
  private PairedStatsAccumulator horizontalValuesAccumulatorByAddAllPartitionedPairedStats;

            

Reported by PMD.

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

Line: 67

                private PairedStatsAccumulator oneValueAccumulator;
  private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator twoValuesAccumulator;
  private PairedStatsAccumulator twoValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator manyValuesAccumulator;
  private PairedStatsAccumulator manyValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator horizontalValuesAccumulator;
  private PairedStatsAccumulator horizontalValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator verticalValuesAccumulator;

            

Reported by PMD.

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

Line: 68

                private PairedStatsAccumulator oneValueAccumulatorByAddAllEmptyPairedStats;
  private PairedStatsAccumulator twoValuesAccumulator;
  private PairedStatsAccumulator twoValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator manyValuesAccumulator;
  private PairedStatsAccumulator manyValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator horizontalValuesAccumulator;
  private PairedStatsAccumulator horizontalValuesAccumulatorByAddAllPartitionedPairedStats;
  private PairedStatsAccumulator verticalValuesAccumulator;
  private PairedStatsAccumulator verticalValuesAccumulatorByAddAllPartitionedPairedStats;

            

Reported by PMD.