The following issues were found

guava-tests/test/com/google/common/io/FilesFileTraverserTest.java
32 issues
This class has too many methods, consider refactoring it.
Design

Line: 37

               * @author Jens Nyman
 */

public class FilesFileTraverserTest extends TestCase {

  private File rootDir;

  @Override
  public void setUp() throws IOException {

            

Reported by PMD.

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

Line: 39

              
public class FilesFileTraverserTest extends TestCase {

  private File rootDir;

  @Override
  public void setUp() throws IOException {
    rootDir = Files.createTempDir();
  }

            

Reported by PMD.

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

Line: 41

              
  private File rootDir;

  @Override
  public void setUp() throws IOException {
    rootDir = Files.createTempDir();
  }

  @Override

            

Reported by PMD.

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

Line: 46

                  rootDir = Files.createTempDir();
  }

  @Override
  public void tearDown() throws IOException {
    // delete rootDir and its contents
    java.nio.file.Files.walkFileTree(
        rootDir.toPath(),
        new SimpleFileVisitor<Path>() {

            

Reported by PMD.

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

Line: 55

                        @Override
          public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
              throws IOException {
            java.nio.file.Files.deleteIfExists(file);
            return FileVisitResult.CONTINUE;
          }

          @Override
          public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {

            

Reported by PMD.

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

Line: 64

                          if (exc != null) {
              return FileVisitResult.TERMINATE;
            }
            java.nio.file.Files.deleteIfExists(dir);
            return FileVisitResult.CONTINUE;
          }
        });
  }


            

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

                      });
  }

  public void testFileTraverser_emptyDirectory() throws Exception {
    assertThat(Files.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
  }

  public void testFileTraverser_nonExistingFile() throws Exception {
    File file = new File(rootDir, "file-that-doesnt-exist");

            

Reported by PMD.

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

Line: 71

                }

  public void testFileTraverser_emptyDirectory() throws Exception {
    assertThat(Files.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
  }

  public void testFileTraverser_nonExistingFile() throws Exception {
    File file = new File(rootDir, "file-that-doesnt-exist");


            

Reported by PMD.

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

Line: 71

                }

  public void testFileTraverser_emptyDirectory() throws Exception {
    assertThat(Files.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
  }

  public void testFileTraverser_nonExistingFile() throws Exception {
    File file = new File(rootDir, "file-that-doesnt-exist");


            

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

                  assertThat(Files.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
  }

  public void testFileTraverser_nonExistingFile() throws Exception {
    File file = new File(rootDir, "file-that-doesnt-exist");

    assertThat(Files.fileTraverser().breadthFirst(file)).containsExactly(file);
  }


            

Reported by PMD.

guava-testlib/src/com/google/common/testing/ForwardingWrapperTester.java
32 issues
Avoid throwing raw exception types.
Design

Line: 119

                      methods[i] = type.getMethod(methods[i].getName(), methods[i].getParameterTypes());
      } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
      }
    }
    return methods;
  }


            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 149

                    fail(method + " failed to throw exception as is.");
    } catch (InvocationTargetException e) {
      if (exception != e.getCause()) {
        throw new RuntimeException(e);
      }
    } catch (IllegalAccessException e) {
      throw new AssertionError(e);
    }
  }

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 227

                            "Return value of " + method + " not forwarded", returnValue, actualReturnValue);
        }
      } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
      } catch (InvocationTargetException e) {
        throw Throwables.propagate(e.getCause());
      }
      assertEquals("Failed to forward to " + method, 1, called.get());
    }

            

Reported by PMD.

Avoid using redundant field initializer for 'testsEquals'
Performance

Line: 60

              @GwtIncompatible
public final class ForwardingWrapperTester {

  private boolean testsEquals = false;

  /**
   * Asks for {@link Object#equals} and {@link Object#hashCode} to be tested. That is, forwarding
   * wrappers of equal instances should be equal.
   */

            

Reported by PMD.

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

Line: 60

              @GwtIncompatible
public final class ForwardingWrapperTester {

  private boolean testsEquals = false;

