The following issues were found

android/guava/src/com/google/common/collect/ImmutableTable.java
22 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 45

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
    implements Serializable {

  /**
   * Returns an empty immutable table.
   *

            

Reported by PMD.

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

Line: 46

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
    implements Serializable {

  /**
   * Returns an empty immutable table.
   *
   * <p><b>Performance note:</b> the instance returned is a singleton.

            

Reported by PMD.

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

Line: 143

                 */
  @DoNotMock
  public static final class Builder<R, C, V> {
    private final List<Cell<R, C, V>> cells = Lists.newArrayList();
    @CheckForNull private Comparator<? super R> rowComparator;
    @CheckForNull private Comparator<? super C> columnComparator;

    /**
     * Creates a new builder. The returned builder is equivalent to the builder generated by {@link

            

Reported by PMD.

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

Line: 144

                @DoNotMock
  public static final class Builder<R, C, V> {
    private final List<Cell<R, C, V>> cells = Lists.newArrayList();
    @CheckForNull private Comparator<? super R> rowComparator;
    @CheckForNull private Comparator<? super C> columnComparator;

    /**
     * Creates a new builder. The returned builder is equivalent to the builder generated by {@link
     * ImmutableTable#builder}.

            

Reported by PMD.

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

Line: 145

                public static final class Builder<R, C, V> {
    private final List<Cell<R, C, V>> cells = Lists.newArrayList();
    @CheckForNull private Comparator<? super R> rowComparator;
    @CheckForNull private Comparator<? super C> columnComparator;

    /**
     * Creates a new builder. The returned builder is equivalent to the builder generated by {@link
     * ImmutableTable#builder}.
     */

            

Reported by PMD.

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

Line: 271

                public ImmutableMap<R, V> column(C columnKey) {
    checkNotNull(columnKey, "columnKey");
    return MoreObjects.firstNonNull(
        (ImmutableMap<R, V>) columnMap().get(columnKey), ImmutableMap.<R, V>of());
  }

  @Override
  public ImmutableSet<C> columnKeySet() {
    return columnMap().keySet();

            

Reported by PMD.

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

Line: 276

              
  @Override
  public ImmutableSet<C> columnKeySet() {
    return columnMap().keySet();
  }

  /**
   * {@inheritDoc}
   *

            

Reported by PMD.

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

Line: 297

                public ImmutableMap<C, V> row(R rowKey) {
    checkNotNull(rowKey, "rowKey");
    return MoreObjects.firstNonNull(
        (ImmutableMap<C, V>) rowMap().get(rowKey), ImmutableMap.<C, V>of());
  }

  @Override
  public ImmutableSet<R> rowKeySet() {
    return rowMap().keySet();

            

Reported by PMD.

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

Line: 302

              
  @Override
  public ImmutableSet<R> rowKeySet() {
    return rowMap().keySet();
  }

  /**
   * {@inheritDoc}
   *

            

Reported by PMD.

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

Line: 321

              
  @Override
  public boolean containsValue(@CheckForNull Object value) {
    return values().contains(value);
  }

  /**
   * Guaranteed to throw an exception and leave the table unmodified.
   *

            

Reported by PMD.

guava/src/com/google/common/hash/Murmur3_128HashFunction.java
22 issues
Avoid reassigning parameters such as 'k'
Design

Line: 191

                            .array());
    }

    private static long fmix64(long k) {
      k ^= k >>> 33;
      k *= 0xff51afd7ed558ccdL;
      k ^= k >>> 33;
      k *= 0xc4ceb9fe1a85ec53L;
      k ^= k >>> 33;

            

Reported by PMD.

Avoid reassigning parameters such as 'k'
Design

Line: 191

                            .array());
    }

    private static long fmix64(long k) {
      k ^= k >>> 33;
      k *= 0xff51afd7ed558ccdL;
      k ^= k >>> 33;
      k *= 0xc4ceb9fe1a85ec53L;
      k ^= k >>> 33;

            

Reported by PMD.

Avoid reassigning parameters such as 'k'
Design

Line: 191

                            .array());
    }

    private static long fmix64(long k) {
      k ^= k >>> 33;
      k *= 0xff51afd7ed558ccdL;
      k ^= k >>> 33;
      k *= 0xc4ceb9fe1a85ec53L;
      k ^= k >>> 33;

            

Reported by PMD.

Avoid reassigning parameters such as 'k'
Design

Line: 191

                            .array());
    }

    private static long fmix64(long k) {
      k ^= k >>> 33;
      k *= 0xff51afd7ed558ccdL;
      k ^= k >>> 33;
      k *= 0xc4ceb9fe1a85ec53L;
      k ^= k >>> 33;

            

Reported by PMD.

Avoid reassigning parameters such as 'k'
Design

Line: 191

                            .array());
    }

    private static long fmix64(long k) {
      k ^= k >>> 33;
      k *= 0xff51afd7ed558ccdL;
      k ^= k >>> 33;
      k *= 0xc4ceb9fe1a85ec53L;
      k ^= k >>> 33;

            

Reported by PMD.

Avoid reassigning parameters such as 'k1'
Design

Line: 200

                    return k;
    }

    private static long mixK1(long k1) {
      k1 *= C1;
      k1 = Long.rotateLeft(k1, 31);
      k1 *= C2;
      return k1;
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'k1'
Design

Line: 200

                    return k;
    }

    private static long mixK1(long k1) {
      k1 *= C1;
      k1 = Long.rotateLeft(k1, 31);
      k1 *= C2;
      return k1;
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'k1'
Design

Line: 200

                    return k;
    }

    private static long mixK1(long k1) {
      k1 *= C1;
      k1 = Long.rotateLeft(k1, 31);
      k1 *= C2;
      return k1;
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'k2'
Design

Line: 207

                    return k1;
    }

    private static long mixK2(long k2) {
      k2 *= C2;
      k2 = Long.rotateLeft(k2, 33);
      k2 *= C1;
      return k2;
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'k2'
Design

Line: 207

                    return k1;
    }

    private static long mixK2(long k2) {
      k2 *= C2;
      k2 = Long.rotateLeft(k2, 33);
      k2 *= C1;
      return k2;
    }

            

Reported by PMD.

guava/src/com/google/common/collect/ForwardingTable.java
22 issues
This class has too many methods, consider refactoring it.
Design

Line: 39

              @ElementTypesAreNonnullByDefault
public abstract class ForwardingTable<
        R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
    extends ForwardingObject implements Table<R, C, V> {
  /** Constructor for use by subclasses. */
  protected ForwardingTable() {}

  @Override
  protected abstract Table<R, C, V> delegate();

            

Reported by PMD.

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

Line: 48

              
  @Override
  public Set<Cell<R, C, V>> cellSet() {
    return delegate().cellSet();
  }

  @Override
  public void clear() {
    delegate().clear();

            

Reported by PMD.

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

Line: 53

              
  @Override
  public void clear() {
    delegate().clear();
  }

  @Override
  public Map<R, V> column(@ParametricNullness C columnKey) {
    return delegate().column(columnKey);

            

Reported by PMD.

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

Line: 58

              
  @Override
  public Map<R, V> column(@ParametricNullness C columnKey) {
    return delegate().column(columnKey);
  }

  @Override
  public Set<C> columnKeySet() {
    return delegate().columnKeySet();

            

Reported by PMD.

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

Line: 63

              
  @Override
  public Set<C> columnKeySet() {
    return delegate().columnKeySet();
  }

  @Override
  public Map<C, Map<R, V>> columnMap() {
    return delegate().columnMap();

            

Reported by PMD.

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

Line: 68

              
  @Override
  public Map<C, Map<R, V>> columnMap() {
    return delegate().columnMap();
  }

  @Override
  public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
    return delegate().contains(rowKey, columnKey);

            

Reported by PMD.

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

Line: 73

              
  @Override
  public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
    return delegate().contains(rowKey, columnKey);
  }

  @Override
  public boolean containsColumn(@CheckForNull Object columnKey) {
    return delegate().containsColumn(columnKey);

            

Reported by PMD.

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

Line: 78

              
  @Override
  public boolean containsColumn(@CheckForNull Object columnKey) {
    return delegate().containsColumn(columnKey);
  }

  @Override
  public boolean containsRow(@CheckForNull Object rowKey) {
    return delegate().containsRow(rowKey);

            

Reported by PMD.

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

Line: 83

              
  @Override
  public boolean containsRow(@CheckForNull Object rowKey) {
    return delegate().containsRow(rowKey);
  }

  @Override
  public boolean containsValue(@CheckForNull Object value) {
    return delegate().containsValue(value);

            

Reported by PMD.

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

Line: 88

              
  @Override
  public boolean containsValue(@CheckForNull Object value) {
    return delegate().containsValue(value);
  }

  @Override
  @CheckForNull
  public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {

            

Reported by PMD.

guava/src/com/google/common/collect/ImmutableTable.java
22 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 50

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
    implements Serializable {

  /**
   * Returns a {@code Collector} that accumulates elements into an {@code ImmutableTable}. Each
   * input element is mapped to one cell in the returned table, with the rows, columns, and values

            

Reported by PMD.

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

Line: 51

              @GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
    implements Serializable {

  /**
   * Returns a {@code Collector} that accumulates elements into an {@code ImmutableTable}. Each
   * input element is mapped to one cell in the returned table, with the rows, columns, and values
   * generated by applying the specified functions.

            

Reported by PMD.

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

Line: 187

                 */
  @DoNotMock
  public static final class Builder<R, C, V> {
    private final List<Cell<R, C, V>> cells = Lists.newArrayList();
    @CheckForNull private Comparator<? super R> rowComparator;
    @CheckForNull private Comparator<? super C> columnComparator;

    /**
     * Creates a new builder. The returned builder is equivalent to the builder generated by {@link

            

Reported by PMD.

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

Line: 188

                @DoNotMock
  public static final class Builder<R, C, V> {
    private final List<Cell<R, C, V>> cells = Lists.newArrayList();
    @CheckForNull private Comparator<? super R> rowComparator;
    @CheckForNull private Comparator<? super C> columnComparator;

    /**
     * Creates a new builder. The returned builder is equivalent to the builder generated by {@link
     * ImmutableTable#builder}.

            

Reported by PMD.

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

Line: 189

                public static final class Builder<R, C, V> {
    private final List<Cell<R, C, V>> cells = Lists.newArrayList();
    @CheckForNull private Comparator<? super R> rowComparator;
    @CheckForNull private Comparator<? super C> columnComparator;

    /**
     * Creates a new builder. The returned builder is equivalent to the builder generated by {@link
     * ImmutableTable#builder}.
     */

            

Reported by PMD.

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

Line: 320

                public ImmutableMap<R, V> column(C columnKey) {
    checkNotNull(columnKey, "columnKey");
    return MoreObjects.firstNonNull(
        (ImmutableMap<R, V>) columnMap().get(columnKey), ImmutableMap.<R, V>of());
  }

  @Override
  public ImmutableSet<C> columnKeySet() {
    return columnMap().keySet();

            

Reported by PMD.

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

Line: 325

              
  @Override
  public ImmutableSet<C> columnKeySet() {
    return columnMap().keySet();
  }

  /**
   * {@inheritDoc}
   *

            

Reported by PMD.

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

Line: 346

                public ImmutableMap<C, V> row(R rowKey) {
    checkNotNull(rowKey, "rowKey");
    return MoreObjects.firstNonNull(
        (ImmutableMap<C, V>) rowMap().get(rowKey), ImmutableMap.<C, V>of());
  }

  @Override
  public ImmutableSet<R> rowKeySet() {
    return rowMap().keySet();

            

Reported by PMD.

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

Line: 351

              
  @Override
  public ImmutableSet<R> rowKeySet() {
    return rowMap().keySet();
  }

  /**
   * {@inheritDoc}
   *

            

Reported by PMD.

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

Line: 370

              
  @Override
  public boolean containsValue(@CheckForNull Object value) {
    return values().contains(value);
  }

  /**
   * Guaranteed to throw an exception and leave the table unmodified.
   *

            

Reported by PMD.

guava-tests/test/com/google/common/base/CharsetsTest.java
22 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: 33

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

  @GwtIncompatible // Non-UTF-8 Charset
  public void testUsAscii() {
    assertEquals(Charset.forName("US-ASCII"), Charsets.US_ASCII);
  }

  @GwtIncompatible // Non-UTF-8 Charset

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

              
  @GwtIncompatible // Non-UTF-8 Charset
  public void testUsAscii() {
    assertEquals(Charset.forName("US-ASCII"), Charsets.US_ASCII);
  }

  @GwtIncompatible // Non-UTF-8 Charset
  public void testIso88591() {
    assertEquals(Charset.forName("ISO-8859-1"), Charsets.ISO_8859_1);

            

Reported by PMD.

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

Line: 38

                  assertEquals(Charset.forName("US-ASCII"), Charsets.US_ASCII);
  }

  @GwtIncompatible // Non-UTF-8 Charset
  public void testIso88591() {
    assertEquals(Charset.forName("ISO-8859-1"), Charsets.ISO_8859_1);
  }

  public void testUtf8() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

              
  @GwtIncompatible // Non-UTF-8 Charset
  public void testIso88591() {
    assertEquals(Charset.forName("ISO-8859-1"), Charsets.ISO_8859_1);
  }

  public void testUtf8() {
    assertEquals(Charset.forName("UTF-8"), Charsets.UTF_8);
  }

            

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

                  assertEquals(Charset.forName("ISO-8859-1"), Charsets.ISO_8859_1);
  }

  public void testUtf8() {
    assertEquals(Charset.forName("UTF-8"), Charsets.UTF_8);
  }

  @GwtIncompatible // Non-UTF-8 Charset
  public void testUtf16be() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

                }

  public void testUtf8() {
    assertEquals(Charset.forName("UTF-8"), Charsets.UTF_8);
  }

  @GwtIncompatible // Non-UTF-8 Charset
  public void testUtf16be() {
    assertEquals(Charset.forName("UTF-16BE"), Charsets.UTF_16BE);

            

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

                  assertEquals(Charset.forName("UTF-8"), Charsets.UTF_8);
  }

  @GwtIncompatible // Non-UTF-8 Charset
  public void testUtf16be() {
    assertEquals(Charset.forName("UTF-16BE"), Charsets.UTF_16BE);
  }

  @GwtIncompatible // Non-UTF-8 Charset

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

              
  @GwtIncompatible // Non-UTF-8 Charset
  public void testUtf16be() {
    assertEquals(Charset.forName("UTF-16BE"), Charsets.UTF_16BE);
  }

  @GwtIncompatible // Non-UTF-8 Charset
  public void testUtf16le() {
    assertEquals(Charset.forName("UTF-16LE"), Charsets.UTF_16LE);

            

Reported by PMD.

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

Line: 52

                  assertEquals(Charset.forName("UTF-16BE"), Charsets.UTF_16BE);
  }

  @GwtIncompatible // Non-UTF-8 Charset
  public void testUtf16le() {
    assertEquals(Charset.forName("UTF-16LE"), Charsets.UTF_16LE);
  }

  @GwtIncompatible // Non-UTF-8 Charset

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 54

              
  @GwtIncompatible // Non-UTF-8 Charset
  public void testUtf16le() {
    assertEquals(Charset.forName("UTF-16LE"), Charsets.UTF_16LE);
  }

  @GwtIncompatible // Non-UTF-8 Charset
  public void testUtf16() {
    assertEquals(Charset.forName("UTF-16"), Charsets.UTF_16);

            

Reported by PMD.

guava-tests/test/com/google/common/collect/AbstractImmutableTableTest.java
22 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: 32

              
  abstract Iterable<ImmutableTable<Character, Integer, String>> getTestInstances();

  public final void testClear() {
    for (Table<Character, Integer, String> testInstance : getTestInstances()) {
      try {
        testInstance.clear();
        fail();
      } catch (UnsupportedOperationException e) {

            

Reported by PMD.

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

Line: 36

                  for (Table<Character, Integer, String> testInstance : getTestInstances()) {
      try {
        testInstance.clear();
        fail();
      } catch (UnsupportedOperationException e) {
        // success
      }
    }
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

                  for (Table<Character, Integer, String> testInstance : getTestInstances()) {
      try {
        testInstance.clear();
        fail();
      } catch (UnsupportedOperationException e) {
        // success
      }
    }
  }

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 37

                    try {
        testInstance.clear();
        fail();
      } catch (UnsupportedOperationException e) {
        // success
      }
    }
  }


            

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

                  }
  }

  public final void testPut() {
    for (Table<Character, Integer, String> testInstance : getTestInstances()) {
      try {
        testInstance.put('a', 1, "blah");
        fail();
      } catch (UnsupportedOperationException e) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

                  for (Table<Character, Integer, String> testInstance : getTestInstances()) {
      try {
        testInstance.put('a', 1, "blah");
        fail();
      } catch (UnsupportedOperationException e) {
        // success
      }
    }
  }

            

Reported by PMD.

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

Line: 47

                  for (Table<Character, Integer, String> testInstance : getTestInstances()) {
      try {
        testInstance.put('a', 1, "blah");
        fail();
      } catch (UnsupportedOperationException e) {
        // success
      }
    }
  }

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 48

                    try {
        testInstance.put('a', 1, "blah");
        fail();
      } catch (UnsupportedOperationException e) {
        // success
      }
    }
  }


            

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 final void testPutAll() {
    for (Table<Character, Integer, String> testInstance : getTestInstances()) {
      try {
        testInstance.putAll(ImmutableTable.of('a', 1, "blah"));
        fail();
      } catch (UnsupportedOperationException e) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 58

                  for (Table<Character, Integer, String> testInstance : getTestInstances()) {
      try {
        testInstance.putAll(ImmutableTable.of('a', 1, "blah"));
        fail();
      } catch (UnsupportedOperationException e) {
        // success
      }
    }
  }

            

Reported by PMD.

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

Line: 32

               * @author Nick Piepmeier
 */
public class HashingOutputStreamTest extends TestCase {
  private Hasher hasher;
  private HashFunction hashFunction;
  private final ByteArrayOutputStream buffer = new ByteArrayOutputStream();

  @SuppressWarnings("DoNotMock")
  @Override

            

Reported by PMD.

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

Line: 33

               */
public class HashingOutputStreamTest extends TestCase {
  private Hasher hasher;
  private HashFunction hashFunction;
  private final ByteArrayOutputStream buffer = new ByteArrayOutputStream();

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

            

Reported by PMD.

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

Line: 34

              public class HashingOutputStreamTest extends TestCase {
  private Hasher hasher;
  private HashFunction hashFunction;
  private final ByteArrayOutputStream buffer = new ByteArrayOutputStream();

  @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: 36

                private HashFunction hashFunction;
  private final ByteArrayOutputStream buffer = new ByteArrayOutputStream();

  @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: 43

                  hasher = mock(Hasher.class);
    hashFunction = mock(HashFunction.class);

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

  public void testWrite_putSingleByte() throws Exception {
    int b = 'q';
    HashingOutputStream out = new HashingOutputStream(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: 46

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

  public void testWrite_putSingleByte() throws Exception {
    int b = 'q';
    HashingOutputStream out = new HashingOutputStream(hashFunction, buffer);
    out.write(b);

    verify(hashFunction).newHasher();

            

Reported by PMD.

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

Line: 48

              
  public void testWrite_putSingleByte() throws Exception {
    int b = 'q';
    HashingOutputStream out = new HashingOutputStream(hashFunction, buffer);
    out.write(b);

    verify(hashFunction).newHasher();
    verify(hasher).putByte((byte) b);
    verifyNoMoreInteractions(hashFunction, hasher);

            

Reported by PMD.

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

Line: 51

                  HashingOutputStream out = new HashingOutputStream(hashFunction, buffer);
    out.write(b);

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

  public void testWrite_putByteArray() throws Exception {

            

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

                  verifyNoMoreInteractions(hashFunction, hasher);
  }

  public void testWrite_putByteArray() throws Exception {
    byte[] buf = new byte[] {'y', 'a', 'm', 's'};
    HashingOutputStream out = new HashingOutputStream(hashFunction, buffer);
    out.write(buf);

    verify(hashFunction).newHasher();

            

Reported by PMD.

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

Line: 58

              
  public void testWrite_putByteArray() throws Exception {
    byte[] buf = new byte[] {'y', 'a', 'm', 's'};
    HashingOutputStream out = new HashingOutputStream(hashFunction, buffer);
    out.write(buf);

    verify(hashFunction).newHasher();
    verify(hasher).putBytes(buf, 0, buf.length);
    verifyNoMoreInteractions(hashFunction, hasher);

            

Reported by PMD.

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

Line: 29

               * @author Gregory Kick
 */
@GwtCompatible(emulated = true)
public class EmptyImmutableTableTest extends AbstractImmutableTableTest {
  private static final ImmutableTable<Character, Integer, String> INSTANCE = ImmutableTable.of();

  @Override
  Iterable<ImmutableTable<Character, Integer, String>> getTestInstances() {
    return ImmutableSet.of(INSTANCE);

            

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

                  return ImmutableSet.of(INSTANCE);
  }

  public void testHashCode() {
    assertEquals(0, INSTANCE.hashCode());
  }

  public void testEqualsObject() {
    Table<Character, Integer, String> nonEmptyTable = HashBasedTable.create();

            

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

                  assertEquals(0, INSTANCE.hashCode());
  }

  public void testEqualsObject() {
    Table<Character, Integer, String> nonEmptyTable = HashBasedTable.create();
    nonEmptyTable.put('A', 1, "blah");

    new EqualsTester()
        .addEqualityGroup(INSTANCE, HashBasedTable.create(), TreeBasedTable.create())

            

Reported by PMD.

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

Line: 43

              
  public void testEqualsObject() {
    Table<Character, Integer, String> nonEmptyTable = HashBasedTable.create();
    nonEmptyTable.put('A', 1, "blah");

    new EqualsTester()
        .addEqualityGroup(INSTANCE, HashBasedTable.create(), TreeBasedTable.create())
        .addEqualityGroup(nonEmptyTable)
        .testEquals();

            

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

                      .testEquals();
  }

  @GwtIncompatible // ArrayTable
  public void testEqualsObjectNullValues() {
    new EqualsTester()
        .addEqualityGroup(INSTANCE)
        .addEqualityGroup(ArrayTable.create(ImmutableSet.of('A'), ImmutableSet.of(1)))
        .testEquals();

            

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

                      .testEquals();
  }

  public void testToString() {
    assertEquals("{}", INSTANCE.toString());
  }

  public void testSize() {
    assertEquals(0, INSTANCE.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: 63

                  assertEquals("{}", INSTANCE.toString());
  }

  public void testSize() {
    assertEquals(0, INSTANCE.size());
  }

  public void testGet() {
    assertNull(INSTANCE.get('a', 1));

            

Reported by PMD.

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

Line: 67

                  assertEquals(0, INSTANCE.size());
  }

  public void testGet() {
    assertNull(INSTANCE.get('a', 1));
  }

  public void testIsEmpty() {
    assertTrue(INSTANCE.isEmpty());

            

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

                  assertNull(INSTANCE.get('a', 1));
  }

  public void testIsEmpty() {
    assertTrue(INSTANCE.isEmpty());
  }

  public void testCellSet() {
    assertEquals(ImmutableSet.of(), INSTANCE.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: 75

                  assertTrue(INSTANCE.isEmpty());
  }

  public void testCellSet() {
    assertEquals(ImmutableSet.of(), INSTANCE.cellSet());
  }

  public void testColumn() {
    assertEquals(ImmutableMap.of(), INSTANCE.column(1));

            

Reported by PMD.

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

Line: 39

               */
public class SynchronizedSetTest extends TestCase {

  public static final Object MUTEX = new Integer(1); // something Serializable

  public static Test suite() {
    return SetTestSuiteBuilder.using(
            new TestStringSetGenerator() {
              @Override

            

Reported by PMD.

This class name ends with Test but contains no test cases
Error

Line: 37

               *
 * @author Mike Bostock
 */
public class SynchronizedSetTest extends TestCase {

  public static final Object MUTEX = new Integer(1); // something Serializable

  public static Test suite() {
    return SetTestSuiteBuilder.using(

            

Reported by PMD.

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

Line: 41

              
  public static final Object MUTEX = new Integer(1); // something Serializable

  public static Test suite() {
    return SetTestSuiteBuilder.using(
            new TestStringSetGenerator() {
              @Override
              protected Set<String> create(String[] elements) {
                TestSet<String> inner = new TestSet<>(new HashSet<String>(), null);

            

Reported by PMD.

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

Line: 62

                      .createTestSuite();
  }

  static class TestSet<E> extends ForwardingSet<E> implements Serializable {
    final Set<E> delegate;
    public Object mutex;

    public TestSet(Set<E> delegate, Object mutex) {
      this.delegate = delegate;

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 63

                }

  static class TestSet<E> extends ForwardingSet<E> implements Serializable {
    final Set<E> delegate;
    public Object mutex;

    public TestSet(Set<E> delegate, Object mutex) {
      this.delegate = delegate;
      this.mutex = mutex;

            

Reported by PMD.

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

Line: 63

                }

  static class TestSet<E> extends ForwardingSet<E> implements Serializable {
    final Set<E> delegate;
    public Object mutex;

    public TestSet(Set<E> delegate, Object mutex) {
      this.delegate = delegate;
      this.mutex = mutex;

            

Reported by PMD.

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

Line: 64

              
  static class TestSet<E> extends ForwardingSet<E> implements Serializable {
    final Set<E> delegate;
    public Object mutex;

    public TestSet(Set<E> delegate, Object mutex) {
      this.delegate = delegate;
      this.mutex = mutex;
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 78

              
    @Override
    public String toString() {
      assertTrue(Thread.holdsLock(mutex));
      return super.toString();
    }

    @Override
    public boolean equals(@Nullable Object o) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 84

              
    @Override
    public boolean equals(@Nullable Object o) {
      assertTrue(Thread.holdsLock(mutex));
      return super.equals(o);
    }

    @Override
    public int hashCode() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 90

              
    @Override
    public int hashCode() {
      assertTrue(Thread.holdsLock(mutex));
      return super.hashCode();
    }

    @Override
    public boolean add(@Nullable E o) {

            

Reported by PMD.

guava-tests/benchmark/com/google/common/io/BaseEncodingBenchmark.java
22 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 46

                  }
  }

  @Param EncodingOption encoding;

  @Param({"10", "100", "10000"})
  int n;

  private final byte[][] encodingInputs = new byte[INPUTS_COUNT][];

            

Reported by PMD.

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

Line: 49

                @Param EncodingOption encoding;

  @Param({"10", "100", "10000"})
  int n;

  private final byte[][] encodingInputs = new byte[INPUTS_COUNT][];
  private final String[] decodingInputs = new String[INPUTS_COUNT];

  @BeforeExperiment

            

Reported by PMD.

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

Line: 51

                @Param({"10", "100", "10000"})
  int n;

  private final byte[][] encodingInputs = new byte[INPUTS_COUNT][];
  private final String[] decodingInputs = new String[INPUTS_COUNT];

  @BeforeExperiment
  public void setUp() {
    Random rng = new Random();

            

Reported by PMD.

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

Line: 52

                int n;

  private final byte[][] encodingInputs = new byte[INPUTS_COUNT][];
  private final String[] decodingInputs = new String[INPUTS_COUNT];

  @BeforeExperiment
  public void setUp() {
    Random rng = new Random();
    for (int i = 0; i < encodingInputs.length; i++) {

            

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 final byte[][] encodingInputs = new byte[INPUTS_COUNT][];
  private final String[] decodingInputs = new String[INPUTS_COUNT];

  @BeforeExperiment
  public void setUp() {
    Random rng = new Random();
    for (int i = 0; i < encodingInputs.length; i++) {
      encodingInputs[i] = new byte[n];
      rng.nextBytes(encodingInputs[i]);

            

Reported by PMD.

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

Line: 60

                  for (int i = 0; i < encodingInputs.length; i++) {
      encodingInputs[i] = new byte[n];
      rng.nextBytes(encodingInputs[i]);
      decodingInputs[i] = encoding.encoding.encode(encodingInputs[i]);
    }
  }

  @Benchmark
  public int encode(int reps) {

            

Reported by PMD.

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

Line: 68

                public int encode(int reps) {
    int tmp = 0;
    for (int i = 0; i < reps; i++) {
      tmp += System.identityHashCode(encoding.encoding.encode(encodingInputs[i & INPUTS_MASK]));
    }
    return tmp;
  }

  @Benchmark

            

Reported by PMD.

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

Line: 77

                public int decode(int reps) {
    int tmp = 0;
    for (int i = 0; i < reps; i++) {
      tmp += System.identityHashCode(encoding.encoding.decode(decodingInputs[i & INPUTS_MASK]));
    }
    return tmp;
  }

  @Benchmark

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 86

                public int encodingStream(int reps) throws IOException {
    int tmp = 0;
    for (int i = 0; i < reps; i++) {
      StringWriter target = new StringWriter(2 * n);
      OutputStream encodingStream = encoding.encoding.encodingStream(target);
      encodingStream.write(encodingInputs[i & INPUTS_MASK]);
      encodingStream.close();
      tmp += target.getBuffer().length();
    }

            

Reported by PMD.

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

Line: 87

                  int tmp = 0;
    for (int i = 0; i < reps; i++) {
      StringWriter target = new StringWriter(2 * n);
      OutputStream encodingStream = encoding.encoding.encodingStream(target);
      encodingStream.write(encodingInputs[i & INPUTS_MASK]);
      encodingStream.close();
      tmp += target.getBuffer().length();
    }
    return tmp;

            

Reported by PMD.