The following issues were found

guava-tests/test/com/google/common/collect/ImmutableCollectionTest.java
9 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: 27

               * @author Louis Wasserman
 */
public class ImmutableCollectionTest extends TestCase {
  public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));

            

Reported by PMD.

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

Line: 27

               * @author Louis Wasserman
 */
public class ImmutableCollectionTest extends TestCase {
  public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

               */
public class ImmutableCollectionTest extends TestCase {
  public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

              public class ImmutableCollectionTest extends TestCase {
  public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                public void testCapacityExpansion() {
    assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));
    assertEquals(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                  assertEquals(1, ImmutableCollection.Builder.expandedCapacity(0, 1));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(0, 2));
    assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE,

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                  assertEquals(2, ImmutableCollection.Builder.expandedCapacity(1, 2));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE,
        ImmutableCollection.Builder.expandedCapacity(Integer.MAX_VALUE - 1, Integer.MAX_VALUE));


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

                      Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(0, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE, ImmutableCollection.Builder.expandedCapacity(1, Integer.MAX_VALUE));
    assertEquals(
        Integer.MAX_VALUE,
        ImmutableCollection.Builder.expandedCapacity(Integer.MAX_VALUE - 1, Integer.MAX_VALUE));

    assertEquals(13, ImmutableCollection.Builder.expandedCapacity(8, 9));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 39

                      Integer.MAX_VALUE,
        ImmutableCollection.Builder.expandedCapacity(Integer.MAX_VALUE - 1, Integer.MAX_VALUE));

    assertEquals(13, ImmutableCollection.Builder.expandedCapacity(8, 9));
  }
}

            

Reported by PMD.

guava-tests/benchmark/com/google/common/hash/MessageDigestCreationBenchmark.java
9 issues
getInstance method always creates a new object and hence does not comply to Singleton Design Pattern behaviour. Please review
Error