  /**
   * Asks for {@link Object#equals} and {@link Object#hashCode} to be tested. That is, forwarding
   * wrappers of equal instances should be equal.
   */

            

Reported by PMD.

The method 'testForwarding(Class, Function)' has a cyclomatic complexity of 11.
Design

Line: 76

                 * calls with parameters passed as is, return value returned as is, and exceptions propagated as
   * is.
   */
  public <T> void testForwarding(
      Class<T> interfaceType, Function<? super T, ? extends T> wrapperFunction) {
    checkNotNull(wrapperFunction);
    checkArgument(interfaceType.isInterface(), "%s isn't an interface", interfaceType);
    Method[] methods = getMostConcreteMethods(interfaceType);
    AccessibleObject.setAccessible(methods, true);

            

Reported by PMD.

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

Line: 76

                 * calls with parameters passed as is, return value returned as is, and exceptions propagated as
   * is.
   */
  public <T> void testForwarding(
      Class<T> interfaceType, Function<? super T, ? extends T> wrapperFunction) {
    checkNotNull(wrapperFunction);
    checkArgument(interfaceType.isInterface(), "%s isn't an interface", interfaceType);
    Method[] methods = getMostConcreteMethods(interfaceType);
    AccessibleObject.setAccessible(methods, true);

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 91

                    }
      // The interface could be package-private or private.
      // filter out equals/hashCode/toString
      if (method.getName().equals("equals")
          && method.getParameterTypes().length == 1
          && method.getParameterTypes()[0] == Object.class) {
        continue;
      }
      if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0) {

            

Reported by PMD.

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

Line: 91

                    }
      // The interface could be package-private or private.
      // filter out equals/hashCode/toString
      if (method.getName().equals("equals")
          && method.getParameterTypes().length == 1
          && method.getParameterTypes()[0] == Object.class) {
        continue;
      }
      if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0) {

            

Reported by PMD.

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

Line: 92

                    // The interface could be package-private or private.
      // filter out equals/hashCode/toString
      if (method.getName().equals("equals")
          && method.getParameterTypes().length == 1
          && method.getParameterTypes()[0] == Object.class) {
        continue;
      }
      if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0) {
        continue;

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java
32 issues
High amount of different objects as members denotes a high coupling
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect.testing.google;

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

import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.Multiset;

            

Reported by PMD.

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

Line: 74

                @Override
  protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(CollectionSerializationEqualTester.class);
    testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);

            

Reported by PMD.

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

Line: 75

                protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(CollectionSerializationEqualTester.class);
    testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetReadsTester.class);

            

Reported by PMD.

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

Line: 76

                  List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
    testers.add(CollectionSerializationEqualTester.class);
    testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);

            

Reported by PMD.

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

Line: 77

                  testers.add(CollectionSerializationEqualTester.class);
    testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);

            

Reported by PMD.

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

Line: 78

                  testers.add(MultisetAddTester.class);
    testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);

            

Reported by PMD.

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

Line: 79

                  testers.add(MultisetContainsTester.class);
    testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);
    testers.add(MultisetEntrySetTester.class);

            

Reported by PMD.

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

Line: 80

                  testers.add(MultisetCountTester.class);
    testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);
    testers.add(MultisetEntrySetTester.class);
    testers.add(MultisetIteratorTester.class);

            

Reported by PMD.

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

Line: 81

                  testers.add(MultisetElementSetTester.class);
    testers.add(MultisetEqualsTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);
    testers.add(MultisetEntrySetTester.class);
    testers.add(MultisetIteratorTester.class);
    testers.add(MultisetSerializationTester.class);

            

Reported by PMD.

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

Line: 82

                  testers.add(MultisetEqualsTester.class);
    testers.add(MultisetReadsTester.class);
    testers.add(MultisetSetCountConditionallyTester.class);
    testers.add(MultisetSetCountUnconditionallyTester.class);
    testers.add(MultisetRemoveTester.class);
    testers.add(MultisetEntrySetTester.class);
    testers.add(MultisetIteratorTester.class);
    testers.add(MultisetSerializationTester.class);
    return testers;

            

