The following issues were found

android/guava/src/com/google/common/graph/AbstractNetwork.java
51 issues
The class 'AbstractNetwork' has a Standard Cyclomatic Complexity of 2 (Highest = 16).
Design

Line: 53

               */
@Beta
@ElementTypesAreNonnullByDefault
public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override

            

Reported by PMD.

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

Line: 53

               */
@Beta
@ElementTypesAreNonnullByDefault
public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override

            

Reported by PMD.

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

Line: 53

               */
@Beta
@ElementTypesAreNonnullByDefault
public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override

            

Reported by PMD.

The method 'asGraph' has a Modified Cyclomatic Complexity of 16.
Design

Line: 56

              public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override
      public Set<N> nodes() {
        return AbstractNetwork.this.nodes();
      }

            

Reported by PMD.

The method 'asGraph' has a Standard Cyclomatic Complexity of 16.
Design

Line: 56

              public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override
      public Set<N> nodes() {
        return AbstractNetwork.this.nodes();
      }

            

Reported by PMD.

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

Line: 60

                  return new AbstractGraph<N>() {
      @Override
      public Set<N> nodes() {
        return AbstractNetwork.this.nodes();
      }

      @Override
      public Set<EndpointPair<N>> edges() {
        if (allowsParallelEdges()) {

            

Reported by PMD.

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

Line: 60

                  return new AbstractGraph<N>() {
      @Override
      public Set<N> nodes() {
        return AbstractNetwork.this.nodes();
      }

      @Override
      public Set<EndpointPair<N>> edges() {
        if (allowsParallelEdges()) {

            

Reported by PMD.

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

Line: 74

                        @Override
          public Iterator<EndpointPair<N>> iterator() {
            return Iterators.transform(
                AbstractNetwork.this.edges().iterator(),
                new Function<E, EndpointPair<N>>() {
                  @Override
                  public EndpointPair<N> apply(E edge) {
                    return incidentNodes(edge);
                  }

            

Reported by PMD.

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

Line: 74

                        @Override
          public Iterator<EndpointPair<N>> iterator() {
            return Iterators.transform(
                AbstractNetwork.this.edges().iterator(),
                new Function<E, EndpointPair<N>>() {
                  @Override
                  public EndpointPair<N> apply(E edge) {
                    return incidentNodes(edge);
                  }

            

Reported by PMD.

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

Line: 74

                        @Override
          public Iterator<EndpointPair<N>> iterator() {
            return Iterators.transform(
                AbstractNetwork.this.edges().iterator(),
                new Function<E, EndpointPair<N>>() {
                  @Override
                  public EndpointPair<N> apply(E edge) {
                    return incidentNodes(edge);
                  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java
51 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: 39

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

  @GwtIncompatible // doesn't build without explicit type parameters on build() methods
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();

            

Reported by PMD.

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

Line: 40

              public class MultimapBuilderTest extends TestCase {

  @GwtIncompatible // doesn't build without explicit type parameters on build() methods
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }

            

Reported by PMD.

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

Line: 41

              
  @GwtIncompatible // doesn't build without explicit type parameters on build() methods
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }


            

Reported by PMD.

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

Line: 41

              
  @GwtIncompatible // doesn't build without explicit type parameters on build() methods
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }


            

Reported by PMD.

Avoid unused local variables such as 'a'.
Design

Line: 41

              
  @GwtIncompatible // doesn't build without explicit type parameters on build() methods
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }


            

Reported by PMD.

Avoid unused local variables such as 'b'.
Design

Line: 42

                @GwtIncompatible // doesn't build without explicit type parameters on build() methods
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }

  public void testGenerics_gwtCompatible() {

            

Reported by PMD.

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

Line: 42

                @GwtIncompatible // doesn't build without explicit type parameters on build() methods
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }

  public void testGenerics_gwtCompatible() {

            

Reported by PMD.

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

Line: 42

                @GwtIncompatible // doesn't build without explicit type parameters on build() methods
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }

  public void testGenerics_gwtCompatible() {

            

Reported by PMD.

Avoid unused local variables such as 'c'.
Design

Line: 43

                public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }

  public void testGenerics_gwtCompatible() {
    ListMultimap<String, Integer> a =

            

Reported by PMD.

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

Line: 44

                  ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
    SetMultimap<String, Integer> c =
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }

  public void testGenerics_gwtCompatible() {
    ListMultimap<String, Integer> a =
        MultimapBuilder.hashKeys().arrayListValues().<String, Integer>build();

            

Reported by PMD.

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

Line: 46

               */
@GwtIncompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {

  private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;

            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {

  private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;
  private E c;


            

Reported by PMD.

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

Line: 49

              public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {

  private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;
  private E c;

  @Override

            

Reported by PMD.

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

Line: 50

              
  private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;
  private E c;

  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 51

                private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;
  private E c;

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

            

Reported by PMD.

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

Line: 52

                private List<E> values;
  private E a;
  private E b;
  private E c;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    navigableSet = (NavigableSet<E>) getSet();

            

Reported by PMD.

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

Line: 54

                private E b;
  private E c;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    navigableSet = (NavigableSet<E>) getSet();
    values =
        Helpers.copyToList(

            

Reported by PMD.

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

Line: 60

                  navigableSet = (NavigableSet<E>) getSet();
    values =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(values, navigableSet.comparator());

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

            

Reported by PMD.

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

Line: 61

                  values =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(values, navigableSet.comparator());

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

            

Reported by PMD.

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

Line: 61

                  values =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(values, navigableSet.comparator());

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

            

Reported by PMD.

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

Line: 46

               */
@GwtIncompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {

  private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;

            

Reported by PMD.

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

Line: 48

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {

  private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;
  private E c;


            

Reported by PMD.

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

Line: 49

              public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {

  private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;
  private E c;

  @Override

            

Reported by PMD.

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

Line: 50

              
  private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;
  private E c;

  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 51

                private NavigableSet<E> navigableSet;
  private List<E> values;
  private E a;
  private E b;
  private E c;

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

            

Reported by PMD.

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

Line: 52

                private List<E> values;
  private E a;
  private E b;
  private E c;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    navigableSet = (NavigableSet<E>) getSet();

            

Reported by PMD.

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

Line: 54

                private E b;
  private E c;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    navigableSet = (NavigableSet<E>) getSet();
    values =
        Helpers.copyToList(

            

Reported by PMD.

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

Line: 60

                  navigableSet = (NavigableSet<E>) getSet();
    values =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(values, navigableSet.comparator());

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

            

Reported by PMD.

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

Line: 61

                  values =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(values, navigableSet.comparator());

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

            

Reported by PMD.

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

Line: 61

                  values =
        Helpers.copyToList(
            getSubjectGenerator()
                .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
    Collections.sort(values, navigableSet.comparator());

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

            

Reported by PMD.

guava-tests/test/com/google/common/base/AbstractIteratorTest.java
51 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 35

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

  public void testDefaultBehaviorOfNextAndHasNext() {

    // This sample AbstractIterator returns 0 on the first call, 1 on the
    // second, then signals that it's reached the end of the data
    Iterator<Integer> iter =
        new AbstractIterator<Integer>() {

            

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

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

  public void testDefaultBehaviorOfNextAndHasNext() {

    // This sample AbstractIterator returns 0 on the first call, 1 on the
    // second, then signals that it's reached the end of the data
    Iterator<Integer> iter =
        new AbstractIterator<Integer>() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 59

                        }
        };

    assertTrue(iter.hasNext());
    assertEquals(0, (int) iter.next());

    // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 60

                      };

    assertTrue(iter.hasNext());
    assertEquals(0, (int) iter.next());

    // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                  assertEquals(0, (int) iter.next());

    // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 64

              
    // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 65

                  // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());

    // Make sure computeNext() doesn't get invoked again

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 66

                  assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());

    // Make sure computeNext() doesn't get invoked again
    assertFalse(iter.hasNext());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 68

                  assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());

    // Make sure computeNext() doesn't get invoked again
    assertFalse(iter.hasNext());

    try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 71

                  assertFalse(iter.hasNext());

    // Make sure computeNext() doesn't get invoked again
    assertFalse(iter.hasNext());

    try {
      iter.next();
      fail("no exception thrown");
    } catch (NoSuchElementException expected) {

            

Reported by PMD.

guava-tests/test/com/google/common/hash/HashingInputStreamTest.java
51 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

               * @author Qian Huang
 */
public class HashingInputStreamTest extends TestCase {
  private Hasher hasher;
  private HashFunction hashFunction;
  private static final byte[] testBytes = new byte[] {'y', 'a', 'm', 's'};
  private ByteArrayInputStream buffer;

  @SuppressWarnings("DoNotMock")

            

Reported by PMD.

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

Line: 34

               */
public class HashingInputStreamTest extends TestCase {
  private Hasher hasher;
  private HashFunction hashFunction;
  private static final byte[] testBytes = new byte[] {'y', 'a', 'm', 's'};
  private ByteArrayInputStream buffer;

  @SuppressWarnings("DoNotMock")
  @Override

            

Reported by PMD.

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

Line: 36

                private Hasher hasher;
  private HashFunction hashFunction;
  private static final byte[] testBytes = new byte[] {'y', 'a', 'm', 's'};
  private ByteArrayInputStream buffer;

  @SuppressWarnings("DoNotMock")
  @Override
  protected void setUp() throws Exception {
    super.setUp();

            

Reported by PMD.

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

Line: 38

                private static final byte[] testBytes = new byte[] {'y', 'a', 'm', 's'};
  private ByteArrayInputStream buffer;

  @SuppressWarnings("DoNotMock")
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    hasher = mock(Hasher.class);
    hashFunction = mock(HashFunction.class);

            

Reported by PMD.

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

Line: 46

                  hashFunction = mock(HashFunction.class);
    buffer = new ByteArrayInputStream(testBytes);

    when(hashFunction.newHasher()).thenReturn(hasher);
  }

  public void testRead_putSingleByte() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);


            

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

                  when(hashFunction.newHasher()).thenReturn(hasher);
  }

  public void testRead_putSingleByte() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);

    int b = in.read();
    assertEquals('y', b);


            

Reported by PMD.

Ensure that resources like this HashingInputStream object are closed after use
Error

Line: 50

                }

  public void testRead_putSingleByte() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);

    int b = in.read();
    assertEquals('y', b);

    verify(hasher).putByte((byte) 'y');

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                  HashingInputStream in = new HashingInputStream(hashFunction, buffer);

    int b = in.read();
    assertEquals('y', b);

    verify(hasher).putByte((byte) 'y');
    verify(hashFunction).newHasher();
    verifyNoMoreInteractions(hashFunction, hasher);
  }

            

Reported by PMD.

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

Line: 56

                  assertEquals('y', b);

    verify(hasher).putByte((byte) 'y');
    verify(hashFunction).newHasher();
    verifyNoMoreInteractions(hashFunction, hasher);
  }

  public void testRead_putByteArray() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);

            

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

                  verifyNoMoreInteractions(hashFunction, hasher);
  }

  public void testRead_putByteArray() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);

    byte[] buf = new byte[4];
    int numOfByteRead = in.read(buf, 0, buf.length);
    assertEquals(4, numOfByteRead);

            

Reported by PMD.

guava/src/com/google/common/graph/AbstractNetwork.java
51 issues
The class 'AbstractNetwork' has a Modified Cyclomatic Complexity of 2 (Highest = 16).
Design

Line: 54

               */
@Beta
@ElementTypesAreNonnullByDefault
public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override

            

Reported by PMD.

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

Line: 54

               */
@Beta
@ElementTypesAreNonnullByDefault
public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override

            

Reported by PMD.

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

Line: 54

               */
@Beta
@ElementTypesAreNonnullByDefault
public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override

            

Reported by PMD.

The method 'asGraph' has a Modified Cyclomatic Complexity of 16.
Design

Line: 57

              public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override
      public Set<N> nodes() {
        return AbstractNetwork.this.nodes();
      }

            

Reported by PMD.

The method 'asGraph' has a Standard Cyclomatic Complexity of 16.
Design

Line: 57

              public abstract class AbstractNetwork<N, E> implements Network<N, E> {

  @Override
  public Graph<N> asGraph() {
    return new AbstractGraph<N>() {
      @Override
      public Set<N> nodes() {
        return AbstractNetwork.this.nodes();
      }

            

Reported by PMD.

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

Line: 61

                  return new AbstractGraph<N>() {
      @Override
      public Set<N> nodes() {
        return AbstractNetwork.this.nodes();
      }

      @Override
      public Set<EndpointPair<N>> edges() {
        if (allowsParallelEdges()) {

            

Reported by PMD.

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

Line: 61

                  return new AbstractGraph<N>() {
      @Override
      public Set<N> nodes() {
        return AbstractNetwork.this.nodes();
      }

      @Override
      public Set<EndpointPair<N>> edges() {
        if (allowsParallelEdges()) {

            

Reported by PMD.

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

Line: 75

                        @Override
          public Iterator<EndpointPair<N>> iterator() {
            return Iterators.transform(
                AbstractNetwork.this.edges().iterator(),
                new Function<E, EndpointPair<N>>() {
                  @Override
                  public EndpointPair<N> apply(E edge) {
                    return incidentNodes(edge);
                  }

            

Reported by PMD.

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

Line: 75

                        @Override
          public Iterator<EndpointPair<N>> iterator() {
            return Iterators.transform(
                AbstractNetwork.this.edges().iterator(),
                new Function<E, EndpointPair<N>>() {
                  @Override
                  public EndpointPair<N> apply(E edge) {
                    return incidentNodes(edge);
                  }

            

Reported by PMD.

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

Line: 75

                        @Override
          public Iterator<EndpointPair<N>> iterator() {
            return Iterators.transform(
                AbstractNetwork.this.edges().iterator(),
                new Function<E, EndpointPair<N>>() {
                  @Override
                  public EndpointPair<N> apply(E edge) {
                    return incidentNodes(edge);
                  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java
51 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 35

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

  public void testDefaultBehaviorOfNextAndHasNext() {

    // This sample AbstractIterator returns 0 on the first call, 1 on the
    // second, then signals that it's reached the end of the data
    Iterator<Integer> iter =
        new AbstractIterator<Integer>() {

            

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

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

  public void testDefaultBehaviorOfNextAndHasNext() {

    // This sample AbstractIterator returns 0 on the first call, 1 on the
    // second, then signals that it's reached the end of the data
    Iterator<Integer> iter =
        new AbstractIterator<Integer>() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 59

                        }
        };

    assertTrue(iter.hasNext());
    assertEquals(0, (int) iter.next());

    // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 60

                      };

    assertTrue(iter.hasNext());
    assertEquals(0, (int) iter.next());

    // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

                  assertEquals(0, (int) iter.next());

    // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 64

              
    // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 65

                  // verify idempotence of hasNext()
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());

    // Make sure computeNext() doesn't get invoked again

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 66

                  assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());

    // Make sure computeNext() doesn't get invoked again
    assertFalse(iter.hasNext());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 68

                  assertTrue(iter.hasNext());
    assertEquals(1, (int) iter.next());

    assertFalse(iter.hasNext());

    // Make sure computeNext() doesn't get invoked again
    assertFalse(iter.hasNext());

    try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 71

                  assertFalse(iter.hasNext());

    // Make sure computeNext() doesn't get invoked again
    assertFalse(iter.hasNext());

    try {
      iter.next();
      fail("no exception thrown");
    } catch (NoSuchElementException expected) {

            

Reported by PMD.

android/guava-tests/test/com/google/common/hash/HashingInputStreamTest.java
51 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

               * @author Qian Huang
 */
public class HashingInputStreamTest extends TestCase {
  private Hasher hasher;
  private HashFunction hashFunction;
  private static final byte[] testBytes = new byte[] {'y', 'a', 'm', 's'};
  private ByteArrayInputStream buffer;

  @SuppressWarnings("DoNotMock")

            

Reported by PMD.

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

Line: 34

               */
public class HashingInputStreamTest extends TestCase {
  private Hasher hasher;
  private HashFunction hashFunction;
  private static final byte[] testBytes = new byte[] {'y', 'a', 'm', 's'};
  private ByteArrayInputStream buffer;

  @SuppressWarnings("DoNotMock")
  @Override

            

Reported by PMD.

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

Line: 36

                private Hasher hasher;
  private HashFunction hashFunction;
  private static final byte[] testBytes = new byte[] {'y', 'a', 'm', 's'};
  private ByteArrayInputStream buffer;

  @SuppressWarnings("DoNotMock")
  @Override
  protected void setUp() throws Exception {
    super.setUp();

            

Reported by PMD.

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

Line: 38

                private static final byte[] testBytes = new byte[] {'y', 'a', 'm', 's'};
  private ByteArrayInputStream buffer;

  @SuppressWarnings("DoNotMock")
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    hasher = mock(Hasher.class);
    hashFunction = mock(HashFunction.class);

            

Reported by PMD.

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

Line: 46

                  hashFunction = mock(HashFunction.class);
    buffer = new ByteArrayInputStream(testBytes);

    when(hashFunction.newHasher()).thenReturn(hasher);
  }

  public void testRead_putSingleByte() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);


            

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

                  when(hashFunction.newHasher()).thenReturn(hasher);
  }

  public void testRead_putSingleByte() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);

    int b = in.read();
    assertEquals('y', b);


            

Reported by PMD.

Ensure that resources like this HashingInputStream object are closed after use
Error

Line: 50

                }

  public void testRead_putSingleByte() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);

    int b = in.read();
    assertEquals('y', b);

    verify(hasher).putByte((byte) 'y');

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                  HashingInputStream in = new HashingInputStream(hashFunction, buffer);

    int b = in.read();
    assertEquals('y', b);

    verify(hasher).putByte((byte) 'y');
    verify(hashFunction).newHasher();
    verifyNoMoreInteractions(hashFunction, hasher);
  }

            

Reported by PMD.

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

Line: 56

                  assertEquals('y', b);

    verify(hasher).putByte((byte) 'y');
    verify(hashFunction).newHasher();
    verifyNoMoreInteractions(hashFunction, hasher);
  }

  public void testRead_putByteArray() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);

            

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

                  verifyNoMoreInteractions(hashFunction, hasher);
  }

  public void testRead_putByteArray() throws Exception {
    HashingInputStream in = new HashingInputStream(hashFunction, buffer);

    byte[] buf = new byte[4];
    int numOfByteRead = in.read(buf, 0, buf.length);
    assertEquals(4, numOfByteRead);

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
50 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: 39

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

  public void testBuilder_withImmutableEntry() {
    ImmutableMultimap<String, Integer> multimap =
        new Builder<String, Integer>().put(Maps.immutableEntry("one", 1)).build();
    assertEquals(Arrays.asList(1), multimap.get("one"));
  }


            

Reported by PMD.

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

Line: 41

              
  public void testBuilder_withImmutableEntry() {
    ImmutableMultimap<String, Integer> multimap =
        new Builder<String, Integer>().put(Maps.immutableEntry("one", 1)).build();
    assertEquals(Arrays.asList(1), multimap.get("one"));
  }

  public void testBuilder_withImmutableEntryAndNullContents() {
    Builder<String, Integer> builder = new Builder<>();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

                public void testBuilder_withImmutableEntry() {
    ImmutableMultimap<String, Integer> multimap =
        new Builder<String, Integer>().put(Maps.immutableEntry("one", 1)).build();
    assertEquals(Arrays.asList(1), multimap.get("one"));
  }

  public void testBuilder_withImmutableEntryAndNullContents() {
    Builder<String, Integer> builder = new Builder<>();
    try {

            

Reported by PMD.

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

Line: 45

                  assertEquals(Arrays.asList(1), multimap.get("one"));
  }

  public void testBuilder_withImmutableEntryAndNullContents() {
    Builder<String, Integer> builder = new Builder<>();
    try {
      builder.put(Maps.immutableEntry("one", (Integer) null));
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                  Builder<String, Integer> builder = new Builder<>();
    try {
      builder.put(Maps.immutableEntry("one", (Integer) null));
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      builder.put(Maps.immutableEntry((String) null, 1));
      fail();

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 49

                  Builder<String, Integer> builder = new Builder<>();
    try {
      builder.put(Maps.immutableEntry("one", (Integer) null));
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      builder.put(Maps.immutableEntry((String) null, 1));
      fail();

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 50

                  try {
      builder.put(Maps.immutableEntry("one", (Integer) null));
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      builder.put(Maps.immutableEntry((String) null, 1));
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

Avoid catching NullPointerException; consider removing the cause of the NPE.
Error

Line: 50

                  try {
      builder.put(Maps.immutableEntry("one", (Integer) null));
      fail();
    } catch (NullPointerException expected) {
    }
    try {
      builder.put(Maps.immutableEntry((String) null, 1));
      fail();
    } catch (NullPointerException expected) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 54

                  }
    try {
      builder.put(Maps.immutableEntry((String) null, 1));
      fail();
    } catch (NullPointerException expected) {
    }
  }

  private static class StringHolder {

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 54

                  }
    try {
      builder.put(Maps.immutableEntry((String) null, 1));
      fail();
    } catch (NullPointerException expected) {
    }
  }

  private static class StringHolder {

            

Reported by PMD.