Line: 42

                }

  @Benchmark
  int getInstance(int reps) throws Exception {
    int retValue = 0;
    for (int i = 0; i < reps; i++) {
      retValue ^= MessageDigest.getInstance(algorithm).getDigestLength();
    }
    return retValue;

            

Reported by PMD.

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

Line: 32

              public class MessageDigestCreationBenchmark {

  @Param({"MD5", "SHA-1", "SHA-256", "SHA-384", "SHA-512"})
  private String algorithm;

  private MessageDigest md;

  @BeforeExperiment
  void setUp() throws Exception {

            

Reported by PMD.

You shouldnt declare field of MessageDigest type, because unsynchronized access could cause problems
Design

Line: 34

                @Param({"MD5", "SHA-1", "SHA-256", "SHA-384", "SHA-512"})
  private String algorithm;

  private MessageDigest md;

  @BeforeExperiment
  void setUp() throws Exception {
    md = MessageDigest.getInstance(algorithm);
  }

            

Reported by PMD.

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

Line: 34

                @Param({"MD5", "SHA-1", "SHA-256", "SHA-384", "SHA-512"})
  private String algorithm;

  private MessageDigest md;

  @BeforeExperiment
  void setUp() throws Exception {
    md = MessageDigest.getInstance(algorithm);
  }

            

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 MessageDigest md;

  @BeforeExperiment
  void setUp() throws Exception {
    md = MessageDigest.getInstance(algorithm);
  }

  @Benchmark

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 37

                private MessageDigest md;

  @BeforeExperiment
  void setUp() throws Exception {
    md = MessageDigest.getInstance(algorithm);
  }

  @Benchmark
  int getInstance(int reps) throws Exception {

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 42

                }

  @Benchmark
  int getInstance(int reps) throws Exception {
    int retValue = 0;
    for (int i = 0; i < reps; i++) {
      retValue ^= MessageDigest.getInstance(algorithm).getDigestLength();
    }
    return retValue;

            

Reported by PMD.

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

Line: 45

                int getInstance(int reps) throws Exception {
    int retValue = 0;
    for (int i = 0; i < reps; i++) {
      retValue ^= MessageDigest.getInstance(algorithm).getDigestLength();
    }
    return retValue;
  }

  @Benchmark

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 51

                }

  @Benchmark
  int clone(int reps) throws Exception {
    int retValue = 0;
    for (int i = 0; i < reps; i++) {
      retValue ^= ((MessageDigest) md.clone()).getDigestLength();
    }
    return retValue;

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java
9 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: 47

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionAddTester<E> extends AbstractCollectionTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  public void testAdd_supportedNotPresent() {
    assertTrue("add(notPresent) should return true", collection.add(e3()));
    expectAdded(e3());
  }


            

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

                  expectAdded(e3());
  }

  @CollectionFeature.Require(absent = SUPPORTS_ADD)
  public void testAdd_unsupportedNotPresent() {
    try {
      collection.add(e3());
      fail("add(notPresent) should throw");
    } catch (UnsupportedOperationException expected) {

            

Reported by PMD.

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

Line: 64

                  expectMissing(e3());
  }

  @CollectionFeature.Require(absent = SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)
  public void testAdd_unsupportedPresent() {
    try {
      assertFalse("add(present) should return false or throw", collection.add(e0()));
    } catch (UnsupportedOperationException tolerated) {

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 69

                public void testAdd_unsupportedPresent() {
    try {
      assertFalse("add(present) should return false or throw", collection.add(e0()));
    } catch (UnsupportedOperationException tolerated) {
    }
    expectUnchanged();
  }

  @CollectionFeature.Require(

            

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

                  expectUnchanged();
  }

  @CollectionFeature.Require(
      value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES},
      absent = RESTRICTS_ELEMENTS)
  public void testAdd_nullSupported() {
    assertTrue("add(null) should return true", collection.add(null));
    expectAdded((E) null);

            

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

                  expectAdded((E) null);
  }

  @CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES)
  public void testAdd_nullUnsupported() {
    try {
      collection.add(null);
      fail("add(null) should throw");
    } catch (NullPointerException expected) {

            

Reported by PMD.

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

Line: 87

                  try {
      collection.add(null);
      fail("add(null) should throw");
    } catch (NullPointerException expected) {
    }
    expectUnchanged();
    expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(null)");
  }


            

Reported by PMD.

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

Line: 87

                  try {
      collection.add(null);
      fail("add(null) should throw");
    } catch (NullPointerException expected) {
    }
    expectUnchanged();
    expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(null)");
  }


            

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

                  expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(null)");
  }

  @CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
  @CollectionSize.Require(absent = ZERO)
  public void testAddConcurrentWithIteration() {
    try {
      Iterator<E> iterator = collection.iterator();
      assertTrue(collection.add(e3()));

            

Reported by PMD.

guava-testlib/test/com/google/common/collect/testing/features/FeatureEnumTest.java
9 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 45

                  assertEquals(
        rootLocaleFormat("%s must have RUNTIME RetentionPolicy.", annotationClass),
        RetentionPolicy.RUNTIME,
        retentionPolicy.value());
    assertNotNull(
        rootLocaleFormat("%s must be inherited.", annotationClass),
        annotationClass.getAnnotation(Inherited.class));

    for (String propertyName : new String[] {"value", "absent"}) {

            

Reported by PMD.

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

Line: 58

                      fail(
            rootLocaleFormat("%s must have a property named '%s'.", annotationClass, propertyName));
      }
      final Class<?> returnType = method.getReturnType();
      assertTrue(
          rootLocaleFormat("%s.%s() must return an array.", annotationClass, propertyName),
          returnType.isArray());
      assertSame(
          rootLocaleFormat(

            

Reported by PMD.

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

Line: 61

                    final Class<?> returnType = method.getReturnType();
      assertTrue(
          rootLocaleFormat("%s.%s() must return an array.", annotationClass, propertyName),
          returnType.isArray());
      assertSame(
          rootLocaleFormat(
              "%s.%s() must return an array of %s.",
              annotationClass, propertyName, annotationClass.getDeclaringClass()),
          annotationClass.getDeclaringClass(),

            

Reported by PMD.

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

Line: 67

                            "%s.%s() must return an array of %s.",
              annotationClass, propertyName, annotationClass.getDeclaringClass()),
          annotationClass.getDeclaringClass(),
          returnType.getComponentType());
    }
  }

  // This is public so that tests for Feature enums we haven't yet imagined
  // can reuse it.

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 77

                    Class<E> featureEnumClass) {
    final Class<?>[] classes = featureEnumClass.getDeclaredClasses();
    for (Class<?> containedClass : classes) {
      if (containedClass.getSimpleName().equals("Require")) {
        if (containedClass.isAnnotation()) {
          assertGoodTesterAnnotation(asAnnotation(containedClass));
        } else {
          fail(
              rootLocaleFormat(

            

Reported by PMD.

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

Line: 77

                    Class<E> featureEnumClass) {
    final Class<?>[] classes = featureEnumClass.getDeclaredClasses();
    for (Class<?> containedClass : classes) {
      if (containedClass.getSimpleName().equals("Require")) {
        if (containedClass.isAnnotation()) {
          assertGoodTesterAnnotation(asAnnotation(containedClass));
        } else {
          fail(
              rootLocaleFormat(

            

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

                  }
  }

  public void testFeatureEnums() throws Exception {
    assertGoodFeatureEnum(CollectionFeature.class);
    assertGoodFeatureEnum(ListFeature.class);
    assertGoodFeatureEnum(SetFeature.class);
    assertGoodFeatureEnum(CollectionSize.class);
    assertGoodFeatureEnum(MapFeature.class);

            

Reported by PMD.

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

Line: 105

                  }
  }

  public void testFeatureEnums() throws Exception {
    assertGoodFeatureEnum(CollectionFeature.class);
    assertGoodFeatureEnum(ListFeature.class);
    assertGoodFeatureEnum(SetFeature.class);
    assertGoodFeatureEnum(CollectionSize.class);
    assertGoodFeatureEnum(MapFeature.class);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'method' (lines '51'-'53').
Error

Line: 51

                      annotationClass.getAnnotation(Inherited.class));

    for (String propertyName : new String[] {"value", "absent"}) {
      Method method = null;
      try {
        method = annotationClass.getMethod(propertyName);
      } catch (NoSuchMethodException e) {
        fail(
            rootLocaleFormat("%s must have a property named '%s'.", annotationClass, propertyName));

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java
9 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 55

                protected List<Class<? extends AbstractTester>> getTesters() {
    List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());

    testers.add(CollectionSerializationEqualTester.class);
    testers.add(SetAddAllTester.class);
    testers.add(SetAddTester.class);
    testers.add(SetCreationTester.class);
    testers.add(SetHashCodeTester.class);
    testers.add(SetEqualsTester.class);

            

Reported by PMD.

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

Line: 56

                  List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());

    testers.add(CollectionSerializationEqualTester.class);
    testers.add(SetAddAllTester.class);
    testers.add(SetAddTester.class);
    testers.add(SetCreationTester.class);
    testers.add(SetHashCodeTester.class);
    testers.add(SetEqualsTester.class);
    testers.add(SetRemoveTester.class);

            

Reported by PMD.

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

Line: 57

              
    testers.add(CollectionSerializationEqualTester.class);
    testers.add(SetAddAllTester.class);
    testers.add(SetAddTester.class);
    testers.add(SetCreationTester.class);
    testers.add(SetHashCodeTester.class);
    testers.add(SetEqualsTester.class);
    testers.add(SetRemoveTester.class);
    // SetRemoveAllTester doesn't exist because, Sets not permitting

            

Reported by PMD.

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

Line: 58

                  testers.add(CollectionSerializationEqualTester.class);
    testers.add(SetAddAllTester.class);
    testers.add(SetAddTester.class);
    testers.add(SetCreationTester.class);
    testers.add(SetHashCodeTester.class);
    testers.add(SetEqualsTester.class);
    testers.add(SetRemoveTester.class);
    // SetRemoveAllTester doesn't exist because, Sets not permitting
    // duplicate elements, there are no tests for Set.removeAll() that aren't

            

Reported by PMD.

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

Line: 59

                  testers.add(SetAddAllTester.class);
    testers.add(SetAddTester.class);
    testers.add(SetCreationTester.class);
    testers.add(SetHashCodeTester.class);
    testers.add(SetEqualsTester.class);
    testers.add(SetRemoveTester.class);
    // SetRemoveAllTester doesn't exist because, Sets not permitting
    // duplicate elements, there are no tests for Set.removeAll() that aren't
    // covered by CollectionRemoveAllTester.

            

Reported by PMD.

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

Line: 60

                  testers.add(SetAddTester.class);
    testers.add(SetCreationTester.class);
    testers.add(SetHashCodeTester.class);
    testers.add(SetEqualsTester.class);
    testers.add(SetRemoveTester.class);
    // SetRemoveAllTester doesn't exist because, Sets not permitting
    // duplicate elements, there are no tests for Set.removeAll() that aren't
    // covered by CollectionRemoveAllTester.
    return testers;

            

Reported by PMD.

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

Line: 61

                  testers.add(SetCreationTester.class);
    testers.add(SetHashCodeTester.class);
    testers.add(SetEqualsTester.class);
    testers.add(SetRemoveTester.class);
    // SetRemoveAllTester doesn't exist because, Sets not permitting
    // duplicate elements, there are no tests for Set.removeAll() that aren't
    // covered by CollectionRemoveAllTester.
    return testers;
  }

            

Reported by PMD.

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

Line: 74

                        parentBuilder) {
    List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));

    if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
      derivedSuites.add(
          SetTestSuiteBuilder.using(
                  new ReserializedSetGenerator<E>(parentBuilder.getSubjectGenerator()))
              .named(getName() + " reserialized")
              .withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))

            

Reported by PMD.

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

Line: 89

                }

  static class ReserializedSetGenerator<E> implements TestSetGenerator<E> {
    final OneSizeTestContainerGenerator<Collection<E>, E> gen;

    private ReserializedSetGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
      this.gen = gen;
    }


            

Reported by PMD.

android/guava/src/com/google/common/base/SmallCharMatcher.java
9 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 32

              @ElementTypesAreNonnullByDefault
final class SmallCharMatcher extends NamedFastMatcher {
  static final int MAX_SIZE = 1023;
  private final char[] table;
  private final boolean containsZero;
  private final long filter;

  private SmallCharMatcher(char[] table, long filter, boolean containsZero, String description) {
    super(description);

            

Reported by PMD.

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

Line: 33

              final class SmallCharMatcher extends NamedFastMatcher {
  static final int MAX_SIZE = 1023;
  private final char[] table;
  private final boolean containsZero;
  private final long filter;

  private SmallCharMatcher(char[] table, long filter, boolean containsZero, String description) {
    super(description);
    this.table = table;

            

Reported by PMD.

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

Line: 34

                static final int MAX_SIZE = 1023;
  private final char[] table;
  private final boolean containsZero;
  private final long filter;

  private SmallCharMatcher(char[] table, long filter, boolean containsZero, String description) {
    super(description);
    this.table = table;
    this.filter = filter;

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 75

                 */
  @VisibleForTesting
  static int chooseTableSize(int setSize) {
    if (setSize == 1) {
      return 2;
    }
    // Correct the size for open addressing to match desired load factor.
    // Round up to the next highest power of 2.
    int tableSize = Integer.highestOneBit(setSize - 1) << 1;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'mask' (lines '94'-'110').
Error

Line: 94

                  boolean containsZero = chars.get(0);
    // Compute the hash table.
    char[] table = new char[chooseTableSize(size)];
    int mask = table.length - 1;
    for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) {
      // Compute the filter at the same time.
      filter |= 1L << c;
      int index = smear(c) & mask;
      while (true) {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'index' (lines '98'-'98').
Error

Line: 98

                  for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) {
      // Compute the filter at the same time.
      filter |= 1L << c;
      int index = smear(c) & mask;
      while (true) {
        // Check for empty.
        if (table[index] == 0) {
          table[index] = (char) c;
          break;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'index' (lines '98'-'110').
Error

Line: 98

                  for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) {
      // Compute the filter at the same time.
      filter |= 1L << c;
      int index = smear(c) & mask;
      while (true) {
        // Check for empty.
        if (table[index] == 0) {
          table[index] = (char) c;
          break;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'index' (lines '106'-'110').
Error

Line: 106

                        break;
        }
        // Linear probing.
        index = (index + 1) & mask;
      }
    }
    return new SmallCharMatcher(table, filter, containsZero, description);
  }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'index' (lines '106'-'98').
Error

Line: 106

                        break;
        }
        // Linear probing.
        index = (index + 1) & mask;
      }
    }
    return new SmallCharMatcher(table, filter, containsZero, description);
  }


            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/AbstractTester.java
9 issues
This class name ends with Test but contains no test cases
Error

Line: 34

               * @author George van den Driessche
 */
@GwtCompatible
public class AbstractTester<G> extends TestCase {
  private G subjectGenerator;
  private String suiteName;
  private Runnable setUp;
  private Runnable tearDown;


            

Reported by PMD.

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

Line: 35

               */
@GwtCompatible
public class AbstractTester<G> extends TestCase {
  private G subjectGenerator;
  private String suiteName;
  private Runnable setUp;
  private Runnable tearDown;

  // public so that it can be referenced in generated GWT tests.

            

Reported by PMD.

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

Line: 36

              @GwtCompatible
public class AbstractTester<G> extends TestCase {
  private G subjectGenerator;
  private String suiteName;
  private Runnable setUp;
  private Runnable tearDown;

  // public so that it can be referenced in generated GWT tests.
  @Override

            

Reported by PMD.

Field setUp has the same name as a method
Error

Line: 37

              public class AbstractTester<G> extends TestCase {
  private G subjectGenerator;
  private String suiteName;
  private Runnable setUp;
  private Runnable tearDown;

  // public so that it can be referenced in generated GWT tests.
  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 37

              public class AbstractTester<G> extends TestCase {
  private G subjectGenerator;
  private String suiteName;
  private Runnable setUp;
  private Runnable tearDown;

  // public so that it can be referenced in generated GWT tests.
  @Override
  public void setUp() throws Exception {

            

Reported by PMD.

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

Line: 38

                private G subjectGenerator;
  private String suiteName;
  private Runnable setUp;
  private Runnable tearDown;

  // public so that it can be referenced in generated GWT tests.
  @Override
  public void setUp() throws Exception {
    if (setUp != null) {

            

Reported by PMD.

Field tearDown has the same name as a method
Error

Line: 38

                private G subjectGenerator;
  private String suiteName;
  private Runnable setUp;
  private Runnable tearDown;

  // public so that it can be referenced in generated GWT tests.
  @Override
  public void setUp() throws Exception {
    if (setUp != null) {

            

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 Runnable tearDown;

  // public so that it can be referenced in generated GWT tests.
  @Override
  public void setUp() throws Exception {
    if (setUp != null) {
      setUp.run();
    }
  }

            

Reported by PMD.

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

Line: 49

                }

  // public so that it can be referenced in generated GWT tests.
  @Override
  public void tearDown() throws Exception {
    if (tearDown != null) {
      tearDown.run();
    }
  }

            

Reported by PMD.

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

Line: 25

              
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class IndexedImmutableSet<E> extends ImmutableSet<E> {
  abstract E get(int index);

  @Override
  public UnmodifiableIterator<E> iterator() {
    return asList().iterator();

            

Reported by PMD.

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

Line: 30

              
  @Override
  public UnmodifiableIterator<E> iterator() {
    return asList().iterator();
  }

  @Override
  @GwtIncompatible
  int copyIntoArray(@Nullable Object[] dst, int offset) {

            

Reported by PMD.

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

Line: 36

                @Override
  @GwtIncompatible
  int copyIntoArray(@Nullable Object[] dst, int offset) {
    return asList().copyIntoArray(dst, offset);
  }

  @Override
  ImmutableList<E> createAsList() {
    return new ImmutableList<E>() {

            

Reported by PMD.

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

Line: 44

                  return new ImmutableList<E>() {
      @Override
      public E get(int index) {
        return IndexedImmutableSet.this.get(index);
      }

      @Override
      boolean isPartialView() {
        return IndexedImmutableSet.this.isPartialView();

            

Reported by PMD.

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

Line: 44

                  return new ImmutableList<E>() {
      @Override
      public E get(int index) {
        return IndexedImmutableSet.this.get(index);
      }

      @Override
      boolean isPartialView() {
        return IndexedImmutableSet.this.isPartialView();

            

Reported by PMD.

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

Line: 49

              
      @Override
      boolean isPartialView() {
        return IndexedImmutableSet.this.isPartialView();
      }

      @Override
      public int size() {
        return IndexedImmutableSet.this.size();

            

Reported by PMD.

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

Line: 49

              
      @Override
      boolean isPartialView() {
        return IndexedImmutableSet.this.isPartialView();
      }

      @Override
      public int size() {
        return IndexedImmutableSet.this.size();

            

Reported by PMD.

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

Line: 54

              
      @Override
      public int size() {
        return IndexedImmutableSet.this.size();
      }
    };
  }
}

            

Reported by PMD.

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

Line: 54

              
      @Override
      public int size() {
        return IndexedImmutableSet.this.size();
      }
    };
  }
}

            

Reported by PMD.

android/guava/src/com/google/common/collect/ForwardingMapEntry.java
9 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 65

                @Override
  @ParametricNullness
  public K getKey() {
    return delegate().getKey();
  }

  @Override
  @ParametricNullness
  public V getValue() {

            

Reported by PMD.

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

Line: 71

                @Override
  @ParametricNullness
  public V getValue() {
    return delegate().getValue();
  }

  @Override
  @ParametricNullness
  public V setValue(@ParametricNullness V value) {

            

Reported by PMD.

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

Line: 77

                @Override
  @ParametricNullness
  public V setValue(@ParametricNullness V value) {
    return delegate().setValue(value);
  }

  @Override
  public boolean equals(@CheckForNull Object object) {
    return delegate().equals(object);

            

Reported by PMD.

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

Line: 82

              
  @Override
  public boolean equals(@CheckForNull Object object) {
    return delegate().equals(object);
  }

  @Override
  public int hashCode() {
    return delegate().hashCode();

            

Reported by PMD.

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

Line: 87

              
  @Override
  public int hashCode() {
    return delegate().hashCode();
  }

  /**
   * A sensible definition of {@link #equals(Object)} in terms of {@link #getKey()} and {@link
   * #getValue()}. If you override either of these methods, you may wish to override {@link

            

Reported by PMD.

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

Line: 100

                protected boolean standardEquals(@CheckForNull Object object) {
    if (object instanceof Entry) {
      Entry<?, ?> that = (Entry<?, ?>) object;
      return Objects.equal(this.getKey(), that.getKey())
          && Objects.equal(this.getValue(), that.getValue());
    }
    return false;
  }


            

Reported by PMD.

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

Line: 101

                  if (object instanceof Entry) {
      Entry<?, ?> that = (Entry<?, ?>) object;
      return Objects.equal(this.getKey(), that.getKey())
          && Objects.equal(this.getValue(), that.getValue());
    }
    return false;
  }

  /**

            

Reported by PMD.

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

Line: 116

                protected int standardHashCode() {
    K k = getKey();
    V v = getValue();
    return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode());
  }

  /**
   * A sensible definition of {@link #toString} in terms of {@link #getKey} and {@link #getValue}.
   * If you override either of these methods, you may wish to override {@link #equals} to forward to

            

Reported by PMD.

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

Line: 116

                protected int standardHashCode() {
    K k = getKey();
    V v = getValue();
    return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode());
  }

  /**
   * A sensible definition of {@link #toString} in terms of {@link #getKey} and {@link #getValue}.
   * If you override either of these methods, you may wish to override {@link #equals} to forward to

            

Reported by PMD.

guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/AbstractSortedMultiset.java
9 issues
This class has too many methods, consider refactoring it.
Design

Line: 35

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
abstract class AbstractSortedMultiset<E> extends AbstractMultiset<E> implements SortedMultiset<E> {
  @GwtTransient final Comparator<? super E> comparator;

  // needed for serialization
  @SuppressWarnings("unchecked")
  AbstractSortedMultiset() {

            

Reported by PMD.

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

Line: 36

               */
@GwtCompatible(emulated = true)
abstract class AbstractSortedMultiset<E> extends AbstractMultiset<E> implements SortedMultiset<E> {
  @GwtTransient final Comparator<? super E> comparator;

  // needed for serialization
  @SuppressWarnings("unchecked")
  AbstractSortedMultiset() {
    this((Comparator) Ordering.natural());

            

Reported by PMD.

Field comparator has the same name as a method
Error

Line: 36

               */
@GwtCompatible(emulated = true)
abstract class AbstractSortedMultiset<E> extends AbstractMultiset<E> implements SortedMultiset<E> {
  @GwtTransient final Comparator<? super E> comparator;

  // needed for serialization
  @SuppressWarnings("unchecked")
  AbstractSortedMultiset() {
    this((Comparator) Ordering.natural());

            

Reported by PMD.

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

Line: 80

                  Iterator<Entry<E>> entryIterator = entryIterator();
    if (entryIterator.hasNext()) {
      Entry<E> result = entryIterator.next();
      result = Multisets.immutableEntry(result.getElement(), result.getCount());
      entryIterator.remove();
      return result;
    }
    return null;
  }

            

Reported by PMD.

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

Line: 80

                  Iterator<Entry<E>> entryIterator = entryIterator();
    if (entryIterator.hasNext()) {
      Entry<E> result = entryIterator.next();
      result = Multisets.immutableEntry(result.getElement(), result.getCount());
      entryIterator.remove();
      return result;
    }
    return null;
  }

            

Reported by PMD.

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

Line: 92

                  Iterator<Entry<E>> entryIterator = descendingEntryIterator();
    if (entryIterator.hasNext()) {
      Entry<E> result = entryIterator.next();
      result = Multisets.immutableEntry(result.getElement(), result.getCount());
      entryIterator.remove();
      return result;
    }
    return null;
  }

            

Reported by PMD.

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

Line: 92

                  Iterator<Entry<E>> entryIterator = descendingEntryIterator();
    if (entryIterator.hasNext()) {
      Entry<E> result = entryIterator.next();
      result = Multisets.immutableEntry(result.getElement(), result.getCount());
      entryIterator.remove();
      return result;
    }
    return null;
  }

            

Reported by PMD.

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

Line: 108

                  // These are checked elsewhere, but NullPointerTester wants them checked eagerly.
    checkNotNull(fromBoundType);
    checkNotNull(toBoundType);
    return tailMultiset(fromElement, fromBoundType).headMultiset(toElement, toBoundType);
  }

  abstract Iterator<Entry<E>> descendingEntryIterator();

  Iterator<E> descendingIterator() {

            

Reported by PMD.

Field descendingMultiset has the same name as a method
Error

Line: 117

                  return Multisets.iteratorImpl(descendingMultiset());
  }

  private transient SortedMultiset<E> descendingMultiset;

  @Override
  public SortedMultiset<E> descendingMultiset() {
    SortedMultiset<E> result = descendingMultiset;
    return (result == null) ? descendingMultiset = createDescendingMultiset() : result;

            

Reported by PMD.