The following issues were found

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

Line: 32

               * @author Louis Wasserman
 */
@GwtIncompatible // NavigableMap
public class ImmutableRangeMapTest extends TestCase {
  private static final ImmutableList<Range<Integer>> RANGES;
  private static final int MIN_BOUND = 0;
  private static final int MAX_BOUND = 10;

  static {

            

Reported by PMD.

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

Line: 66

                  RANGES = builder.build();
  }

  public void testBuilderRejectsEmptyRanges() {
    for (int i = MIN_BOUND; i <= MAX_BOUND; i++) {
      ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
      try {
        builder.put(Range.closedOpen(i, i), 1);
        fail("Expected IllegalArgumentException");

            

Reported by PMD.

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

Line: 71

                    ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
      try {
        builder.put(Range.closedOpen(i, i), 1);
        fail("Expected IllegalArgumentException");
      } catch (IllegalArgumentException expected) {
        // success
      }
      try {
        builder.put(Range.openClosed(i, i), 1);

            

Reported by PMD.

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

Line: 77

                    }
      try {
        builder.put(Range.openClosed(i, i), 1);
        fail("Expected IllegalArgumentException");
      } catch (IllegalArgumentException 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: 83

                  }
  }

  public void testOverlapRejection() {
    for (Range<Integer> range1 : RANGES) {
      for (Range<Integer> range2 : RANGES) {
        boolean expectRejection =
            range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
        ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();

            

Reported by PMD.

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

Line: 83

                  }
  }

  public void testOverlapRejection() {
    for (Range<Integer> range1 : RANGES) {
      for (Range<Integer> range2 : RANGES) {
        boolean expectRejection =
            range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
        ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();

            

Reported by PMD.

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

Line: 87

                  for (Range<Integer> range1 : RANGES) {
      for (Range<Integer> range2 : RANGES) {
        boolean expectRejection =
            range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
        ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
        builder.put(range1, 1).put(range2, 2);
        try {
          ImmutableRangeMap<Integer, Integer> unused = builder.build();
          assertFalse(expectRejection);

            

Reported by PMD.

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

Line: 89

                      boolean expectRejection =
            range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
        ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
        builder.put(range1, 1).put(range2, 2);
        try {
          ImmutableRangeMap<Integer, Integer> unused = builder.build();
          assertFalse(expectRejection);
        } catch (IllegalArgumentException e) {
          assertTrue(expectRejection);

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 91

                      ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
        builder.put(range1, 1).put(range2, 2);
        try {
          ImmutableRangeMap<Integer, Integer> unused = builder.build();
          assertFalse(expectRejection);
        } catch (IllegalArgumentException e) {
          assertTrue(expectRejection);
        }
      }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 92

                      builder.put(range1, 1).put(range2, 2);
        try {
          ImmutableRangeMap<Integer, Integer> unused = builder.build();
          assertFalse(expectRejection);
        } catch (IllegalArgumentException e) {
          assertTrue(expectRejection);
        }
      }
    }

            

Reported by PMD.

android/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
104 issues
Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 85

              
  public void testPutThrows() {
    try {
      map.put(TypeToken.of(Integer.class), new Integer(5));
      fail();
    } catch (UnsupportedOperationException expected) {
    }
  }


            

Reported by PMD.

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

Line: 93

              
  public void testPutAllThrows() {
    try {
      map.putAll(ImmutableMap.of(TypeToken.of(Integer.class), new Integer(5)));
      fail();
    } catch (UnsupportedOperationException expected) {
    }
  }


            

Reported by PMD.

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

Line: 137

                }

  public void testPutAndGetInstance() {
    assertNull(map.putInstance(Integer.class, new Integer(5)));

    Integer oldValue = map.putInstance(Integer.class, new Integer(7));
    assertEquals(5, (int) oldValue);

    Integer newValue = map.getInstance(Integer.class);

            

Reported by PMD.

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

Line: 139

                public void testPutAndGetInstance() {
    assertNull(map.putInstance(Integer.class, new Integer(5)));

    Integer oldValue = map.putInstance(Integer.class, new Integer(7));
    assertEquals(5, (int) oldValue);

    Integer newValue = map.getInstance(Integer.class);
    assertEquals(7, (int) newValue);
    assertEquals(7, (int) map.getInstance(TypeToken.of(Integer.class)));

            

Reported by PMD.

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

Line: 151

              
  public void testNull() {
    try {
      map.putInstance((TypeToken) null, new Integer(1));
      fail();
    } catch (NullPointerException expected) {
    }
    map.putInstance(Integer.class, null);
    assertTrue(map.containsKey(TypeToken.of(Integer.class)));

            

Reported by PMD.

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

Line: 40

               *
 * @author Ben Yu
 */
public class MutableTypeToInstanceMapTest extends TestCase {

  @AndroidIncompatible // problem with suite builders on Android
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(MutableTypeToInstanceMapTest.class);

            

Reported by PMD.

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

Line: 42

               */
public class MutableTypeToInstanceMapTest extends TestCase {

  @AndroidIncompatible // problem with suite builders on Android
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(MutableTypeToInstanceMapTest.class);

    suite.addTest(

            

Reported by PMD.

The String literal 'unchecked' appears 4 times in this file; the first occurrence is on line 53
Error

Line: 53

                                // Other tests will verify what real, warning-free usage looks like
                  // but here we have to do some serious fudging
                  @Override
                  @SuppressWarnings("unchecked")
                  public Map<TypeToken, Object> create(Object... elements) {
                    MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
                    for (Object object : elements) {
                      Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
                      map.putInstance(entry.getKey(), entry.getValue());

            

Reported by PMD.

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

Line: 58

                                  MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
                    for (Object object : elements) {
                      Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
                      map.putInstance(entry.getKey(), entry.getValue());
                    }
                    return (Map) map;
                  }
                })
            .named("MutableTypeToInstanceMap")

            

Reported by PMD.

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

Line: 58

                                  MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
                    for (Object object : elements) {
                      Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
                      map.putInstance(entry.getKey(), entry.getValue());
                    }
                    return (Map) map;
                  }
                })
            .named("MutableTypeToInstanceMap")

            

Reported by PMD.

guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
104 issues
Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 85

              
  public void testPutThrows() {
    try {
      map.put(TypeToken.of(Integer.class), new Integer(5));
      fail();
    } catch (UnsupportedOperationException expected) {
    }
  }


            

Reported by PMD.

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

Line: 93

              
  public void testPutAllThrows() {
    try {
      map.putAll(ImmutableMap.of(TypeToken.of(Integer.class), new Integer(5)));
      fail();
    } catch (UnsupportedOperationException expected) {
    }
  }


            

Reported by PMD.

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

Line: 137

                }

  public void testPutAndGetInstance() {
    assertNull(map.putInstance(Integer.class, new Integer(5)));

    Integer oldValue = map.putInstance(Integer.class, new Integer(7));
    assertEquals(5, (int) oldValue);

    Integer newValue = map.getInstance(Integer.class);

            

Reported by PMD.

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

Line: 139

                public void testPutAndGetInstance() {
    assertNull(map.putInstance(Integer.class, new Integer(5)));

    Integer oldValue = map.putInstance(Integer.class, new Integer(7));
    assertEquals(5, (int) oldValue);

    Integer newValue = map.getInstance(Integer.class);
    assertEquals(7, (int) newValue);
    assertEquals(7, (int) map.getInstance(TypeToken.of(Integer.class)));

            

Reported by PMD.

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

Line: 151

              
  public void testNull() {
    try {
      map.putInstance((TypeToken) null, new Integer(1));
      fail();
    } catch (NullPointerException expected) {
    }
    map.putInstance(Integer.class, null);
    assertTrue(map.containsKey(TypeToken.of(Integer.class)));

            

Reported by PMD.

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

Line: 40

               *
 * @author Ben Yu
 */
public class MutableTypeToInstanceMapTest extends TestCase {

  @AndroidIncompatible // problem with suite builders on Android
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(MutableTypeToInstanceMapTest.class);

            

Reported by PMD.

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

Line: 42

               */
public class MutableTypeToInstanceMapTest extends TestCase {

  @AndroidIncompatible // problem with suite builders on Android
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(MutableTypeToInstanceMapTest.class);

    suite.addTest(

            

Reported by PMD.

The String literal 'unchecked' appears 4 times in this file; the first occurrence is on line 53
Error

Line: 53

                                // Other tests will verify what real, warning-free usage looks like
                  // but here we have to do some serious fudging
                  @Override
                  @SuppressWarnings("unchecked")
                  public Map<TypeToken, Object> create(Object... elements) {
                    MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
                    for (Object object : elements) {
                      Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
                      map.putInstance(entry.getKey(), entry.getValue());

            

Reported by PMD.

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

Line: 58

                                  MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
                    for (Object object : elements) {
                      Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
                      map.putInstance(entry.getKey(), entry.getValue());
                    }
                    return (Map) map;
                  }
                })
            .named("MutableTypeToInstanceMap")

            

Reported by PMD.

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

Line: 58

                                  MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
                    for (Object object : elements) {
                      Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
                      map.putInstance(entry.getKey(), entry.getValue());
                    }
                    return (Map) map;
                  }
                })
            .named("MutableTypeToInstanceMap")

            

Reported by PMD.

android/guava-tests/test/com/google/common/math/StatsTesting.java
104 issues
This class has too many methods, consider refactoring it.
Design

Line: 41

               *
 * @author Pete Gillin
 */
class StatsTesting {

  static final double ALLOWED_ERROR = 1e-10;

  // Inputs and their statistics:


            

Reported by PMD.

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

Line: 76

                 */
  static class ManyValues {

    private final ImmutableList<Double> values;

    ManyValues(double[] values) {
      this.values = ImmutableList.copyOf(Doubles.asList(values));
    }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 122

                        values[3] = 555.555;
          for (double fifth : ImmutableList.of(-2.2, POSITIVE_INFINITY, NEGATIVE_INFINITY, NaN)) {
            values[4] = fifth;
            builder.add(new ManyValues(values));
          }
        }
      }
      return builder.build();
    }

            

Reported by PMD.

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

Line: 289

                private static PairedStats buildManyValuesPairedStats() {
    PairedStatsAccumulator accumulator =
        createFilledPairedStatsAccumulator(MANY_VALUES, OTHER_MANY_VALUES);
    PairedStats stats = accumulator.snapshot();
    accumulator.add(99.99, 9999.9999); // should do nothing to the snapshot
    return stats;
  }

  private static PairedStats buildHorizontalValuesPairedStats() {

            

Reported by PMD.

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

Line: 290

                  PairedStatsAccumulator accumulator =
        createFilledPairedStatsAccumulator(MANY_VALUES, OTHER_MANY_VALUES);
    PairedStats stats = accumulator.snapshot();
    accumulator.add(99.99, 9999.9999); // should do nothing to the snapshot
    return stats;
  }

  private static PairedStats buildHorizontalValuesPairedStats() {
    PairedStatsAccumulator accumulator = new PairedStatsAccumulator();

            

Reported by PMD.

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

Line: 332

                // Helper methods:

  static void assertStatsApproxEqual(Stats expectedStats, Stats actualStats) {
    assertThat(actualStats.count()).isEqualTo(expectedStats.count());
    if (expectedStats.count() == 0) {
      try {
        actualStats.mean();
        fail("Expected IllegalStateException");
      } catch (IllegalStateException expected) {

            

Reported by PMD.

The String literal 'Expected IllegalStateException' appears 8 times in this file; the first occurrence is on line 336
Error

Line: 336

                  if (expectedStats.count() == 0) {
      try {
        actualStats.mean();
        fail("Expected IllegalStateException");
      } catch (IllegalStateException expected) {
      }
      try {
        actualStats.populationVariance();
        fail("Expected IllegalStateException");

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 354

                      fail("Expected IllegalStateException");
      } catch (IllegalStateException expected) {
      }
    } else if (expectedStats.count() == 1) {
      assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());
      assertThat(actualStats.populationVariance()).isWithin(0.0).of(0.0);
      assertThat(actualStats.min()).isWithin(ALLOWED_ERROR).of(expectedStats.min());
      assertThat(actualStats.max()).isWithin(ALLOWED_ERROR).of(expectedStats.max());
    } else {

            

Reported by PMD.

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

Line: 355

                    } catch (IllegalStateException expected) {
      }
    } else if (expectedStats.count() == 1) {
      assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());
      assertThat(actualStats.populationVariance()).isWithin(0.0).of(0.0);
      assertThat(actualStats.min()).isWithin(ALLOWED_ERROR).of(expectedStats.min());
      assertThat(actualStats.max()).isWithin(ALLOWED_ERROR).of(expectedStats.max());
    } else {
      assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());

            

Reported by PMD.

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

Line: 355

                    } catch (IllegalStateException expected) {
      }
    } else if (expectedStats.count() == 1) {
      assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());
      assertThat(actualStats.populationVariance()).isWithin(0.0).of(0.0);
      assertThat(actualStats.min()).isWithin(ALLOWED_ERROR).of(expectedStats.min());
      assertThat(actualStats.max()).isWithin(ALLOWED_ERROR).of(expectedStats.max());
    } else {
      assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());

            

Reported by PMD.

guava/src/com/google/common/collect/Multisets.java
103 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;

            

Reported by PMD.

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

Line: 64

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns a {@code Collector} that accumulates elements into a multiset created via the specified
   * {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the

            

Reported by PMD.

Avoid really long classes.
Design

Line: 64

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns a {@code Collector} that accumulates elements into a multiset created via the specified
   * {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the

            

Reported by PMD.

Possible God Class (WMC=59, ATFD=47, TCC=0.000%)
Design

Line: 64

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns a {@code Collector} that accumulates elements into a multiset created via the specified
   * {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the

            

Reported by PMD.

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

Line: 64

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns a {@code Collector} that accumulates elements into a multiset created via the specified
   * {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the

            

Reported by PMD.

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

Line: 64

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns a {@code Collector} that accumulates elements into a multiset created via the specified
   * {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the

            

Reported by PMD.

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

Line: 105

                public static <E extends @Nullable Object> Multiset<E> unmodifiableMultiset(
      Multiset<? extends E> multiset) {
    if (multiset instanceof UnmodifiableMultiset || multiset instanceof ImmutableMultiset) {
      @SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
      Multiset<E> result = (Multiset<E>) multiset;
      return result;
    }
    return new UnmodifiableMultiset<E>(checkNotNull(multiset));
  }

            

Reported by PMD.

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

Line: 124

                }

  static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
      implements Serializable {
    final Multiset<? extends E> delegate;

    UnmodifiableMultiset(Multiset<? extends E> delegate) {
      this.delegate = delegate;
    }

            

Reported by PMD.

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

Line: 125

              
  static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
      implements Serializable {
    final Multiset<? extends E> delegate;

    UnmodifiableMultiset(Multiset<? extends E> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 125

              
  static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
      implements Serializable {
    final Multiset<? extends E> delegate;

    UnmodifiableMultiset(Multiset<? extends E> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

android/guava-tests/test/com/google/common/eventbus/outside/AnnotatedSubscriberFinderTests.java
103 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.eventbus.outside;

import static com.google.common.truth.Truth.assertThat;

import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;

            

Reported by PMD.

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

Line: 41

                abstract static class AbstractEventBusTest<H> extends TestCase {
    abstract H createSubscriber();

    private H subscriber;

    H getSubscriber() {
      return subscriber;
    }


            

Reported by PMD.

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

Line: 47

                    return subscriber;
    }

    @Override
    protected void setUp() throws Exception {
      subscriber = createSubscriber();
      EventBus bus = new EventBus();
      bus.register(subscriber);
      bus.post(EVENT);

            

Reported by PMD.

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

Line: 55

                    bus.post(EVENT);
    }

    @Override
    protected void tearDown() throws Exception {
      subscriber = null;
    }
  }


            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 57

              
    @Override
    protected void tearDown() throws Exception {
      subscriber = null;
    }
  }

  /*
   * We break the tests up based on whether they are annotated or abstract in the superclass.

            

Reported by PMD.

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

Line: 67

                public static class BaseSubscriberFinderTest
      extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
    static class Subscriber {
      final List<Object> nonSubscriberEvents = Lists.newArrayList();
      final List<Object> subscriberEvents = Lists.newArrayList();

      public void notASubscriber(Object o) {
        nonSubscriberEvents.add(o);
      }

            

Reported by PMD.

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

Line: 68

                    extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
    static class Subscriber {
      final List<Object> nonSubscriberEvents = Lists.newArrayList();
      final List<Object> subscriberEvents = Lists.newArrayList();

      public void notASubscriber(Object o) {
        nonSubscriberEvents.add(o);
      }


            

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

                    }
    }

    public void testNonSubscriber() {
      assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
    }

    public void testSubscriber() {
      assertThat(getSubscriber().subscriberEvents).contains(EVENT);

            

Reported by PMD.

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

Line: 81

                  }

    public void testNonSubscriber() {
      assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
    }

    public void testSubscriber() {
      assertThat(getSubscriber().subscriberEvents).contains(EVENT);
    }

            

Reported by PMD.

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

Line: 81

                  }

    public void testNonSubscriber() {
      assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
    }

    public void testSubscriber() {
      assertThat(getSubscriber().subscriberEvents).contains(EVENT);
    }

            

Reported by PMD.

guava-tests/test/com/google/common/eventbus/outside/AnnotatedSubscriberFinderTests.java
103 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.eventbus.outside;

import static com.google.common.truth.Truth.assertThat;

import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;

            

Reported by PMD.

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

Line: 41

                abstract static class AbstractEventBusTest<H> extends TestCase {
    abstract H createSubscriber();

    private H subscriber;

    H getSubscriber() {
      return subscriber;
    }


            

Reported by PMD.

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

Line: 47

                    return subscriber;
    }

    @Override
    protected void setUp() throws Exception {
      subscriber = createSubscriber();
      EventBus bus = new EventBus();
      bus.register(subscriber);
      bus.post(EVENT);

            

Reported by PMD.

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

Line: 55

                    bus.post(EVENT);
    }

    @Override
    protected void tearDown() throws Exception {
      subscriber = null;
    }
  }


            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 57

              
    @Override
    protected void tearDown() throws Exception {
      subscriber = null;
    }
  }

  /*
   * We break the tests up based on whether they are annotated or abstract in the superclass.

            

Reported by PMD.

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

Line: 67

                public static class BaseSubscriberFinderTest
      extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
    static class Subscriber {
      final List<Object> nonSubscriberEvents = Lists.newArrayList();
      final List<Object> subscriberEvents = Lists.newArrayList();

      public void notASubscriber(Object o) {
        nonSubscriberEvents.add(o);
      }

            

Reported by PMD.

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

Line: 68

                    extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
    static class Subscriber {
      final List<Object> nonSubscriberEvents = Lists.newArrayList();
      final List<Object> subscriberEvents = Lists.newArrayList();

      public void notASubscriber(Object o) {
        nonSubscriberEvents.add(o);
      }


            

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

                    }
    }

    public void testNonSubscriber() {
      assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
    }

    public void testSubscriber() {
      assertThat(getSubscriber().subscriberEvents).contains(EVENT);

            

Reported by PMD.

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

Line: 81

                  }

    public void testNonSubscriber() {
      assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
    }

    public void testSubscriber() {
      assertThat(getSubscriber().subscriberEvents).contains(EVENT);
    }

            

Reported by PMD.

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

Line: 81

                  }

    public void testNonSubscriber() {
      assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
    }

    public void testSubscriber() {
      assertThat(getSubscriber().subscriberEvents).contains(EVENT);
    }

            

Reported by PMD.

android/guava/src/com/google/common/collect/Multisets.java
101 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.collect;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;

            

Reported by PMD.

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

Line: 59

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns an unmodifiable view of the specified multiset. Query operations on the returned
   * multiset "read through" to the specified multiset, and attempts to modify the returned multiset

            

Reported by PMD.

Avoid really long classes.
Design

Line: 59

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns an unmodifiable view of the specified multiset. Query operations on the returned
   * multiset "read through" to the specified multiset, and attempts to modify the returned multiset

            

Reported by PMD.

Possible God Class (WMC=61, ATFD=42, TCC=0.000%)
Design

Line: 59

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns an unmodifiable view of the specified multiset. Query operations on the returned
   * multiset "read through" to the specified multiset, and attempts to modify the returned multiset

            

Reported by PMD.

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

Line: 59

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns an unmodifiable view of the specified multiset. Query operations on the returned
   * multiset "read through" to the specified multiset, and attempts to modify the returned multiset

            

Reported by PMD.

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

Line: 59

               */
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
  private Multisets() {}

  /**
   * Returns an unmodifiable view of the specified multiset. Query operations on the returned
   * multiset "read through" to the specified multiset, and attempts to modify the returned multiset

            

Reported by PMD.

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

Line: 75

                public static <E extends @Nullable Object> Multiset<E> unmodifiableMultiset(
      Multiset<? extends E> multiset) {
    if (multiset instanceof UnmodifiableMultiset || multiset instanceof ImmutableMultiset) {
      @SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
      Multiset<E> result = (Multiset<E>) multiset;
      return result;
    }
    return new UnmodifiableMultiset<E>(checkNotNull(multiset));
  }

            

Reported by PMD.

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

Line: 94

                }

  static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
      implements Serializable {
    final Multiset<? extends E> delegate;

    UnmodifiableMultiset(Multiset<? extends E> delegate) {
      this.delegate = delegate;
    }

            

Reported by PMD.

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

Line: 95

              
  static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
      implements Serializable {
    final Multiset<? extends E> delegate;

    UnmodifiableMultiset(Multiset<? extends E> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 95

              
  static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
      implements Serializable {
    final Multiset<? extends E> delegate;

    UnmodifiableMultiset(Multiset<? extends E> delegate) {
      this.delegate = delegate;
    }


            

Reported by PMD.

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

Line: 34

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class GeneralRangeTest extends TestCase {
  private static final Ordering<Integer> ORDERING = Ordering.natural().nullsFirst();

  private static final List<Integer> IN_ORDER_VALUES = Arrays.asList(null, 1, 2, 3, 4, 5);

  public void testCreateEmptyRangeFails() {

            

Reported by PMD.

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

Line: 39

              
  private static final List<Integer> IN_ORDER_VALUES = Arrays.asList(null, 1, 2, 3, 4, 5);

  public void testCreateEmptyRangeFails() {
    for (BoundType lboundType : BoundType.values()) {
      for (BoundType uboundType : BoundType.values()) {
        try {
          GeneralRange.range(ORDERING, 4, lboundType, 2, uboundType);
          fail("Expected IAE");

            

Reported by PMD.

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

Line: 44

                    for (BoundType uboundType : BoundType.values()) {
        try {
          GeneralRange.range(ORDERING, 4, lboundType, 2, uboundType);
          fail("Expected IAE");
        } catch (IllegalArgumentException 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: 51

                  }
  }

  public void testCreateEmptyRangeOpenOpenFails() {
    for (Integer i : IN_ORDER_VALUES) {
      try {
        GeneralRange.range(ORDERING, i, OPEN, i, OPEN);
        fail("Expected IAE");
      } catch (IllegalArgumentException expected) {

            

Reported by PMD.

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

Line: 55

                  for (Integer i : IN_ORDER_VALUES) {
      try {
        GeneralRange.range(ORDERING, i, OPEN, i, OPEN);
        fail("Expected IAE");
      } catch (IllegalArgumentException 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: 61

                  }
  }

  public void testCreateEmptyRangeClosedOpenSucceeds() {
    for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 65

                  for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }
    }
  }

  public void testCreateEmptyRangeOpenClosedSucceeds() {

            

Reported by PMD.

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

Line: 65

                  for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }
    }
  }

  public void testCreateEmptyRangeOpenClosedSucceeds() {

            

Reported by PMD.

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

Line: 70

                  }
  }

  public void testCreateEmptyRangeOpenClosedSucceeds() {
    for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, OPEN, i, CLOSED);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }

            

Reported by PMD.

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

Line: 74

                  for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, OPEN, i, CLOSED);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }
    }
  }

  public void testCreateSingletonRangeSucceeds() {

            

Reported by PMD.

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

Line: 34

               * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class GeneralRangeTest extends TestCase {
  private static final Ordering<Integer> ORDERING = Ordering.natural().nullsFirst();

  private static final List<Integer> IN_ORDER_VALUES = Arrays.asList(null, 1, 2, 3, 4, 5);

  public void testCreateEmptyRangeFails() {

            

Reported by PMD.

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

Line: 39

              
  private static final List<Integer> IN_ORDER_VALUES = Arrays.asList(null, 1, 2, 3, 4, 5);

  public void testCreateEmptyRangeFails() {
    for (BoundType lboundType : BoundType.values()) {
      for (BoundType uboundType : BoundType.values()) {
        try {
          GeneralRange.range(ORDERING, 4, lboundType, 2, uboundType);
          fail("Expected IAE");

            

Reported by PMD.

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

Line: 44

                    for (BoundType uboundType : BoundType.values()) {
        try {
          GeneralRange.range(ORDERING, 4, lboundType, 2, uboundType);
          fail("Expected IAE");
        } catch (IllegalArgumentException 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: 51

                  }
  }

  public void testCreateEmptyRangeOpenOpenFails() {
    for (Integer i : IN_ORDER_VALUES) {
      try {
        GeneralRange.range(ORDERING, i, OPEN, i, OPEN);
        fail("Expected IAE");
      } catch (IllegalArgumentException expected) {

            

Reported by PMD.

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

Line: 55

                  for (Integer i : IN_ORDER_VALUES) {
      try {
        GeneralRange.range(ORDERING, i, OPEN, i, OPEN);
        fail("Expected IAE");
      } catch (IllegalArgumentException 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: 61

                  }
  }

  public void testCreateEmptyRangeClosedOpenSucceeds() {
    for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 65

                  for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }
    }
  }

  public void testCreateEmptyRangeOpenClosedSucceeds() {

            

Reported by PMD.

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

Line: 65

                  for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }
    }
  }

  public void testCreateEmptyRangeOpenClosedSucceeds() {

            

Reported by PMD.

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

Line: 70

                  }
  }

  public void testCreateEmptyRangeOpenClosedSucceeds() {
    for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, OPEN, i, CLOSED);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 74

                  for (Integer i : IN_ORDER_VALUES) {
      GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, OPEN, i, CLOSED);
      for (Integer j : IN_ORDER_VALUES) {
        assertFalse(range.contains(j));
      }
    }
  }

  public void testCreateSingletonRangeSucceeds() {

            

Reported by PMD.