The following issues were found

guava/src/com/google/common/collect/TreeRangeSet.java
166 issues
Avoid reassigning parameters such as 'subWindow'
Design

Line: 477

                    this.complementLowerBoundWindow = window;
    }

    private NavigableMap<Cut<C>, Range<C>> subMap(Range<Cut<C>> subWindow) {
      if (!complementLowerBoundWindow.isConnected(subWindow)) {
        return ImmutableSortedMap.of();
      } else {
        subWindow = subWindow.intersection(complementLowerBoundWindow);
        return new ComplementRangesByLowerBound<C>(positiveRangesByLowerBound, subWindow);

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.collect;

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

import com.google.common.annotations.Beta;

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 44

              @Beta
@GwtIncompatible // uses NavigableMap
@ElementTypesAreNonnullByDefault
public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C>
    implements Serializable {

  @VisibleForTesting final NavigableMap<Cut<C>, Range<C>> rangesByLowerBound;

  /** Creates an empty {@code TreeRangeSet} instance. */

            

Reported by PMD.

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

Line: 45

              @GwtIncompatible // uses NavigableMap
@ElementTypesAreNonnullByDefault
public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C>
    implements Serializable {

  @VisibleForTesting final NavigableMap<Cut<C>, Range<C>> rangesByLowerBound;

  /** Creates an empty {@code TreeRangeSet} instance. */
  public static <C extends Comparable<?>> TreeRangeSet<C> create() {

            

Reported by PMD.

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

Line: 47

              public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C>
    implements Serializable {

  @VisibleForTesting final NavigableMap<Cut<C>, Range<C>> rangesByLowerBound;

  /** Creates an empty {@code TreeRangeSet} instance. */
  public static <C extends Comparable<?>> TreeRangeSet<C> create() {
    return new TreeRangeSet<C>(new TreeMap<Cut<C>, Range<C>>());
  }

            

Reported by PMD.

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

Line: 57

                /** Returns a {@code TreeRangeSet} initialized with the ranges in the specified range set. */
  public static <C extends Comparable<?>> TreeRangeSet<C> create(RangeSet<C> rangeSet) {
    TreeRangeSet<C> result = create();
    result.addAll(rangeSet);
    return result;
  }

  /**
   * Returns a {@code TreeRangeSet} representing the union of the specified ranges.

            

Reported by PMD.

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

Line: 72

                 */
  public static <C extends Comparable<?>> TreeRangeSet<C> create(Iterable<Range<C>> ranges) {
    TreeRangeSet<C> result = create();
    result.addAll(ranges);
    return result;
  }

  private TreeRangeSet(NavigableMap<Cut<C>, Range<C>> rangesByLowerCut) {
    this.rangesByLowerBound = rangesByLowerCut;

            

Reported by PMD.

Field asRanges has the same name as a method
Error

Line: 80

                  this.rangesByLowerBound = rangesByLowerCut;
  }

  @CheckForNull private transient Set<Range<C>> asRanges;
  @CheckForNull private transient Set<Range<C>> asDescendingSetOfRanges;

  @Override
  public Set<Range<C>> asRanges() {
    Set<Range<C>> result = asRanges;

            

Reported by PMD.

Field asDescendingSetOfRanges has the same name as a method
Error

Line: 81

                }

  @CheckForNull private transient Set<Range<C>> asRanges;
  @CheckForNull private transient Set<Range<C>> asDescendingSetOfRanges;

  @Override
  public Set<Range<C>> asRanges() {
    Set<Range<C>> result = asRanges;
    return (result == null) ? asRanges = new AsRanges(rangesByLowerBound.values()) : result;

            

Reported by PMD.

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

Line: 93

                public Set<Range<C>> asDescendingSetOfRanges() {
    Set<Range<C>> result = asDescendingSetOfRanges;
    return (result == null)
        ? asDescendingSetOfRanges = new AsRanges(rangesByLowerBound.descendingMap().values())
        : result;
  }

  final class AsRanges extends ForwardingCollection<Range<C>> implements Set<Range<C>> {


            

Reported by PMD.

android/guava/src/com/google/common/collect/TreeRangeSet.java
166 issues
Avoid reassigning parameters such as 'subWindow'
Design

Line: 477

                    this.complementLowerBoundWindow = window;
    }

    private NavigableMap<Cut<C>, Range<C>> subMap(Range<Cut<C>> subWindow) {
      if (!complementLowerBoundWindow.isConnected(subWindow)) {
        return ImmutableSortedMap.of();
      } else {
        subWindow = subWindow.intersection(complementLowerBoundWindow);
        return new ComplementRangesByLowerBound<C>(positiveRangesByLowerBound, subWindow);

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.collect;

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

import com.google.common.annotations.Beta;

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 44

              @Beta
@GwtIncompatible // uses NavigableMap
@ElementTypesAreNonnullByDefault
public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C>
    implements Serializable {

  @VisibleForTesting final NavigableMap<Cut<C>, Range<C>> rangesByLowerBound;

  /** Creates an empty {@code TreeRangeSet} instance. */

            

Reported by PMD.

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

Line: 45

              @GwtIncompatible // uses NavigableMap
@ElementTypesAreNonnullByDefault
public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C>
    implements Serializable {

  @VisibleForTesting final NavigableMap<Cut<C>, Range<C>> rangesByLowerBound;

  /** Creates an empty {@code TreeRangeSet} instance. */
  public static <C extends Comparable<?>> TreeRangeSet<C> create() {

            

Reported by PMD.

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

Line: 47

              public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C>
    implements Serializable {

  @VisibleForTesting final NavigableMap<Cut<C>, Range<C>> rangesByLowerBound;

  /** Creates an empty {@code TreeRangeSet} instance. */
  public static <C extends Comparable<?>> TreeRangeSet<C> create() {
    return new TreeRangeSet<C>(new TreeMap<Cut<C>, Range<C>>());
  }

            

Reported by PMD.

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

Line: 57

                /** Returns a {@code TreeRangeSet} initialized with the ranges in the specified range set. */
  public static <C extends Comparable<?>> TreeRangeSet<C> create(RangeSet<C> rangeSet) {
    TreeRangeSet<C> result = create();
    result.addAll(rangeSet);
    return result;
  }

  /**
   * Returns a {@code TreeRangeSet} representing the union of the specified ranges.

            

Reported by PMD.

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

Line: 72

                 */
  public static <C extends Comparable<?>> TreeRangeSet<C> create(Iterable<Range<C>> ranges) {
    TreeRangeSet<C> result = create();
    result.addAll(ranges);
    return result;
  }

  private TreeRangeSet(NavigableMap<Cut<C>, Range<C>> rangesByLowerCut) {
    this.rangesByLowerBound = rangesByLowerCut;

            

Reported by PMD.

Field asRanges has the same name as a method
Error

Line: 80

                  this.rangesByLowerBound = rangesByLowerCut;
  }

  @CheckForNull private transient Set<Range<C>> asRanges;
  @CheckForNull private transient Set<Range<C>> asDescendingSetOfRanges;

  @Override
  public Set<Range<C>> asRanges() {
    Set<Range<C>> result = asRanges;

            

Reported by PMD.

Field asDescendingSetOfRanges has the same name as a method
Error

Line: 81

                }

  @CheckForNull private transient Set<Range<C>> asRanges;
  @CheckForNull private transient Set<Range<C>> asDescendingSetOfRanges;

  @Override
  public Set<Range<C>> asRanges() {
    Set<Range<C>> result = asRanges;
    return (result == null) ? asRanges = new AsRanges(rangesByLowerBound.values()) : result;

            

Reported by PMD.

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

Line: 93

                public Set<Range<C>> asDescendingSetOfRanges() {
    Set<Range<C>> result = asDescendingSetOfRanges;
    return (result == null)
        ? asDescendingSetOfRanges = new AsRanges(rangesByLowerBound.descendingMap().values())
        : result;
  }

  final class AsRanges extends ForwardingCollection<Range<C>> implements Set<Range<C>> {


            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
163 issues
Class contains more than one logger.
Error

Line: 52

               * @author Luke Sandberg
 * @author Chris Nokleberg
 */
public class ServiceManagerTest extends TestCase {

  private static class NoOpService extends AbstractService {
    @Override
    protected void doStart() {
      notifyStarted();

            

Reported by PMD.

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

Line: 52

               * @author Luke Sandberg
 * @author Chris Nokleberg
 */
public class ServiceManagerTest extends TestCase {

  private static class NoOpService extends AbstractService {
    @Override
    protected void doStart() {
      notifyStarted();

            

Reported by PMD.

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

Line: 52

               * @author Luke Sandberg
 * @author Chris Nokleberg
 */
public class ServiceManagerTest extends TestCase {

  private static class NoOpService extends AbstractService {
    @Override
    protected void doStart() {
      notifyStarted();

            

Reported by PMD.

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

Line: 52

               * @author Luke Sandberg
 * @author Chris Nokleberg
 */
public class ServiceManagerTest extends TestCase {

  private static class NoOpService extends AbstractService {
    @Override
    protected void doStart() {
      notifyStarted();

            

Reported by PMD.

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

Line: 71

                 * of time.
   */
  private static class NoOpDelayedService extends NoOpService {
    private long delay;

    public NoOpDelayedService(long delay) {
      this.delay = delay;
    }


            

Reported by PMD.

Private field 'delay' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 71

                 * of time.
   */
  private static class NoOpDelayedService extends NoOpService {
    private long delay;

    public NoOpDelayedService(long delay) {
      this.delay = delay;
    }


            

Reported by PMD.

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

Line: 123

                }


  public void testServiceStartupTimes() {
    Service a = new NoOpDelayedService(150);
    Service b = new NoOpDelayedService(353);
    ServiceManager serviceManager = new ServiceManager(asList(a, b));
    serviceManager.startAsync().awaitHealthy();
    ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();

            

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

                }


  public void testServiceStartupTimes() {
    Service a = new NoOpDelayedService(150);
    Service b = new NoOpDelayedService(353);
    ServiceManager serviceManager = new ServiceManager(asList(a, b));
    serviceManager.startAsync().awaitHealthy();
    ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();

            

Reported by PMD.

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

Line: 127

                  Service a = new NoOpDelayedService(150);
    Service b = new NoOpDelayedService(353);
    ServiceManager serviceManager = new ServiceManager(asList(a, b));
    serviceManager.startAsync().awaitHealthy();
    ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();
    assertThat(startupTimes).hasSize(2);
    assertThat(startupTimes.get(a)).isAtLeast(150);
    assertThat(startupTimes.get(b)).isAtLeast(353);
  }

            

Reported by PMD.

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

Line: 129

                  ServiceManager serviceManager = new ServiceManager(asList(a, b));
    serviceManager.startAsync().awaitHealthy();
    ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();
    assertThat(startupTimes).hasSize(2);
    assertThat(startupTimes.get(a)).isAtLeast(150);
    assertThat(startupTimes.get(b)).isAtLeast(353);
  }



            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/MultisetNavigationTester.java
158 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * limitations under the License.
 */

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

import static com.google.common.collect.BoundType.CLOSED;
import static com.google.common.collect.BoundType.OPEN;
import static com.google.common.collect.testing.Helpers.copyToList;
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;

            

Reported by PMD.

The class 'MultisetNavigationTester' has a total cyclomatic complexity of 84 (highest 4).
Design

Line: 49

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

            

Reported by PMD.

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

Line: 49

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

            

Reported by PMD.

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

Line: 50

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;


            

Reported by PMD.

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

Line: 51

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */

            

Reported by PMD.

Perhaps 'entries' could be replaced by a local variable.
Design

Line: 51

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */

            

Reported by PMD.

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

Line: 52

              public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
  static <T> SortedMultiset<T> cast(Multiset<T> iterable) {

            

Reported by PMD.

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

Line: 53

                private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
  static <T> SortedMultiset<T> cast(Multiset<T> iterable) {
    return (SortedMultiset<T>) iterable;

            

Reported by PMD.

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

Line: 54

                private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
  static <T> SortedMultiset<T> cast(Multiset<T> iterable) {
    return (SortedMultiset<T>) iterable;
  }

            

Reported by PMD.

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

Line: 61

                  return (SortedMultiset<T>) iterable;
  }

  @Override
  public void setUp() throws Exception {
    super.setUp();
    sortedMultiset = cast(getMultiset());
    entries =
        copyToList(

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultisetNavigationTester.java
158 issues
This class has a bunch of public methods and attributes
Design

Line: 15

               * limitations under the License.
 */

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

import static com.google.common.collect.BoundType.CLOSED;
import static com.google.common.collect.BoundType.OPEN;
import static com.google.common.collect.testing.Helpers.copyToList;
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;

            

Reported by PMD.

The class 'MultisetNavigationTester' has a total cyclomatic complexity of 84 (highest 4).
Design

Line: 49

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

            

Reported by PMD.

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

Line: 49

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

            

Reported by PMD.

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

Line: 50

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;


            

Reported by PMD.

Perhaps 'entries' could be replaced by a local variable.
Design

Line: 51

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */

            

Reported by PMD.

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

Line: 51

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */

            

Reported by PMD.

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

Line: 52

              public class MultisetNavigationTester<E> extends AbstractMultisetTester<E> {
  private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
  static <T> SortedMultiset<T> cast(Multiset<T> iterable) {

            

Reported by PMD.

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

Line: 53

                private SortedMultiset<E> sortedMultiset;
  private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
  static <T> SortedMultiset<T> cast(Multiset<T> iterable) {
    return (SortedMultiset<T>) iterable;

            

Reported by PMD.

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

Line: 54

                private List<E> entries;
  private Entry<E> a;
  private Entry<E> b;
  private Entry<E> c;

  /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
  static <T> SortedMultiset<T> cast(Multiset<T> iterable) {
    return (SortedMultiset<T>) iterable;
  }

            

Reported by PMD.

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

Line: 61

                  return (SortedMultiset<T>) iterable;
  }

  @Override
  public void setUp() throws Exception {
    super.setUp();
    sortedMultiset = cast(getMultiset());
    entries =
        copyToList(

            

Reported by PMD.

android/guava-tests/test/com/google/common/base/CaseFormatTest.java
157 issues
This class has too many methods, consider refactoring it.
Design

Line: 37

               * @author Mike Bostock
 */
@GwtCompatible(emulated = true)
public class CaseFormatTest extends TestCase {

  public void testIdentity() {
    for (CaseFormat from : CaseFormat.values()) {
      assertSame(from + " to " + from, "foo", from.to(from, "foo"));
      for (CaseFormat to : CaseFormat.values()) {

            

Reported by PMD.

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

Line: 39

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

  public void testIdentity() {
    for (CaseFormat from : CaseFormat.values()) {
      assertSame(from + " to " + from, "foo", from.to(from, "foo"));
      for (CaseFormat to : CaseFormat.values()) {
        assertEquals(from + " to " + to, "", from.to(to, ""));
        assertEquals(from + " to " + to, " ", from.to(to, " "));

            

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

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

  public void testIdentity() {
    for (CaseFormat from : CaseFormat.values()) {
      assertSame(from + " to " + from, "foo", from.to(from, "foo"));
      for (CaseFormat to : CaseFormat.values()) {
        assertEquals(from + " to " + to, "", from.to(to, ""));
        assertEquals(from + " to " + to, " ", from.to(to, " "));

            

Reported by PMD.

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

Line: 41

              
  public void testIdentity() {
    for (CaseFormat from : CaseFormat.values()) {
      assertSame(from + " to " + from, "foo", from.to(from, "foo"));
      for (CaseFormat to : CaseFormat.values()) {
        assertEquals(from + " to " + to, "", from.to(to, ""));
        assertEquals(from + " to " + to, " ", from.to(to, " "));
      }
    }

            

Reported by PMD.

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

Line: 49

                  }
  }

  @GwtIncompatible // NullPointerTester
  public void testNullArguments() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(CaseFormat.class);
    for (CaseFormat format : CaseFormat.values()) {
      tester.testAllPublicInstanceMethods(format);

            

Reported by PMD.

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

Line: 50

                }

  @GwtIncompatible // NullPointerTester
  public void testNullArguments() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(CaseFormat.class);
    for (CaseFormat format : CaseFormat.values()) {
      tester.testAllPublicInstanceMethods(format);
    }

            

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

                  }
  }

  public void testLowerHyphenToLowerHyphen() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo"));
    assertEquals("foo-bar", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo-bar"));
  }

  public void testLowerHyphenToLowerUnderscore() {

            

Reported by PMD.

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

Line: 58

                  }
  }

  public void testLowerHyphenToLowerHyphen() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo"));
    assertEquals("foo-bar", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo-bar"));
  }

  public void testLowerHyphenToLowerUnderscore() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 59

                }

  public void testLowerHyphenToLowerHyphen() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo"));
    assertEquals("foo-bar", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo-bar"));
  }

  public void testLowerHyphenToLowerUnderscore() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_UNDERSCORE, "foo"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 60

              
  public void testLowerHyphenToLowerHyphen() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo"));
    assertEquals("foo-bar", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo-bar"));
  }

  public void testLowerHyphenToLowerUnderscore() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_UNDERSCORE, "foo"));
    assertEquals("foo_bar", LOWER_HYPHEN.to(LOWER_UNDERSCORE, "foo-bar"));

            

Reported by PMD.

guava-tests/test/com/google/common/base/CaseFormatTest.java
157 issues
This class has too many methods, consider refactoring it.
Design

Line: 37

               * @author Mike Bostock
 */
@GwtCompatible(emulated = true)
public class CaseFormatTest extends TestCase {

  public void testIdentity() {
    for (CaseFormat from : CaseFormat.values()) {
      assertSame(from + " to " + from, "foo", from.to(from, "foo"));
      for (CaseFormat to : CaseFormat.values()) {

            

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

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

  public void testIdentity() {
    for (CaseFormat from : CaseFormat.values()) {
      assertSame(from + " to " + from, "foo", from.to(from, "foo"));
      for (CaseFormat to : CaseFormat.values()) {
        assertEquals(from + " to " + to, "", from.to(to, ""));
        assertEquals(from + " to " + to, " ", from.to(to, " "));

            

Reported by PMD.

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

Line: 39

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

  public void testIdentity() {
    for (CaseFormat from : CaseFormat.values()) {
      assertSame(from + " to " + from, "foo", from.to(from, "foo"));
      for (CaseFormat to : CaseFormat.values()) {
        assertEquals(from + " to " + to, "", from.to(to, ""));
        assertEquals(from + " to " + to, " ", from.to(to, " "));

            

Reported by PMD.

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

Line: 41

              
  public void testIdentity() {
    for (CaseFormat from : CaseFormat.values()) {
      assertSame(from + " to " + from, "foo", from.to(from, "foo"));
      for (CaseFormat to : CaseFormat.values()) {
        assertEquals(from + " to " + to, "", from.to(to, ""));
        assertEquals(from + " to " + to, " ", from.to(to, " "));
      }
    }

            

Reported by PMD.

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

Line: 49

                  }
  }

  @GwtIncompatible // NullPointerTester
  public void testNullArguments() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(CaseFormat.class);
    for (CaseFormat format : CaseFormat.values()) {
      tester.testAllPublicInstanceMethods(format);

            

Reported by PMD.

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

Line: 50

                }

  @GwtIncompatible // NullPointerTester
  public void testNullArguments() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(CaseFormat.class);
    for (CaseFormat format : CaseFormat.values()) {
      tester.testAllPublicInstanceMethods(format);
    }

            

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

                  }
  }

  public void testLowerHyphenToLowerHyphen() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo"));
    assertEquals("foo-bar", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo-bar"));
  }

  public void testLowerHyphenToLowerUnderscore() {

            

Reported by PMD.

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

Line: 58

                  }
  }

  public void testLowerHyphenToLowerHyphen() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo"));
    assertEquals("foo-bar", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo-bar"));
  }

  public void testLowerHyphenToLowerUnderscore() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 59

                }

  public void testLowerHyphenToLowerHyphen() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo"));
    assertEquals("foo-bar", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo-bar"));
  }

  public void testLowerHyphenToLowerUnderscore() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_UNDERSCORE, "foo"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 60

              
  public void testLowerHyphenToLowerHyphen() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo"));
    assertEquals("foo-bar", LOWER_HYPHEN.to(LOWER_HYPHEN, "foo-bar"));
  }

  public void testLowerHyphenToLowerUnderscore() {
    assertEquals("foo", LOWER_HYPHEN.to(LOWER_UNDERSCORE, "foo"));
    assertEquals("foo_bar", LOWER_HYPHEN.to(LOWER_UNDERSCORE, "foo-bar"));

            

Reported by PMD.

guava-tests/test/com/google/common/cache/CacheEvictionTest.java
156 issues
This class has too many methods, consider refactoring it.
Design

Line: 38

               *
 * @author mike nonemacher
 */
public class CacheEvictionTest extends TestCase {
  static final int MAX_SIZE = 100;

  public void testEviction_setMaxSegmentSize() {
    IdentityLoader<Object> loader = identityLoader();
    for (int i = 1; i < 1000; i++) {

            

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

              public class CacheEvictionTest extends TestCase {
  static final int MAX_SIZE = 100;

  public void testEviction_setMaxSegmentSize() {
    IdentityLoader<Object> loader = identityLoader();
    for (int i = 1; i < 1000; i++) {
      LoadingCache<Object, Object> cache = CacheBuilder.newBuilder().maximumSize(i).build(loader);
      assertEquals(i, CacheTesting.getTotalSegmentSize(cache));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  IdentityLoader<Object> loader = identityLoader();
    for (int i = 1; i < 1000; i++) {
      LoadingCache<Object, Object> cache = CacheBuilder.newBuilder().maximumSize(i).build(loader);
      assertEquals(i, CacheTesting.getTotalSegmentSize(cache));
    }
  }

  public void testEviction_setMaxSegmentWeight() {
    IdentityLoader<Object> loader = identityLoader();

            

Reported by PMD.

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

Line: 49

                  }
  }

  public void testEviction_setMaxSegmentWeight() {
    IdentityLoader<Object> loader = identityLoader();
    for (int i = 1; i < 1000; i++) {
      LoadingCache<Object, Object> cache =
          CacheBuilder.newBuilder().maximumWeight(i).weigher(constantWeigher(1)).build(loader);
      assertEquals(i, CacheTesting.getTotalSegmentSize(cache));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 54

                  for (int i = 1; i < 1000; i++) {
      LoadingCache<Object, Object> cache =
          CacheBuilder.newBuilder().maximumWeight(i).weigher(constantWeigher(1)).build(loader);
      assertEquals(i, CacheTesting.getTotalSegmentSize(cache));
    }
  }

  public void testEviction_maxSizeOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();

            

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

                  }
  }

  public void testEviction_maxSizeOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();
    LoadingCache<Integer, Integer> cache =
        CacheBuilder.newBuilder().concurrencyLevel(1).maximumSize(MAX_SIZE).build(loader);
    for (int i = 0; i < 2 * MAX_SIZE; i++) {
      cache.getUnchecked(i);

            

Reported by PMD.

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

Line: 58

                  }
  }

  public void testEviction_maxSizeOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();
    LoadingCache<Integer, Integer> cache =
        CacheBuilder.newBuilder().concurrencyLevel(1).maximumSize(MAX_SIZE).build(loader);
    for (int i = 0; i < 2 * MAX_SIZE; i++) {
      cache.getUnchecked(i);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 64

                      CacheBuilder.newBuilder().concurrencyLevel(1).maximumSize(MAX_SIZE).build(loader);
    for (int i = 0; i < 2 * MAX_SIZE; i++) {
      cache.getUnchecked(i);
      assertEquals(Math.min(i + 1, MAX_SIZE), cache.size());
    }

    assertEquals(MAX_SIZE, cache.size());
    CacheTesting.checkValidState(cache);
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 67

                    assertEquals(Math.min(i + 1, MAX_SIZE), cache.size());
    }

    assertEquals(MAX_SIZE, cache.size());
    CacheTesting.checkValidState(cache);
  }

  public void testEviction_maxWeightOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();

            

Reported by PMD.

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

Line: 67

                    assertEquals(Math.min(i + 1, MAX_SIZE), cache.size());
    }

    assertEquals(MAX_SIZE, cache.size());
    CacheTesting.checkValidState(cache);
  }

  public void testEviction_maxWeightOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/CacheEvictionTest.java
156 issues
This class has too many methods, consider refactoring it.
Design

Line: 38

               *
 * @author mike nonemacher
 */
public class CacheEvictionTest extends TestCase {
  static final int MAX_SIZE = 100;

  public void testEviction_setMaxSegmentSize() {
    IdentityLoader<Object> loader = identityLoader();
    for (int i = 1; i < 1000; i++) {

            

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

              public class CacheEvictionTest extends TestCase {
  static final int MAX_SIZE = 100;

  public void testEviction_setMaxSegmentSize() {
    IdentityLoader<Object> loader = identityLoader();
    for (int i = 1; i < 1000; i++) {
      LoadingCache<Object, Object> cache = CacheBuilder.newBuilder().maximumSize(i).build(loader);
      assertEquals(i, CacheTesting.getTotalSegmentSize(cache));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  IdentityLoader<Object> loader = identityLoader();
    for (int i = 1; i < 1000; i++) {
      LoadingCache<Object, Object> cache = CacheBuilder.newBuilder().maximumSize(i).build(loader);
      assertEquals(i, CacheTesting.getTotalSegmentSize(cache));
    }
  }

  public void testEviction_setMaxSegmentWeight() {
    IdentityLoader<Object> loader = identityLoader();

            

Reported by PMD.

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

Line: 49

                  }
  }

  public void testEviction_setMaxSegmentWeight() {
    IdentityLoader<Object> loader = identityLoader();
    for (int i = 1; i < 1000; i++) {
      LoadingCache<Object, Object> cache =
          CacheBuilder.newBuilder().maximumWeight(i).weigher(constantWeigher(1)).build(loader);
      assertEquals(i, CacheTesting.getTotalSegmentSize(cache));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 54

                  for (int i = 1; i < 1000; i++) {
      LoadingCache<Object, Object> cache =
          CacheBuilder.newBuilder().maximumWeight(i).weigher(constantWeigher(1)).build(loader);
      assertEquals(i, CacheTesting.getTotalSegmentSize(cache));
    }
  }

  public void testEviction_maxSizeOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();

            

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

                  }
  }

  public void testEviction_maxSizeOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();
    LoadingCache<Integer, Integer> cache =
        CacheBuilder.newBuilder().concurrencyLevel(1).maximumSize(MAX_SIZE).build(loader);
    for (int i = 0; i < 2 * MAX_SIZE; i++) {
      cache.getUnchecked(i);

            

Reported by PMD.

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

Line: 58

                  }
  }

  public void testEviction_maxSizeOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();
    LoadingCache<Integer, Integer> cache =
        CacheBuilder.newBuilder().concurrencyLevel(1).maximumSize(MAX_SIZE).build(loader);
    for (int i = 0; i < 2 * MAX_SIZE; i++) {
      cache.getUnchecked(i);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 64

                      CacheBuilder.newBuilder().concurrencyLevel(1).maximumSize(MAX_SIZE).build(loader);
    for (int i = 0; i < 2 * MAX_SIZE; i++) {
      cache.getUnchecked(i);
      assertEquals(Math.min(i + 1, MAX_SIZE), cache.size());
    }

    assertEquals(MAX_SIZE, cache.size());
    CacheTesting.checkValidState(cache);
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 67

                    assertEquals(Math.min(i + 1, MAX_SIZE), cache.size());
    }

    assertEquals(MAX_SIZE, cache.size());
    CacheTesting.checkValidState(cache);
  }

  public void testEviction_maxWeightOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();

            

Reported by PMD.

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

Line: 67

                    assertEquals(Math.min(i + 1, MAX_SIZE), cache.size());
    }

    assertEquals(MAX_SIZE, cache.size());
    CacheTesting.checkValidState(cache);
  }

  public void testEviction_maxWeightOneSegment() {
    IdentityLoader<Integer> loader = identityLoader();

            

Reported by PMD.

guava-tests/test/com/google/common/base/SuppliersTest.java
154 issues
Avoid throwing null pointer exceptions.
Design

Line: 63

                static class ThrowingSupplier implements Supplier<Integer> {
    @Override
    public Integer get() {
      throw new NullPointerException();
    }
  }

  static class SerializableCountingSupplier extends CountingSupplier implements Serializable {
    private static final long serialVersionUID = 0L;

            

Reported by PMD.

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

Line: 43

               * @author Harry Heymann
 */
@GwtCompatible(emulated = true)
public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override

            

Reported by PMD.

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

Line: 43

               * @author Harry Heymann
 */
@GwtCompatible(emulated = true)
public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override

            

Reported by PMD.

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

Line: 43

               * @author Harry Heymann
 */
@GwtCompatible(emulated = true)
public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override

            

Reported by PMD.

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

Line: 46

              public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override
    public Integer get() {
      calls++;
      return calls * 10;

            

Reported by PMD.

Avoid using redundant field initializer for 'calls'
Performance

Line: 46

              public class SuppliersTest extends TestCase {

  static class CountingSupplier implements Supplier<Integer> {
    int calls = 0;

    @Override
    public Integer get() {
      calls++;
      return calls * 10;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 77

              
  static void checkMemoize(CountingSupplier countingSupplier, Supplier<Integer> memoizedSupplier) {
    // the underlying supplier hasn't executed yet
    assertEquals(0, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

    // now it has
    assertEquals(1, countingSupplier.calls);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 79

                  // the underlying supplier hasn't executed yet
    assertEquals(0, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

    // now it has
    assertEquals(1, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 82

                  assertEquals(10, (int) memoizedSupplier.get());

    // now it has
    assertEquals(1, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

    // it still should only have executed once due to memoization
    assertEquals(1, countingSupplier.calls);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 84

                  // now it has
    assertEquals(1, countingSupplier.calls);

    assertEquals(10, (int) memoizedSupplier.get());

    // it still should only have executed once due to memoization
    assertEquals(1, countingSupplier.calls);
  }


            

Reported by PMD.