The following issues were found

guava-tests/test/com/google/common/base/AsciiTest.java
80 issues
Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 134

                  assertTrue(Ascii.equalsIgnoreCase(LOWER, UPPER));
    assertTrue(Ascii.equalsIgnoreCase(UPPER, LOWER));
    // Create new strings here to avoid early-out logic.
    assertTrue(Ascii.equalsIgnoreCase(new String(IGNORED), new String(IGNORED)));
    // Compare to: "\u00c1".equalsIgnoreCase("\u00e1") == true
    assertFalse(Ascii.equalsIgnoreCase("\u00c1", "\u00e1"));
    // Test chars just outside the alphabetic range ('A'-1 vs 'a'-1, 'Z'+1 vs 'z'+1)
    assertFalse(Ascii.equalsIgnoreCase("@", "`"));
    assertFalse(Ascii.equalsIgnoreCase("[", "{"));

            

Reported by PMD.

Avoid instantiating String objects; this is usually unnecessary.
Performance

Line: 134

                  assertTrue(Ascii.equalsIgnoreCase(LOWER, UPPER));
    assertTrue(Ascii.equalsIgnoreCase(UPPER, LOWER));
    // Create new strings here to avoid early-out logic.
    assertTrue(Ascii.equalsIgnoreCase(new String(IGNORED), new String(IGNORED)));
    // Compare to: "\u00c1".equalsIgnoreCase("\u00e1") == true
    assertFalse(Ascii.equalsIgnoreCase("\u00c1", "\u00e1"));
    // Test chars just outside the alphabetic range ('A'-1 vs 'a'-1, 'Z'+1 vs 'z'+1)
    assertFalse(Ascii.equalsIgnoreCase("@", "`"));
    assertFalse(Ascii.equalsIgnoreCase("[", "{"));

            

Reported by PMD.

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