Reported by PMD.

android/guava-tests/test/com/google/common/io/FilesFileTraverserTest.java
32 issues
This class has too many methods, consider refactoring it.
Design

Line: 37

               * @author Jens Nyman
 */

public class FilesFileTraverserTest extends TestCase {

  private File rootDir;

  @Override
  public void setUp() throws IOException {

            

Reported by PMD.

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

Line: 39

              
public class FilesFileTraverserTest extends TestCase {

  private File rootDir;

  @Override
  public void setUp() throws IOException {
    rootDir = Files.createTempDir();
  }

            

Reported by PMD.

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

Line: 41

              
  private File rootDir;

  @Override
  public void setUp() throws IOException {
    rootDir = Files.createTempDir();
  }

  @Override

            

Reported by PMD.

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

Line: 46

                  rootDir = Files.createTempDir();
  }

  @Override
  public void tearDown() throws IOException {
    // delete rootDir and its contents
    java.nio.file.Files.walkFileTree(
        rootDir.toPath(),
        new SimpleFileVisitor<Path>() {

            

Reported by PMD.

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

Line: 55

                        @Override
          public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
              throws IOException {
            java.nio.file.Files.deleteIfExists(file);
            return FileVisitResult.CONTINUE;
          }

          @Override
          public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {

            

Reported by PMD.

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

Line: 64

                          if (exc != null) {
              return FileVisitResult.TERMINATE;
            }
            java.nio.file.Files.deleteIfExists(dir);
            return FileVisitResult.CONTINUE;
          }
        });
  }


            

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

                      });
  }

  public void testFileTraverser_emptyDirectory() throws Exception {
    assertThat(Files.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
  }

  public void testFileTraverser_nonExistingFile() throws Exception {
    File file = new File(rootDir, "file-that-doesnt-exist");

            

Reported by PMD.

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

Line: 71

                }

  public void testFileTraverser_emptyDirectory() throws Exception {
    assertThat(Files.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
  }

  public void testFileTraverser_nonExistingFile() throws Exception {
    File file = new File(rootDir, "file-that-doesnt-exist");


            

Reported by PMD.

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

Line: 71

                }

  public void testFileTraverser_emptyDirectory() throws Exception {
    assertThat(Files.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
  }

  public void testFileTraverser_nonExistingFile() throws Exception {
    File file = new File(rootDir, "file-that-doesnt-exist");


            

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

                  assertThat(Files.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
  }

  public void testFileTraverser_nonExistingFile() throws Exception {
    File file = new File(rootDir, "file-that-doesnt-exist");

    assertThat(Files.fileTraverser().breadthFirst(file)).containsExactly(file);
  }


            

Reported by PMD.

android/guava-tests/test/com/google/common/io/ByteSourceTester.java
32 issues
This class has too many methods, consider refactoring it.
Design

Line: 47

               * @author Colin Decker
 */
@AndroidIncompatible // Android doesn't understand tests that lack default constructors.
public class ByteSourceTester extends SourceSinkTester<ByteSource, byte[], ByteSourceFactory> {

  private static final ImmutableList<Method> testMethods = getTestMethods(ByteSourceTester.class);

  static TestSuite tests(String name, ByteSourceFactory factory, boolean testAsCharSource) {
    TestSuite suite = new TestSuite(name);

            

Reported by PMD.

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

Line: 59

                    } else {
        suite.addTest(
            suiteForBytes(
                factory, entry.getValue().getBytes(Charsets.UTF_8), name, entry.getKey(), true));
      }
    }
    return suite;
  }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 79

                    ByteSourceFactory factory, byte[] bytes, String name, String desc, boolean slice) {
    TestSuite suite = new TestSuite(name + " [" + desc + "]");
    for (Method method : testMethods) {
      suite.addTest(new ByteSourceTester(factory, bytes, name, desc, method));
    }

    if (slice && bytes.length > 0) {
      // test a random slice() of the ByteSource
      Random random = new Random();

            

Reported by PMD.

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

Line: 112

                  return suite;
  }

  private ByteSource source;

  public ByteSourceTester(
      ByteSourceFactory factory, byte[] bytes, String suiteName, String caseDesc, Method method) {
    super(factory, bytes, suiteName, caseDesc, method);
  }

            

Reported by PMD.

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

Line: 119

                  super(factory, bytes, suiteName, caseDesc, method);
  }

  @Override
  public void setUp() throws IOException {
    source = factory.createSource(data);
  }

  public void testOpenStream() throws IOException {

            

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

                  source = factory.createSource(data);
  }

  public void testOpenStream() throws IOException {
    InputStream in = source.openStream();
    try {
      byte[] readBytes = ByteStreams.toByteArray(in);
      assertExpectedBytes(readBytes);
    } finally {

            

Reported by PMD.

Consider using a try-with-resources statement instead of explicitly closing the resource
Design

Line: 126

              
  public void testOpenStream() throws IOException {
    InputStream in = source.openStream();
    try {
      byte[] readBytes = ByteStreams.toByteArray(in);
      assertExpectedBytes(readBytes);
    } finally {
      in.close();
    }

            

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

                  }
  }

  public void testOpenBufferedStream() throws IOException {
    InputStream in = source.openBufferedStream();
    try {
      byte[] readBytes = ByteStreams.toByteArray(in);
      assertExpectedBytes(readBytes);
    } finally {

            

Reported by PMD.

Consider using a try-with-resources statement instead of explicitly closing the resource
Design

Line: 136

              
  public void testOpenBufferedStream() throws IOException {
    InputStream in = source.openBufferedStream();
    try {
      byte[] readBytes = ByteStreams.toByteArray(in);
      assertExpectedBytes(readBytes);
    } finally {
      in.close();
    }

            

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

                  }
  }

  public void testRead() throws IOException {
    byte[] readBytes = source.read();
    assertExpectedBytes(readBytes);
  }

  public void testCopyTo_outputStream() throws IOException {

            

Reported by PMD.

android/guava-testlib/src/com/google/common/testing/ForwardingWrapperTester.java
32 issues
Avoid throwing raw exception types.
Design

Line: 119

                      methods[i] = type.getMethod(methods[i].getName(), methods[i].getParameterTypes());
      } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
      }
    }
    return methods;
  }


            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 149

                    fail(method + " failed to throw exception as is.");
    } catch (InvocationTargetException e) {
      if (exception != e.getCause()) {
        throw new RuntimeException(e);
      }
    } catch (IllegalAccessException e) {
      throw new AssertionError(e);
    }
  }

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 227

                            "Return value of " + method + " not forwarded", returnValue, actualReturnValue);
        }
      } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
      } catch (InvocationTargetException e) {
        throw Throwables.propagate(e.getCause());
      }
      assertEquals("Failed to forward to " + method, 1, called.get());
    }

            

Reported by PMD.

Avoid using redundant field initializer for 'testsEquals'
Performance

Line: 60

              @GwtIncompatible
public final class ForwardingWrapperTester {

  private boolean testsEquals = false;

  /**
   * Asks for {@link Object#equals} and {@link Object#hashCode} to be tested. That is, forwarding
   * wrappers of equal instances should be equal.
   */

            

Reported by PMD.

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

Line: 60

              @GwtIncompatible
public final class ForwardingWrapperTester {

  private boolean testsEquals = false;

  /**
   * Asks for {@link Object#equals} and {@link Object#hashCode} to be tested. That is, forwarding
   * wrappers of equal instances should be equal.
   */

            

Reported by PMD.

The method 'testForwarding(Class, Function)' has a cyclomatic complexity of 11.
Design

Line: 76

                 * calls with parameters passed as is, return value returned as is, and exceptions propagated as
   * is.
   */
  public <T> void testForwarding(
      Class<T> interfaceType, Function<? super T, ? extends T> wrapperFunction) {
    checkNotNull(wrapperFunction);
    checkArgument(interfaceType.isInterface(), "%s isn't an interface", interfaceType);
    Method[] methods = getMostConcreteMethods(interfaceType);
    AccessibleObject.setAccessible(methods, true);

            

Reported by PMD.

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

Line: 76

                 * calls with parameters passed as is, return value returned as is, and exceptions propagated as
   * is.
   */
  public <T> void testForwarding(
      Class<T> interfaceType, Function<? super T, ? extends T> wrapperFunction) {
    checkNotNull(wrapperFunction);
    checkArgument(interfaceType.isInterface(), "%s isn't an interface", interfaceType);
    Method[] methods = getMostConcreteMethods(interfaceType);
    AccessibleObject.setAccessible(methods, true);

            

Reported by PMD.

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

Line: 91

                    }
      // The interface could be package-private or private.
      // filter out equals/hashCode/toString
      if (method.getName().equals("equals")
          && method.getParameterTypes().length == 1
          && method.getParameterTypes()[0] == Object.class) {
        continue;
      }
      if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0) {

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 91

                    }
      // The interface could be package-private or private.
      // filter out equals/hashCode/toString
      if (method.getName().equals("equals")
          && method.getParameterTypes().length == 1
          && method.getParameterTypes()[0] == Object.class) {
        continue;
      }
      if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0) {

            

Reported by PMD.

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

Line: 92

                    // The interface could be package-private or private.
      // filter out equals/hashCode/toString
      if (method.getName().equals("equals")
          && method.getParameterTypes().length == 1
          && method.getParameterTypes()[0] == Object.class) {
        continue;
      }
      if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0) {
        continue;

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/ForwardingConcurrentMapTest.java
31 issues
Field delegate has the same name as a method
Error

Line: 31

              public class ForwardingConcurrentMapTest extends TestCase {

  private static class TestMap extends ForwardingConcurrentMap<String, Integer> {
    final ConcurrentMap<String, Integer> delegate = new ConcurrentHashMap<>();

    @Override
    protected ConcurrentMap<String, Integer> delegate() {
      return delegate;
    }

            

Reported by PMD.

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

Line: 31

              public class ForwardingConcurrentMapTest extends TestCase {

  private static class TestMap extends ForwardingConcurrentMap<String, Integer> {
    final ConcurrentMap<String, Integer> delegate = new ConcurrentHashMap<>();

    @Override
    protected ConcurrentMap<String, Integer> delegate() {
      return delegate;
    }

            

Reported by PMD.

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

Line: 39

                  }
  }

  public void testPutIfAbsent() {
    TestMap map = new TestMap();
    map.put("foo", 1);
    assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
    assertEquals(Integer.valueOf(1), map.get("foo"));
    assertNull(map.putIfAbsent("bar", 3));

            

Reported by PMD.

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

Line: 39

                  }
  }

  public void testPutIfAbsent() {
    TestMap map = new TestMap();
    map.put("foo", 1);
    assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
    assertEquals(Integer.valueOf(1), map.get("foo"));
    assertNull(map.putIfAbsent("bar", 3));

            

Reported by PMD.

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

Line: 41

              
  public void testPutIfAbsent() {
    TestMap map = new TestMap();
    map.put("foo", 1);
    assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
    assertEquals(Integer.valueOf(1), map.get("foo"));
    assertNull(map.putIfAbsent("bar", 3));
    assertEquals(Integer.valueOf(3), map.get("bar"));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

                public void testPutIfAbsent() {
    TestMap map = new TestMap();
    map.put("foo", 1);
    assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
    assertEquals(Integer.valueOf(1), map.get("foo"));
    assertNull(map.putIfAbsent("bar", 3));
    assertEquals(Integer.valueOf(3), map.get("bar"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

                  TestMap map = new TestMap();
    map.put("foo", 1);
    assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
    assertEquals(Integer.valueOf(1), map.get("foo"));
    assertNull(map.putIfAbsent("bar", 3));
    assertEquals(Integer.valueOf(3), map.get("bar"));
  }

  public void testRemove() {

            

Reported by PMD.

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

Line: 44

                  map.put("foo", 1);
    assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
    assertEquals(Integer.valueOf(1), map.get("foo"));
    assertNull(map.putIfAbsent("bar", 3));
    assertEquals(Integer.valueOf(3), map.get("bar"));
  }

  public void testRemove() {
    TestMap map = new TestMap();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

                  map.put("foo", 1);
    assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
    assertEquals(Integer.valueOf(1), map.get("foo"));
    assertNull(map.putIfAbsent("bar", 3));
    assertEquals(Integer.valueOf(3), map.get("bar"));
  }

  public void testRemove() {
    TestMap map = new TestMap();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
    assertEquals(Integer.valueOf(1), map.get("foo"));
    assertNull(map.putIfAbsent("bar", 3));
    assertEquals(Integer.valueOf(3), map.get("bar"));
  }

  public void testRemove() {
    TestMap map = new TestMap();
    map.put("foo", 1);

            

Reported by PMD.

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

Line: 26

              
/** @author Gregory Kick */
@GwtCompatible
public class RegularImmutableTableTest extends AbstractImmutableTableTest {
  private static final ImmutableSet<Cell<Character, Integer, String>> CELLS =
      ImmutableSet.of(
          Tables.immutableCell('a', 1, "foo"),
          Tables.immutableCell('b', 1, "bar"),
          Tables.immutableCell('a', 2, "baz"));

            

Reported by PMD.

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

Line: 29

              public class RegularImmutableTableTest extends AbstractImmutableTableTest {
  private static final ImmutableSet<Cell<Character, Integer, String>> CELLS =
      ImmutableSet.of(
          Tables.immutableCell('a', 1, "foo"),
          Tables.immutableCell('b', 1, "bar"),
          Tables.immutableCell('a', 2, "baz"));

  private static final ImmutableSet<Character> ROW_SPACE = ImmutableSet.of('a', 'b');


            

Reported by PMD.

The String literal 'bar' appears 8 times in this file; the first occurrence is on line 30
Error

Line: 30

                private static final ImmutableSet<Cell<Character, Integer, String>> CELLS =
      ImmutableSet.of(
          Tables.immutableCell('a', 1, "foo"),
          Tables.immutableCell('b', 1, "bar"),
          Tables.immutableCell('a', 2, "baz"));

  private static final ImmutableSet<Character> ROW_SPACE = ImmutableSet.of('a', 'b');

  private static final ImmutableSet<Integer> COLUMN_SPACE = ImmutableSet.of(1, 2);

            

Reported by PMD.

The String literal 'baz' appears 8 times in this file; the first occurrence is on line 31
Error

Line: 31

                    ImmutableSet.of(
          Tables.immutableCell('a', 1, "foo"),
          Tables.immutableCell('b', 1, "bar"),
          Tables.immutableCell('a', 2, "baz"));

  private static final ImmutableSet<Character> ROW_SPACE = ImmutableSet.of('a', 'b');

  private static final ImmutableSet<Integer> COLUMN_SPACE = ImmutableSet.of(1, 2);


            

Reported by PMD.

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

Line: 48

                  return ImmutableList.<ImmutableTable<Character, Integer, String>>of(SPARSE, DENSE);
  }

  public void testCellSet() {
    for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {
      assertEquals(CELLS, testInstance.cellSet());
    }
  }


            

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

                  }
  }

  public void testValues() {
    for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {
      assertThat(testInstance.values()).containsExactly("foo", "bar", "baz").inOrder();
    }
  }


            

Reported by PMD.

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

Line: 56

              
  public void testValues() {
    for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {
      assertThat(testInstance.values()).containsExactly("foo", "bar", "baz").inOrder();
    }
  }

  public void testSize() {
    for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {

            

Reported by PMD.

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

Line: 56

              
  public void testValues() {
    for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {
      assertThat(testInstance.values()).containsExactly("foo", "bar", "baz").inOrder();
    }
  }

  public void testSize() {
    for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {

            

Reported by PMD.

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

Line: 60

                  }
  }

  public void testSize() {
    for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {
      assertEquals(3, testInstance.size());
    }
  }


            

Reported by PMD.

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

Line: 66

                  }
  }

  public void testContainsValue() {
    for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {
      assertTrue(testInstance.containsValue("foo"));
      assertTrue(testInstance.containsValue("bar"));
      assertTrue(testInstance.containsValue("baz"));
      assertFalse(testInstance.containsValue("blah"));

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/HashBasedTableTest.java
31 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 37

                @Override
  protected Table<String, Integer, Character> create(Object... data) {
    Table<String, Integer, Character> table = HashBasedTable.create();
    table.put("foo", 4, 'a');
    table.put("cat", 1, 'b');
    table.clear();
    populate(table, data);
    return table;
  }

            

Reported by PMD.

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

Line: 37

                @Override
  protected Table<String, Integer, Character> create(Object... data) {
    Table<String, Integer, Character> table = HashBasedTable.create();
    table.put("foo", 4, 'a');
    table.put("cat", 1, 'b');
    table.clear();
    populate(table, data);
    return table;
  }

            

Reported by PMD.

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

Line: 38

                protected Table<String, Integer, Character> create(Object... data) {
    Table<String, Integer, Character> table = HashBasedTable.create();
    table.put("foo", 4, 'a');
    table.put("cat", 1, 'b');
    table.clear();
    populate(table, data);
    return table;
  }


            

Reported by PMD.

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

Line: 39

                  Table<String, Integer, Character> table = HashBasedTable.create();
    table.put("foo", 4, 'a');
    table.put("cat", 1, 'b');
    table.clear();
    populate(table, data);
    return table;
  }

  public void testIterationOrder() {

            

Reported by PMD.

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

Line: 44

                  return table;
  }

  public void testIterationOrder() {
    Table<String, String, String> table = HashBasedTable.create();
    for (int i = 0; i < 5; i++) {
      table.put("r" + i, "c" + i, "v" + i);
    }
    assertThat(table.rowKeySet()).containsExactly("r0", "r1", "r2", "r3", "r4").inOrder();

            

Reported by PMD.

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

Line: 44

                  return table;
  }

  public void testIterationOrder() {
    Table<String, String, String> table = HashBasedTable.create();
    for (int i = 0; i < 5; i++) {
      table.put("r" + i, "c" + i, "v" + i);
    }
    assertThat(table.rowKeySet()).containsExactly("r0", "r1", "r2", "r3", "r4").inOrder();

            

Reported by PMD.

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

Line: 49

                  for (int i = 0; i < 5; i++) {
      table.put("r" + i, "c" + i, "v" + i);
    }
    assertThat(table.rowKeySet()).containsExactly("r0", "r1", "r2", "r3", "r4").inOrder();
    assertThat(table.columnKeySet()).containsExactly("c0", "c1", "c2", "c3", "c4").inOrder();
    assertThat(table.values()).containsExactly("v0", "v1", "v2", "v3", "v4").inOrder();
  }

  public void testCreateWithValidSizes() {

            

Reported by PMD.

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

Line: 49

                  for (int i = 0; i < 5; i++) {
      table.put("r" + i, "c" + i, "v" + i);
    }
    assertThat(table.rowKeySet()).containsExactly("r0", "r1", "r2", "r3", "r4").inOrder();
    assertThat(table.columnKeySet()).containsExactly("c0", "c1", "c2", "c3", "c4").inOrder();
    assertThat(table.values()).containsExactly("v0", "v1", "v2", "v3", "v4").inOrder();
  }

  public void testCreateWithValidSizes() {

            

Reported by PMD.

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

Line: 49

                  for (int i = 0; i < 5; i++) {
      table.put("r" + i, "c" + i, "v" + i);
    }
    assertThat(table.rowKeySet()).containsExactly("r0", "r1", "r2", "r3", "r4").inOrder();
    assertThat(table.columnKeySet()).containsExactly("c0", "c1", "c2", "c3", "c4").inOrder();
    assertThat(table.values()).containsExactly("v0", "v1", "v2", "v3", "v4").inOrder();
  }

  public void testCreateWithValidSizes() {

            

Reported by PMD.

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

Line: 50

                    table.put("r" + i, "c" + i, "v" + i);
    }
    assertThat(table.rowKeySet()).containsExactly("r0", "r1", "r2", "r3", "r4").inOrder();
    assertThat(table.columnKeySet()).containsExactly("c0", "c1", "c2", "c3", "c4").inOrder();
    assertThat(table.values()).containsExactly("v0", "v1", "v2", "v3", "v4").inOrder();
  }

  public void testCreateWithValidSizes() {
    Table<String, Integer, Character> table1 = HashBasedTable.create(100, 20);

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/MultisetElementSetTester.java
31 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: 45

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetElementSetTester<E> extends AbstractMultisetTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  public void testElementSetReflectsAddAbsent() {
    Set<E> elementSet = getMultiset().elementSet();
    assertFalse(elementSet.contains(e3()));
    getMultiset().add(e3(), 4);
    assertTrue(elementSet.contains(e3()));

            

Reported by PMD.

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

Line: 46

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetElementSetTester<E> extends AbstractMultisetTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  public void testElementSetReflectsAddAbsent() {
    Set<E> elementSet = getMultiset().elementSet();
    assertFalse(elementSet.contains(e3()));
    getMultiset().add(e3(), 4);
    assertTrue(elementSet.contains(e3()));
  }

            

Reported by PMD.

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

Line: 47

              public class MultisetElementSetTester<E> extends AbstractMultisetTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  public void testElementSetReflectsAddAbsent() {
    Set<E> elementSet = getMultiset().elementSet();
    assertFalse(elementSet.contains(e3()));
    getMultiset().add(e3(), 4);
    assertTrue(elementSet.contains(e3()));
  }


            

Reported by PMD.

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

Line: 48

                @CollectionFeature.Require(SUPPORTS_ADD)
  public void testElementSetReflectsAddAbsent() {
    Set<E> elementSet = getMultiset().elementSet();
    assertFalse(elementSet.contains(e3()));
    getMultiset().add(e3(), 4);
    assertTrue(elementSet.contains(e3()));
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.

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

Line: 49

                public void testElementSetReflectsAddAbsent() {
    Set<E> elementSet = getMultiset().elementSet();
    assertFalse(elementSet.contains(e3()));
    getMultiset().add(e3(), 4);
    assertTrue(elementSet.contains(e3()));
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

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

Line: 50

                  Set<E> elementSet = getMultiset().elementSet();
    assertFalse(elementSet.contains(e3()));
    getMultiset().add(e3(), 4);
    assertTrue(elementSet.contains(e3()));
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testElementSetReflectsRemove() {

            

Reported by PMD.

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

Line: 53

                  assertTrue(elementSet.contains(e3()));
  }

  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testElementSetReflectsRemove() {
    Set<E> elementSet = getMultiset().elementSet();
    assertTrue(elementSet.contains(e0()));
    getMultiset().removeAll(Collections.singleton(e0()));

            

Reported by PMD.

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

Line: 55

              
  @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testElementSetReflectsRemove() {
    Set<E> elementSet = getMultiset().elementSet();
    assertTrue(elementSet.contains(e0()));
    getMultiset().removeAll(Collections.singleton(e0()));
    assertFalse(elementSet.contains(e0()));
  }

            

Reported by PMD.

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

Line: 56

                @CollectionSize.Require(absent = ZERO)
  @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testElementSetReflectsRemove() {
    Set<E> elementSet = getMultiset().elementSet();
    assertTrue(elementSet.contains(e0()));
    getMultiset().removeAll(Collections.singleton(e0()));
    assertFalse(elementSet.contains(e0()));
  }


            

Reported by PMD.

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

Line: 57

                @CollectionFeature.Require(SUPPORTS_REMOVE)
  public void testElementSetReflectsRemove() {
    Set<E> elementSet = getMultiset().elementSet();
    assertTrue(elementSet.contains(e0()));
    getMultiset().removeAll(Collections.singleton(e0()));
    assertFalse(elementSet.contains(e0()));
  }

  @CollectionSize.Require(absent = ZERO)

            

Reported by PMD.