Line: 40

                private static final String LOWER = "abcdefghijklmnopqrstuvwxyz";
  private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

            

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

                private static final String LOWER = "abcdefghijklmnopqrstuvwxyz";
  private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

                private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

              
  public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

                public void testToLowerCase() {
    assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {
    assertEquals(UPPER, Ascii.toUpperCase(LOWER));

            

Reported by PMD.

The String literal 'foobar' appears 19 times in this file; the first occurrence is on line 44
Error

Line: 44

                  assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {
    assertEquals(UPPER, Ascii.toUpperCase(LOWER));
    assertSame(UPPER, Ascii.toUpperCase(UPPER));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 44

                  assertEquals(LOWER, Ascii.toLowerCase(UPPER));
    assertSame(LOWER, Ascii.toLowerCase(LOWER));
    assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
    assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {
    assertEquals(UPPER, Ascii.toUpperCase(LOWER));
    assertSame(UPPER, Ascii.toUpperCase(UPPER));

            

Reported by PMD.

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

Line: 47

                  assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
  }

  public void testToUpperCase() {
    assertEquals(UPPER, Ascii.toUpperCase(LOWER));
    assertSame(UPPER, Ascii.toUpperCase(UPPER));
    assertEquals(IGNORED, Ascii.toUpperCase(IGNORED));
    assertEquals("FOOBAR", Ascii.toUpperCase("FoOBAr"));
  }

            

Reported by PMD.

guava/src/com/google/common/graph/Graphs.java
79 issues
This class has a bunch of public methods and attributes
Design

Line: 17

               * limitations under the License.
 */

package com.google.common.graph;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.graph.GraphConstants.NODE_NOT_IN_GRAPH;
import static java.util.Objects.requireNonNull;


            

Reported by PMD.

Possible God Class (WMC=71, ATFD=13, TCC=0.000%)
Design

Line: 48

               */
@Beta
@ElementTypesAreNonnullByDefault
public final class Graphs {

  private Graphs() {}

  // Graph query methods


            

Reported by PMD.

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

Line: 48

               */
@Beta
@ElementTypesAreNonnullByDefault
public final class Graphs {

  private Graphs() {}

  // Graph query methods


            

Reported by PMD.

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

Line: 62

                 * <p>This method will detect any non-empty cycle, including self-loops (a cycle of length 1).
   */
  public static <N> boolean hasCycle(Graph<N> graph) {
    int numEdges = graph.edges().size();
    if (numEdges == 0) {
      return false; // An edge-free graph is acyclic by definition.
    }
    if (!graph.isDirected() && numEdges >= graph.nodes().size()) {
      return true; // Optimization for the undirected case: at least one cycle must exist.

            

Reported by PMD.

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

Line: 66

                  if (numEdges == 0) {
      return false; // An edge-free graph is acyclic by definition.
    }
    if (!graph.isDirected() && numEdges >= graph.nodes().size()) {
      return true; // Optimization for the undirected case: at least one cycle must exist.
    }

    Map<Object, NodeVisitState> visitedNodes =
        Maps.newHashMapWithExpectedSize(graph.nodes().size());

            

Reported by PMD.

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

Line: 71

                  }

    Map<Object, NodeVisitState> visitedNodes =
        Maps.newHashMapWithExpectedSize(graph.nodes().size());
    for (N node : graph.nodes()) {
      if (subgraphHasCycle(graph, visitedNodes, node, null)) {
        return true;
      }
    }

            

Reported by PMD.

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

Line: 92

                  // However, in an undirected graph, any parallel edge induces a cycle in the graph.
    if (!network.isDirected()
        && network.allowsParallelEdges()
        && network.edges().size() > network.asGraph().edges().size()) {
      return true;
    }
    return hasCycle(network.asGraph());
  }


            

Reported by PMD.

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

Line: 92

                  // However, in an undirected graph, any parallel edge induces a cycle in the graph.
    if (!network.isDirected()
        && network.allowsParallelEdges()
        && network.edges().size() > network.asGraph().edges().size()) {
      return true;
    }
    return hasCycle(network.asGraph());
  }


            

Reported by PMD.

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

Line: 92

                  // However, in an undirected graph, any parallel edge induces a cycle in the graph.
    if (!network.isDirected()
        && network.allowsParallelEdges()
        && network.edges().size() > network.asGraph().edges().size()) {
      return true;
    }
    return hasCycle(network.asGraph());
  }


            

Reported by PMD.

Avoid unnecessary if..then..else statements when returning booleans
Design

Line: 135

                 */
  private static boolean canTraverseWithoutReusingEdge(
      Graph<?> graph, Object nextNode, @CheckForNull Object previousNode) {
    if (graph.isDirected() || !Objects.equal(previousNode, nextNode)) {
      return true;
    }
    // This falls into the undirected A->B->A case. The Graph interface does not support parallel
    // edges, so this traversal would require reusing the undirected AB edge.
    return false;

            

Reported by PMD.

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

Line: 33

               * @author Kevin Bourrillion
 */
@GwtCompatible
public class StopwatchTest extends TestCase {

  private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testCreateStarted() {

            

Reported by PMD.

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

Line: 35

              @GwtCompatible
public class StopwatchTest extends TestCase {

  private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());

            

Reported by PMD.

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

Line: 36

              public class StopwatchTest extends TestCase {

  private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());
  }

            

Reported by PMD.

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

Line: 38

                private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {

            

Reported by PMD.

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

Line: 40

              
  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

              
  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());

            

Reported by PMD.

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

Line: 43

                  assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());
    assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
  }


            

Reported by PMD.

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

Line: 43

                  assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());
    assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
  }


            

Reported by PMD.

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

Line: 45

              
  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());
    assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
  }

  public void testInitialState() {
    assertFalse(stopwatch.isRunning());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

              
  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());
    assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
  }

  public void testInitialState() {
    assertFalse(stopwatch.isRunning());

            

Reported by PMD.

guava-tests/test/com/google/common/reflect/TypeResolverTest.java
79 issues
This class has too many methods, consider refactoring it.
Design

Line: 31

               * @author Ben Yu
 */
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeResolverTest extends TestCase {

  public void testWhere_noMapping() {
    Type t = aTypeVariable();
    assertEquals(t, new TypeResolver().resolveType(t));
  }

            

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

              @AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeResolverTest extends TestCase {

  public void testWhere_noMapping() {
    Type t = aTypeVariable();
    assertEquals(t, new TypeResolver().resolveType(t));
  }

  public void testWhere_typeVariableMapping() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

              
  public void testWhere_noMapping() {
    Type t = aTypeVariable();
    assertEquals(t, new TypeResolver().resolveType(t));
  }

  public void testWhere_typeVariableMapping() {
    Type t = aTypeVariable();
    assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));

            

Reported by PMD.

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

Line: 38

                  assertEquals(t, new TypeResolver().resolveType(t));
  }

  public void testWhere_typeVariableMapping() {
    Type t = aTypeVariable();
    assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
  }

  public <T> void testWhere_indirectMapping() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

              
  public void testWhere_typeVariableMapping() {
    Type t = aTypeVariable();
    assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
  }

  public <T> void testWhere_indirectMapping() {
    Type t1 = new TypeCapture<T>() {}.capture();
    Type t2 = aTypeVariable();

            

Reported by PMD.

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

Line: 43

                  assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
  }

  public <T> void testWhere_indirectMapping() {
    Type t1 = new TypeCapture<T>() {}.capture();
    Type t2 = aTypeVariable();
    assertEquals(
        String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                public <T> void testWhere_indirectMapping() {
    Type t1 = new TypeCapture<T>() {}.capture();
    Type t2 = aTypeVariable();
    assertEquals(
        String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
  }

  public void testWhere_typeVariableSelfMapping() {
    TypeResolver resolver = new TypeResolver();

            

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

                      String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
  }

  public void testWhere_typeVariableSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = aTypeVariable();
    assertEquals(t, resolver.where(t, t).resolveType(t));
  }


            

Reported by PMD.

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

Line: 53

                public void testWhere_typeVariableSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = aTypeVariable();
    assertEquals(t, resolver.where(t, t).resolveType(t));
  }

  public <T> void testWhere_parameterizedSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = new TypeCapture<List<T>>() {}.capture();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                public void testWhere_typeVariableSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = aTypeVariable();
    assertEquals(t, resolver.where(t, t).resolveType(t));
  }

  public <T> void testWhere_parameterizedSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = new TypeCapture<List<T>>() {}.capture();

            

Reported by PMD.

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

Line: 33

               * @author Kevin Bourrillion
 */
@GwtCompatible
public class StopwatchTest extends TestCase {

  private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testCreateStarted() {

            

Reported by PMD.

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

Line: 35

              @GwtCompatible
public class StopwatchTest extends TestCase {

  private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());

            

Reported by PMD.

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

Line: 36

              public class StopwatchTest extends TestCase {

  private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());
  }

            

Reported by PMD.

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

Line: 38

                private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {

            

Reported by PMD.

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

Line: 40

              
  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

              
  public void testCreateStarted() {
    Stopwatch startedStopwatch = Stopwatch.createStarted();
    assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());

            

Reported by PMD.

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

Line: 43

                  assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());
    assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
  }


            

Reported by PMD.

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

Line: 43

                  assertTrue(startedStopwatch.isRunning());
  }

  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());
    assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

              
  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());
    assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
  }

  public void testInitialState() {
    assertFalse(stopwatch.isRunning());

            

Reported by PMD.

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

Line: 45

              
  public void testCreateUnstarted() {
    Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
    assertFalse(unstartedStopwatch.isRunning());
    assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
  }

  public void testInitialState() {
    assertFalse(stopwatch.isRunning());

            

Reported by PMD.

android/guava-tests/test/com/google/common/reflect/TypeResolverTest.java
79 issues
This class has too many methods, consider refactoring it.
Design

Line: 31

               * @author Ben Yu
 */
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeResolverTest extends TestCase {

  public void testWhere_noMapping() {
    Type t = aTypeVariable();
    assertEquals(t, new TypeResolver().resolveType(t));
  }

            

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

              @AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeResolverTest extends TestCase {

  public void testWhere_noMapping() {
    Type t = aTypeVariable();
    assertEquals(t, new TypeResolver().resolveType(t));
  }

  public void testWhere_typeVariableMapping() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

              
  public void testWhere_noMapping() {
    Type t = aTypeVariable();
    assertEquals(t, new TypeResolver().resolveType(t));
  }

  public void testWhere_typeVariableMapping() {
    Type t = aTypeVariable();
    assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));

            

Reported by PMD.

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

Line: 38

                  assertEquals(t, new TypeResolver().resolveType(t));
  }

  public void testWhere_typeVariableMapping() {
    Type t = aTypeVariable();
    assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
  }

  public <T> void testWhere_indirectMapping() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

              
  public void testWhere_typeVariableMapping() {
    Type t = aTypeVariable();
    assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
  }

  public <T> void testWhere_indirectMapping() {
    Type t1 = new TypeCapture<T>() {}.capture();
    Type t2 = aTypeVariable();

            

Reported by PMD.

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

Line: 43

                  assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
  }

  public <T> void testWhere_indirectMapping() {
    Type t1 = new TypeCapture<T>() {}.capture();
    Type t2 = aTypeVariable();
    assertEquals(
        String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                public <T> void testWhere_indirectMapping() {
    Type t1 = new TypeCapture<T>() {}.capture();
    Type t2 = aTypeVariable();
    assertEquals(
        String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
  }

  public void testWhere_typeVariableSelfMapping() {
    TypeResolver resolver = new TypeResolver();

            

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

                      String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
  }

  public void testWhere_typeVariableSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = aTypeVariable();
    assertEquals(t, resolver.where(t, t).resolveType(t));
  }


            

Reported by PMD.

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

Line: 53

                public void testWhere_typeVariableSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = aTypeVariable();
    assertEquals(t, resolver.where(t, t).resolveType(t));
  }

  public <T> void testWhere_parameterizedSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = new TypeCapture<List<T>>() {}.capture();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                public void testWhere_typeVariableSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = aTypeVariable();
    assertEquals(t, resolver.where(t, t).resolveType(t));
  }

  public <T> void testWhere_parameterizedSelfMapping() {
    TypeResolver resolver = new TypeResolver();
    Type t = new TypeCapture<List<T>>() {}.capture();

            

Reported by PMD.

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

Line: 41

              
  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public boolean offer(E o) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.offer(o);

            

Reported by PMD.

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

Line: 35

                protected Deque<String> create() {
    TestDeque<String> inner = new TestDeque<>();
    Deque<String> outer = Synchronized.deque(inner, inner.mutex);
    outer.add("foo"); // necessary because we try to remove elements later on
    return outer;
  }

  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();

            

Reported by PMD.

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

Line: 35

                protected Deque<String> create() {
    TestDeque<String> inner = new TestDeque<>();
    Deque<String> outer = Synchronized.deque(inner, inner.mutex);
    outer.add("foo"); // necessary because we try to remove elements later on
    return outer;
  }

  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();

            

Reported by PMD.

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

Line: 39

                  return outer;
  }

  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public boolean offer(E o) {

            

Reported by PMD.

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

Line: 40

                }

  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public boolean offer(E o) {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

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

Line: 41

              
  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public boolean offer(E o) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.offer(o);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

              
    @Override
    public boolean offer(E o) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.offer(o);
    }

    @Override
    public E poll() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

              
    @Override
    public E poll() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.poll();
    }

    @Override
    public E remove() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 57

              
    @Override
    public E remove() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.remove();
    }

    @Override
    public boolean remove(Object object) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

              
    @Override
    public boolean remove(Object object) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.remove(object);
    }

    @Override
    public E peek() {

            

Reported by PMD.

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

Line: 41

              
  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public boolean offer(E o) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.offer(o);

            

Reported by PMD.

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

Line: 35

                protected Deque<String> create() {
    TestDeque<String> inner = new TestDeque<>();
    Deque<String> outer = Synchronized.deque(inner, inner.mutex);
    outer.add("foo"); // necessary because we try to remove elements later on
    return outer;
  }

  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();

            

Reported by PMD.

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

Line: 35

                protected Deque<String> create() {
    TestDeque<String> inner = new TestDeque<>();
    Deque<String> outer = Synchronized.deque(inner, inner.mutex);
    outer.add("foo"); // necessary because we try to remove elements later on
    return outer;
  }

  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();

            

Reported by PMD.

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

Line: 39

                  return outer;
  }

  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public boolean offer(E o) {

            

Reported by PMD.

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

Line: 40

                }

  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public boolean offer(E o) {
      assertTrue(Thread.holdsLock(mutex));

            

Reported by PMD.

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

Line: 41

              
  private static final class TestDeque<E> implements Deque<E> {
    private final Deque<E> delegate = Lists.newLinkedList();
    public final Object mutex = new Integer(1); // something Serializable

    @Override
    public boolean offer(E o) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.offer(o);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

              
    @Override
    public boolean offer(E o) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.offer(o);
    }

    @Override
    public E poll() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

              
    @Override
    public E poll() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.poll();
    }

    @Override
    public E remove() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 57

              
    @Override
    public E remove() {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.remove();
    }

    @Override
    public boolean remove(Object object) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 63

              
    @Override
    public boolean remove(Object object) {
      assertTrue(Thread.holdsLock(mutex));
      return delegate.remove(object);
    }

    @Override
    public E peek() {

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
78 issues
Possible God Class (WMC=53, ATFD=53, TCC=21.429%)
Design

Line: 19

              import java.util.Arrays;

/** Unit test for {@link AtomicDoubleArray}. */
public class AtomicDoubleArrayTest extends JSR166TestCase {

  private static final double[] VALUES = {
    Double.NEGATIVE_INFINITY,
    -Double.MAX_VALUE,
    (double) Long.MIN_VALUE,

            

Reported by PMD.

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

Line: 19

              import java.util.Arrays;

/** Unit test for {@link AtomicDoubleArray}. */
public class AtomicDoubleArrayTest extends JSR166TestCase {

  private static final double[] VALUES = {
    Double.NEGATIVE_INFINITY,
    -Double.MAX_VALUE,
    (double) Long.MIN_VALUE,

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 44

              
  /** The notion of equality used by AtomicDoubleArray */
  static boolean bitEquals(double x, double y) {
    return Double.doubleToRawLongBits(x) == Double.doubleToRawLongBits(y);
  }

  static void assertBitEquals(double x, double y) {
    assertEquals(Double.doubleToRawLongBits(x), Double.doubleToRawLongBits(y));
  }

            

Reported by PMD.

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

Line: 52

                }

  /** constructor creates array of given size with all elements zero */
  public void testConstructor() {
    AtomicDoubleArray aa = new AtomicDoubleArray(SIZE);
    for (int i = 0; i < SIZE; i++) {
      assertBitEquals(0.0, aa.get(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: 60

                }

  /** constructor with null array throws NPE */
  public void testConstructor2NPE() {
    double[] a = null;
    try {
      new AtomicDoubleArray(a);
      fail();
    } catch (NullPointerException success) {

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 65

                  try {
      new AtomicDoubleArray(a);
      fail();
    } catch (NullPointerException success) {
    }
  }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {

            

Reported by PMD.

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

Line: 65

                  try {
      new AtomicDoubleArray(a);
      fail();
    } catch (NullPointerException success) {
    }
  }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {

            

Reported by PMD.

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

Line: 65

                  try {
      new AtomicDoubleArray(a);
      fail();
    } catch (NullPointerException success) {
    }
  }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {

            

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

                }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {
    AtomicDoubleArray aa = new AtomicDoubleArray(VALUES);
    assertEquals(VALUES.length, aa.length());
    for (int i = 0; i < VALUES.length; i++) {
      assertBitEquals(VALUES[i], aa.get(i));
    }

            

Reported by PMD.

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

Line: 70

                }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {
    AtomicDoubleArray aa = new AtomicDoubleArray(VALUES);
    assertEquals(VALUES.length, aa.length());
    for (int i = 0; i < VALUES.length; i++) {
      assertBitEquals(VALUES[i], aa.get(i));
    }

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
78 issues
Possible God Class (WMC=53, ATFD=53, TCC=21.429%)
Design

Line: 19

              import java.util.Arrays;

/** Unit test for {@link AtomicDoubleArray}. */
public class AtomicDoubleArrayTest extends JSR166TestCase {

  private static final double[] VALUES = {
    Double.NEGATIVE_INFINITY,
    -Double.MAX_VALUE,
    (double) Long.MIN_VALUE,

            

Reported by PMD.

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

Line: 19

              import java.util.Arrays;

/** Unit test for {@link AtomicDoubleArray}. */
public class AtomicDoubleArrayTest extends JSR166TestCase {

  private static final double[] VALUES = {
    Double.NEGATIVE_INFINITY,
    -Double.MAX_VALUE,
    (double) Long.MIN_VALUE,

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 44

              
  /** The notion of equality used by AtomicDoubleArray */
  static boolean bitEquals(double x, double y) {
    return Double.doubleToRawLongBits(x) == Double.doubleToRawLongBits(y);
  }

  static void assertBitEquals(double x, double y) {
    assertEquals(Double.doubleToRawLongBits(x), Double.doubleToRawLongBits(y));
  }

            

Reported by PMD.

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

Line: 52

                }

  /** constructor creates array of given size with all elements zero */
  public void testConstructor() {
    AtomicDoubleArray aa = new AtomicDoubleArray(SIZE);
    for (int i = 0; i < SIZE; i++) {
      assertBitEquals(0.0, aa.get(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: 60

                }

  /** constructor with null array throws NPE */
  public void testConstructor2NPE() {
    double[] a = null;
    try {
      new AtomicDoubleArray(a);
      fail();
    } catch (NullPointerException success) {

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 65

                  try {
      new AtomicDoubleArray(a);
      fail();
    } catch (NullPointerException success) {
    }
  }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {

            

Reported by PMD.

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

Line: 65

                  try {
      new AtomicDoubleArray(a);
      fail();
    } catch (NullPointerException success) {
    }
  }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {

            

Reported by PMD.

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

Line: 65

                  try {
      new AtomicDoubleArray(a);
      fail();
    } catch (NullPointerException success) {
    }
  }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {

            

Reported by PMD.

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

Line: 70

                }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {
    AtomicDoubleArray aa = new AtomicDoubleArray(VALUES);
    assertEquals(VALUES.length, aa.length());
    for (int i = 0; i < VALUES.length; i++) {
      assertBitEquals(VALUES[i], aa.get(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: 70

                }

  /** constructor with array is of same size and has all elements */
  public void testConstructor2() {
    AtomicDoubleArray aa = new AtomicDoubleArray(VALUES);
    assertEquals(VALUES.length, aa.length());
    for (int i = 0; i < VALUES.length; i++) {
      assertBitEquals(VALUES[i], aa.get(i));
    }

            

Reported by PMD.