The following issues were found

android/guava-tests/test/com/google/common/html/HtmlEscapersTest.java
28 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 30

              @GwtCompatible
public class HtmlEscapersTest extends TestCase {

  public void testHtmlEscaper() throws Exception {
    assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals(""test"", htmlEscaper().escape("\"test\""));
    assertEquals("'test'", htmlEscaper().escape("\'test'"));
    assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));

            

Reported by PMD.

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

Line: 30

              @GwtCompatible
public class HtmlEscapersTest extends TestCase {

  public void testHtmlEscaper() throws Exception {
    assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

              public class HtmlEscapersTest extends TestCase {

  public void testHtmlEscaper() throws Exception {
    assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));
    assertEquals("test &gt;&gt; 1", htmlEscaper().escape("test >> 1"));

            

Reported by PMD.

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

Line: 31

              public class HtmlEscapersTest extends TestCase {

  public void testHtmlEscaper() throws Exception {
    assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));
    assertEquals("test &gt;&gt; 1", htmlEscaper().escape("test >> 1"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

              
  public void testHtmlEscaper() throws Exception {
    assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));
    assertEquals("test &gt;&gt; 1", htmlEscaper().escape("test >> 1"));
    assertEquals("&lt;tab&gt;", htmlEscaper().escape("<tab>"));

            

Reported by PMD.

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

Line: 32

              
  public void testHtmlEscaper() throws Exception {
    assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));
    assertEquals("test &gt;&gt; 1", htmlEscaper().escape("test >> 1"));
    assertEquals("&lt;tab&gt;", htmlEscaper().escape("<tab>"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                public void testHtmlEscaper() throws Exception {
    assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));
    assertEquals("test &gt;&gt; 1", htmlEscaper().escape("test >> 1"));
    assertEquals("&lt;tab&gt;", htmlEscaper().escape("<tab>"));


            

Reported by PMD.

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

Line: 33

                public void testHtmlEscaper() throws Exception {
    assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));
    assertEquals("test &gt;&gt; 1", htmlEscaper().escape("test >> 1"));
    assertEquals("&lt;tab&gt;", htmlEscaper().escape("<tab>"));


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                  assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));
    assertEquals("test &gt;&gt; 1", htmlEscaper().escape("test >> 1"));
    assertEquals("&lt;tab&gt;", htmlEscaper().escape("<tab>"));

    // Test simple escape of '&'.

            

Reported by PMD.

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

Line: 34

                  assertEquals("xxx", htmlEscaper().escape("xxx"));
    assertEquals("&quot;test&quot;", htmlEscaper().escape("\"test\""));
    assertEquals("&#39;test&#39;", htmlEscaper().escape("\'test'"));
    assertEquals("test &amp; test &amp; test", htmlEscaper().escape("test & test & test"));
    assertEquals("test &lt;&lt; 1", htmlEscaper().escape("test << 1"));
    assertEquals("test &gt;&gt; 1", htmlEscaper().escape("test >> 1"));
    assertEquals("&lt;tab&gt;", htmlEscaper().escape("<tab>"));

    // Test simple escape of '&'.

            

Reported by PMD.

android/guava-tests/test/com/google/common/cache/CacheLoaderTest.java
28 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 39

              public class CacheLoaderTest extends TestCase {

  private static class QueuingExecutor implements Executor {
    private final Deque<Runnable> tasks = Queues.newArrayDeque();

    @Override
    public void execute(Runnable task) {
      tasks.add(task);
    }

            

Reported by PMD.

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

Line: 47

                  }

    private void runNext() {
      tasks.removeFirst().run();
    }
  }

  public void testAsyncReload() throws Exception {
    final AtomicInteger loadCount = new AtomicInteger();

            

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 testAsyncReload() throws Exception {
    final AtomicInteger loadCount = new AtomicInteger();
    final AtomicInteger reloadCount = new AtomicInteger();
    final AtomicInteger loadAllCount = new AtomicInteger();

    CacheLoader<Object, Object> baseLoader =

            

Reported by PMD.

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

Line: 51

                  }
  }

  public void testAsyncReload() throws Exception {
    final AtomicInteger loadCount = new AtomicInteger();
    final AtomicInteger reloadCount = new AtomicInteger();
    final AtomicInteger loadAllCount = new AtomicInteger();

    CacheLoader<Object, Object> baseLoader =

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 77

                        }
        };

    assertEquals(0, loadCount.get());
    assertEquals(0, reloadCount.get());
    assertEquals(0, loadAllCount.get());

    baseLoader.load(new Object());
    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 78

                      };

    assertEquals(0, loadCount.get());
    assertEquals(0, reloadCount.get());
    assertEquals(0, loadAllCount.get());

    baseLoader.load(new Object());
    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError = baseLoader.reload(new Object(), new Object());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 79

              
    assertEquals(0, loadCount.get());
    assertEquals(0, reloadCount.get());
    assertEquals(0, loadAllCount.get());

    baseLoader.load(new Object());
    @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError = baseLoader.reload(new Object(), new Object());
    baseLoader.loadAll(ImmutableList.of(new Object()));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 85

                  @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
    Future<?> possiblyIgnoredError = baseLoader.reload(new Object(), new Object());
    baseLoader.loadAll(ImmutableList.of(new Object()));
    assertEquals(1, loadCount.get());
    assertEquals(1, reloadCount.get());
    assertEquals(1, loadAllCount.get());

    QueuingExecutor executor = new QueuingExecutor();
    CacheLoader<Object, Object> asyncReloader = CacheLoader.asyncReloading(baseLoader, executor);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 86

                  Future<?> possiblyIgnoredError = baseLoader.reload(new Object(), new Object());
    baseLoader.loadAll(ImmutableList.of(new Object()));
    assertEquals(1, loadCount.get());
    assertEquals(1, reloadCount.get());
    assertEquals(1, loadAllCount.get());

    QueuingExecutor executor = new QueuingExecutor();
    CacheLoader<Object, Object> asyncReloader = CacheLoader.asyncReloading(baseLoader, executor);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 87

                  baseLoader.loadAll(ImmutableList.of(new Object()));
    assertEquals(1, loadCount.get());
    assertEquals(1, reloadCount.get());
    assertEquals(1, loadAllCount.get());

    QueuingExecutor executor = new QueuingExecutor();
    CacheLoader<Object, Object> asyncReloader = CacheLoader.asyncReloading(baseLoader, executor);

    asyncReloader.load(new Object());

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java
28 issues
This class name ends with Test but contains no test cases
Error

Line: 48

               * methods in these degenerate classloaders.
 */

public class AggregateFutureStateFallbackAtomicHelperTest extends TestCase {

  /**
   * This classloader disallows AtomicReferenceFieldUpdater and AtomicIntegerFieldUpdate which will
   * prevent us from selecting our {@code SafeAtomicHelper} strategy.
   *

            

Reported by PMD.

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

Line: 69

                  // corresponding method on FuturesTest in the correct classloader.
    TestSuite suite = new TestSuite(AggregateFutureStateFallbackAtomicHelperTest.class.getName());
    for (Method method : FuturesTest.class.getDeclaredMethods()) {
      if (Modifier.isPublic(method.getModifiers()) && method.getName().startsWith("test")) {
        suite.addTest(
            TestSuite.createTest(
                AggregateFutureStateFallbackAtomicHelperTest.class, method.getName()));
      }
    }

            

Reported by PMD.

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

Line: 81

                @Override
  public void runTest() throws Exception {
    // First ensure that our classloaders are initializing the correct helper versions
    checkHelperVersion(getClass().getClassLoader(), "SafeAtomicHelper");
    checkHelperVersion(NO_ATOMIC_FIELD_UPDATER, "SynchronizedAtomicHelper");

    // Run the corresponding FuturesTest test method in a new classloader that disallows
    // certain core jdk classes.
    ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();

            

Reported by PMD.

In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.
Error

Line: 81

                @Override
  public void runTest() throws Exception {
    // First ensure that our classloaders are initializing the correct helper versions
    checkHelperVersion(getClass().getClassLoader(), "SafeAtomicHelper");
    checkHelperVersion(NO_ATOMIC_FIELD_UPDATER, "SynchronizedAtomicHelper");

    // Run the corresponding FuturesTest test method in a new classloader that disallows
    // certain core jdk classes.
    ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();

            

Reported by PMD.

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

Line: 86

              
    // Run the corresponding FuturesTest test method in a new classloader that disallows
    // certain core jdk classes.
    ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(NO_ATOMIC_FIELD_UPDATER);
    try {
      runTestMethod(NO_ATOMIC_FIELD_UPDATER);
      // TODO(lukes): assert that the logs are full of errors
    } finally {

            

Reported by PMD.

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

Line: 87

                  // Run the corresponding FuturesTest test method in a new classloader that disallows
    // certain core jdk classes.
    ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(NO_ATOMIC_FIELD_UPDATER);
    try {
      runTestMethod(NO_ATOMIC_FIELD_UPDATER);
      // TODO(lukes): assert that the logs are full of errors
    } finally {
      Thread.currentThread().setContextClassLoader(oldClassLoader);

            

Reported by PMD.

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

Line: 92

                    runTestMethod(NO_ATOMIC_FIELD_UPDATER);
      // TODO(lukes): assert that the logs are full of errors
    } finally {
      Thread.currentThread().setContextClassLoader(oldClassLoader);
    }
  }

  private void runTestMethod(ClassLoader classLoader) throws Exception {
    Class<?> test = classLoader.loadClass(FuturesTest.class.getName());

            

Reported by PMD.

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

Line: 96

                  }
  }

  private void runTestMethod(ClassLoader classLoader) throws Exception {
    Class<?> test = classLoader.loadClass(FuturesTest.class.getName());
    Object testInstance = test.getDeclaredConstructor().newInstance();
    test.getMethod("setUp").invoke(testInstance);
    test.getMethod(getName()).invoke(testInstance);
    test.getMethod("tearDown").invoke(testInstance);

            

Reported by PMD.

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

Line: 98

              
  private void runTestMethod(ClassLoader classLoader) throws Exception {
    Class<?> test = classLoader.loadClass(FuturesTest.class.getName());
    Object testInstance = test.getDeclaredConstructor().newInstance();
    test.getMethod("setUp").invoke(testInstance);
    test.getMethod(getName()).invoke(testInstance);
    test.getMethod("tearDown").invoke(testInstance);
  }


            

Reported by PMD.

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

Line: 98

              
  private void runTestMethod(ClassLoader classLoader) throws Exception {
    Class<?> test = classLoader.loadClass(FuturesTest.class.getName());
    Object testInstance = test.getDeclaredConstructor().newInstance();
    test.getMethod("setUp").invoke(testInstance);
    test.getMethod(getName()).invoke(testInstance);
    test.getMethod("tearDown").invoke(testInstance);
  }


            

Reported by PMD.

android/guava/src/com/google/common/primitives/Longs.java
28 issues
Avoid using a branching statement as the last in a loop.
Error

Line: 159

                        continue outer;
        }
      }
      return i;
    }
    return -1;
  }

  /**

            

Reported by PMD.

Avoid reassigning parameters such as 'value'
Design

Line: 274

                 * use a shared {@link java.nio.ByteBuffer} instance, or use {@link
   * com.google.common.io.ByteStreams#newDataOutput()} to get a growable buffer.
   */
  public static byte[] toByteArray(long value) {
    // Note that this code needs to stay compatible with GWT, which has known
    // bugs when narrowing byte casts of long values occur.
    byte[] result = new byte[8];
    for (int i = 7; i >= 0; i--) {
      result[i] = (byte) (value & 0xffL);

            

Reported by PMD.

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

Line: 47

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

  /**
   * The number of bytes required to represent a primitive {@code long} value.
   *

            

Reported by PMD.

Possible God Class (WMC=69, ATFD=34, TCC=0.000%)
Design

Line: 47

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

  /**
   * The number of bytes required to represent a primitive {@code long} value.
   *

            

Reported by PMD.

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

Line: 47

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

  /**
   * The number of bytes required to represent a primitive {@code long} value.
   *

            

Reported by PMD.

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

Line: 47

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

  /**
   * The number of bytes required to represent a primitive {@code long} value.
   *

            

Reported by PMD.

It is somewhat confusing to have a field name matching the declaring class name
Error

Line: 327

                static final class AsciiDigits {
    private AsciiDigits() {}

    private static final byte[] asciiDigits;

    static {
      byte[] result = new byte[128];
      Arrays.fill(result, (byte) -1);
      for (int i = 0; i < 10; i++) {

            

Reported by PMD.

The method 'tryParse(String, int)' has a cyclomatic complexity of 16.
Design

Line: 392

                 */
  @Beta
  @CheckForNull
  public static Long tryParse(String string, int radix) {
    if (checkNotNull(string).isEmpty()) {
      return null;
    }
    if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
      throw new IllegalArgumentException(

            

Reported by PMD.

The method 'tryParse' has a Modified Cyclomatic Complexity of 11.
Design

Line: 392

                 */
  @Beta
  @CheckForNull
  public static Long tryParse(String string, int radix) {
    if (checkNotNull(string).isEmpty()) {
      return null;
    }
    if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
      throw new IllegalArgumentException(

            

Reported by PMD.

The method 'tryParse' has a Standard Cyclomatic Complexity of 11.
Design

Line: 392

                 */
  @Beta
  @CheckForNull
  public static Long tryParse(String string, int radix) {
    if (checkNotNull(string).isEmpty()) {
      return null;
    }
    if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
      throw new IllegalArgumentException(

            

Reported by PMD.

android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
28 issues
The class 'AbstractCatchingFuture' has a Standard Cyclomatic Complexity of 3 (Highest = 10).
Design

Line: 37

              @GwtCompatible
@ElementTypesAreNonnullByDefault
@SuppressWarnings("nullness") // TODO(b/147136275): Remove once our checker understands & and |.
abstract class AbstractCatchingFuture<
        V extends @Nullable Object, X extends Throwable, F, T extends @Nullable Object>
    extends FluentFuture.TrustedFuture<V> implements Runnable {
  static <V extends @Nullable Object, X extends Throwable> ListenableFuture<V> create(
      ListenableFuture<? extends V> input,
      Class<X> exceptionType,

            

Reported by PMD.

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

Line: 37

              @GwtCompatible
@ElementTypesAreNonnullByDefault
@SuppressWarnings("nullness") // TODO(b/147136275): Remove once our checker understands & and |.
abstract class AbstractCatchingFuture<
        V extends @Nullable Object, X extends Throwable, F, T extends @Nullable Object>
    extends FluentFuture.TrustedFuture<V> implements Runnable {
  static <V extends @Nullable Object, X extends Throwable> ListenableFuture<V> create(
      ListenableFuture<? extends V> input,
      Class<X> exceptionType,

            

Reported by PMD.

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

Line: 64

                 * In certain circumstances, this field might theoretically not be visible to an afterDone() call
   * triggered by cancel(). For details, see the comments on the fields of TimeoutFuture.
   */
  @CheckForNull ListenableFuture<? extends V> inputFuture;
  @CheckForNull Class<X> exceptionType;
  @CheckForNull F fallback;

  AbstractCatchingFuture(
      ListenableFuture<? extends V> inputFuture, Class<X> exceptionType, F fallback) {

            

Reported by PMD.

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

Line: 65

                 * triggered by cancel(). For details, see the comments on the fields of TimeoutFuture.
   */
  @CheckForNull ListenableFuture<? extends V> inputFuture;
  @CheckForNull Class<X> exceptionType;
  @CheckForNull F fallback;

  AbstractCatchingFuture(
      ListenableFuture<? extends V> inputFuture, Class<X> exceptionType, F fallback) {
    this.inputFuture = checkNotNull(inputFuture);

            

Reported by PMD.

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

Line: 66

                 */
  @CheckForNull ListenableFuture<? extends V> inputFuture;
  @CheckForNull Class<X> exceptionType;
  @CheckForNull F fallback;

  AbstractCatchingFuture(
      ListenableFuture<? extends V> inputFuture, Class<X> exceptionType, F fallback) {
    this.inputFuture = checkNotNull(inputFuture);
    this.exceptionType = checkNotNull(exceptionType);

            

Reported by PMD.

The method 'run' has a Standard Cyclomatic Complexity of 10.
Design

Line: 76

                }

  @Override
  public final void run() {
    ListenableFuture<? extends V> localInputFuture = inputFuture;
    Class<X> localExceptionType = exceptionType;
    F localFallback = fallback;
    if (localInputFuture == null | localExceptionType == null | localFallback == null
        // This check, unlike all the others, is a volatile read

            

Reported by PMD.

The method 'run()' has an NPath complexity of 252, current threshold is 200
Design

Line: 76

                }

  @Override
  public final void run() {
    ListenableFuture<? extends V> localInputFuture = inputFuture;
    Class<X> localExceptionType = exceptionType;
    F localFallback = fallback;
    if (localInputFuture == null | localExceptionType == null | localFallback == null
        // This check, unlike all the others, is a volatile read

            

Reported by PMD.

The method 'run()' has a cyclomatic complexity of 11.
Design

Line: 76

                }

  @Override
  public final void run() {
    ListenableFuture<? extends V> localInputFuture = inputFuture;
    Class<X> localExceptionType = exceptionType;
    F localFallback = fallback;
    if (localInputFuture == null | localExceptionType == null | localFallback == null
        // This check, unlike all the others, is a volatile read

            

Reported by PMD.

The method 'run' has a Modified Cyclomatic Complexity of 10.
Design

Line: 76

                }

  @Override
  public final void run() {
    ListenableFuture<? extends V> localInputFuture = inputFuture;
    Class<X> localExceptionType = exceptionType;
    F localFallback = fallback;
    if (localInputFuture == null | localExceptionType == null | localFallback == null
        // This check, unlike all the others, is a volatile read

            

Reported by PMD.

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

Line: 85

                      || isCancelled()) {
      return;
    }
    inputFuture = null;

    // For an explanation of the cases here, see the comments on AbstractTransformFuture.run.
    V sourceResult = null;
    Throwable throwable = null;
    try {

            

Reported by PMD.

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

Line: 41

               */
@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
final class GeneralRange<T extends @Nullable Object> implements Serializable {
  /** Converts a Range to a GeneralRange. */
  static <T extends Comparable> GeneralRange<T> from(Range<T> range) {
    T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
    BoundType lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : OPEN;


            

Reported by PMD.

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

Line: 41

               */
@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
final class GeneralRange<T extends @Nullable Object> implements Serializable {
  /** Converts a Range to a GeneralRange. */
  static <T extends Comparable> GeneralRange<T> from(Range<T> range) {
    T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
    BoundType lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : OPEN;


            

Reported by PMD.

Field comparator has the same name as a method
Error

Line: 95

                  return new GeneralRange<T>(comparator, true, lower, lowerType, true, upper, upperType);
  }

  private final Comparator<? super T> comparator;
  private final boolean hasLowerBound;
  @CheckForNull private final T lowerEndpoint;
  private final BoundType lowerBoundType;
  private final boolean hasUpperBound;
  @CheckForNull private final T upperEndpoint;

            

Reported by PMD.

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

Line: 95

                  return new GeneralRange<T>(comparator, true, lower, lowerType, true, upper, upperType);
  }

  private final Comparator<? super T> comparator;
  private final boolean hasLowerBound;
  @CheckForNull private final T lowerEndpoint;
  private final BoundType lowerBoundType;
  private final boolean hasUpperBound;
  @CheckForNull private final T upperEndpoint;

            

Reported by PMD.

Field hasLowerBound has the same name as a method
Error

Line: 96

                }

  private final Comparator<? super T> comparator;
  private final boolean hasLowerBound;
  @CheckForNull private final T lowerEndpoint;
  private final BoundType lowerBoundType;
  private final boolean hasUpperBound;
  @CheckForNull private final T upperEndpoint;
  private final BoundType upperBoundType;

            

Reported by PMD.

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

Line: 96

                }

  private final Comparator<? super T> comparator;
  private final boolean hasLowerBound;
  @CheckForNull private final T lowerEndpoint;
  private final BoundType lowerBoundType;
  private final boolean hasUpperBound;
  @CheckForNull private final T upperEndpoint;
  private final BoundType upperBoundType;

            

Reported by PMD.

Field hasUpperBound has the same name as a method
Error

Line: 99

                private final boolean hasLowerBound;
  @CheckForNull private final T lowerEndpoint;
  private final BoundType lowerBoundType;
  private final boolean hasUpperBound;
  @CheckForNull private final T upperEndpoint;
  private final BoundType upperBoundType;

  private GeneralRange(
      Comparator<? super T> comparator,

            

Reported by PMD.

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

Line: 99

                private final boolean hasLowerBound;
  @CheckForNull private final T lowerEndpoint;
  private final BoundType lowerBoundType;
  private final boolean hasUpperBound;
  @CheckForNull private final T upperEndpoint;
  private final BoundType upperBoundType;

  private GeneralRange(
      Comparator<? super T> comparator,

            

Reported by PMD.

The method 'intersect(GeneralRange)' has a cyclomatic complexity of 17.
Design

Line: 192

                 * Returns the intersection of the two ranges, or an empty range if their intersection is empty.
   */
  @SuppressWarnings("nullness") // TODO(cpovirk): Add casts as needed. Will be noisy and annoying...
  GeneralRange<T> intersect(GeneralRange<T> other) {
    checkNotNull(other);
    checkArgument(comparator.equals(other.comparator));

    boolean hasLowBound = this.hasLowerBound;
    T lowEnd = getLowerEndpoint();

            

Reported by PMD.

The method 'intersect(GeneralRange)' has an NPath complexity of 252, current threshold is 200
Design

Line: 192

                 * Returns the intersection of the two ranges, or an empty range if their intersection is empty.
   */
  @SuppressWarnings("nullness") // TODO(cpovirk): Add casts as needed. Will be noisy and annoying...
  GeneralRange<T> intersect(GeneralRange<T> other) {
    checkNotNull(other);
    checkArgument(comparator.equals(other.comparator));

    boolean hasLowBound = this.hasLowerBound;
    T lowEnd = getLowerEndpoint();

            

Reported by PMD.

android/guava/src/com/google/common/io/ByteStreams.java
28 issues
Avoid reassigning parameters such as 'totalLen'
Design

Line: 171

                 * a total combined length of {@code totalLen} bytes) followed by all bytes remaining in the given
   * input stream.
   */
  private static byte[] toByteArrayInternal(InputStream in, Queue<byte[]> bufs, int totalLen)
      throws IOException {
    // Starting with an 8k buffer, double the size of each successive buffer. Buffers are retained
    // in a deque so that there's no copying between buffers while reading and so all of the bytes
    // in each new allocated buffer are available for reading from the stream.
    for (int bufSize = BUFFER_SIZE;

            

Reported by PMD.

Avoid reassigning parameters such as 'len'
Design

Line: 729

                  }

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
      if (left == 0) {
        return -1;
      }

      len = (int) Math.min(len, left);

            

Reported by PMD.

Avoid reassigning parameters such as 'n'
Design

Line: 756

                  }

    @Override
    public long skip(long n) throws IOException {
      n = Math.min(n, left);
      long skipped = in.skip(n);
      left -= skipped;
      return skipped;
    }

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.io;

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

            

Reported by PMD.

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

Line: 56

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ByteStreams {

  private static final int BUFFER_SIZE = 8192;

  /** Creates a new byte array for buffering reads or writes. */
  static byte[] createBuffer() {

            

Reported by PMD.

Possible God Class (WMC=60, ATFD=9, TCC=1.425%)
Design

Line: 56

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ByteStreams {

  private static final int BUFFER_SIZE = 8192;

  /** Creates a new byte array for buffering reads or writes. */
  static byte[] createBuffer() {

            

Reported by PMD.

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

Line: 137

                  checkNotNull(to);
    if (from instanceof FileChannel) {
      FileChannel sourceChannel = (FileChannel) from;
      long oldPosition = sourceChannel.position();
      long position = oldPosition;
      long copied;
      do {
        copied = sourceChannel.transferTo(position, ZERO_COPY_CHUNK_SIZE, to);
        position += copied;

            

Reported by PMD.

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

Line: 141

                    long position = oldPosition;
      long copied;
      do {
        copied = sourceChannel.transferTo(position, ZERO_COPY_CHUNK_SIZE, to);
        position += copied;
        sourceChannel.position(position);
      } while (copied > 0 || position < sourceChannel.size());
      return position - oldPosition;
    }

            

Reported by PMD.

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

Line: 143

                    do {
        copied = sourceChannel.transferTo(position, ZERO_COPY_CHUNK_SIZE, to);
        position += copied;
        sourceChannel.position(position);
      } while (copied > 0 || position < sourceChannel.size());
      return position - oldPosition;
    }

    ByteBuffer buf = ByteBuffer.wrap(createBuffer());

            

Reported by PMD.

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

Line: 144

                      copied = sourceChannel.transferTo(position, ZERO_COPY_CHUNK_SIZE, to);
        position += copied;
        sourceChannel.position(position);
      } while (copied > 0 || position < sourceChannel.size());
      return position - oldPosition;
    }

    ByteBuffer buf = ByteBuffer.wrap(createBuffer());
    long total = 0;

            

Reported by PMD.

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

Line: 53

               */
@GwtIncompatible // hasn't been tested yet
@ElementTypesAreNonnullByDefault
public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultisetFauxverideShim<E>
    implements SortedMultiset<E> {
  // TODO(lowasser): GWT compatibility

  /**
   * Returns the empty immutable sorted multiset.

            

Reported by PMD.

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

Line: 54

              @GwtIncompatible // hasn't been tested yet
@ElementTypesAreNonnullByDefault
public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultisetFauxverideShim<E>
    implements SortedMultiset<E> {
  // TODO(lowasser): GWT compatibility

  /**
   * Returns the empty immutable sorted multiset.
   *

            

Reported by PMD.

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

Line: 62

                 *
   * <p><b>Performance note:</b> the instance returned is a singleton.
   */
  @SuppressWarnings("unchecked")
  public static <E> ImmutableSortedMultiset<E> of() {
    return (ImmutableSortedMultiset) RegularImmutableSortedMultiset.NATURAL_EMPTY_MULTISET;
  }

  /** Returns an immutable sorted multiset containing a single element. */

            

Reported by PMD.

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

Line: 217

                  if (elements instanceof ImmutableSortedMultiset) {
      @SuppressWarnings("unchecked") // immutable collections are always safe for covariant casts
      ImmutableSortedMultiset<E> multiset = (ImmutableSortedMultiset<E>) elements;
      if (comparator.equals(multiset.comparator())) {
        if (multiset.isPartialView()) {
          return copyOfSortedEntries(comparator, multiset.entrySet().asList());
        } else {
          return multiset;
        }

            

Reported by PMD.

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

Line: 218

                    @SuppressWarnings("unchecked") // immutable collections are always safe for covariant casts
      ImmutableSortedMultiset<E> multiset = (ImmutableSortedMultiset<E>) elements;
      if (comparator.equals(multiset.comparator())) {
        if (multiset.isPartialView()) {
          return copyOfSortedEntries(comparator, multiset.entrySet().asList());
        } else {
          return multiset;
        }
      }

            

Reported by PMD.

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

Line: 219

                    ImmutableSortedMultiset<E> multiset = (ImmutableSortedMultiset<E>) elements;
      if (comparator.equals(multiset.comparator())) {
        if (multiset.isPartialView()) {
          return copyOfSortedEntries(comparator, multiset.entrySet().asList());
        } else {
          return multiset;
        }
      }
    }

            

Reported by PMD.

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

Line: 219

                    ImmutableSortedMultiset<E> multiset = (ImmutableSortedMultiset<E>) elements;
      if (comparator.equals(multiset.comparator())) {
        if (multiset.isPartialView()) {
          return copyOfSortedEntries(comparator, multiset.entrySet().asList());
        } else {
          return multiset;
        }
      }
    }

            

Reported by PMD.

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

Line: 269

              
  @SuppressWarnings("unchecked")
  static <E> ImmutableSortedMultiset<E> emptyMultiset(Comparator<? super E> comparator) {
    if (Ordering.natural().equals(comparator)) {
      return (ImmutableSortedMultiset<E>) RegularImmutableSortedMultiset.NATURAL_EMPTY_MULTISET;
    } else {
      return new RegularImmutableSortedMultiset<E>(comparator);
    }
  }

            

Reported by PMD.

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

Line: 280

              
  @Override
  public final Comparator<? super E> comparator() {
    return elementSet().comparator();
  }

  @Override
  public abstract ImmutableSortedSet<E> elementSet();


            

Reported by PMD.

Field descendingMultiset has the same name as a method
Error

Line: 286

                @Override
  public abstract ImmutableSortedSet<E> elementSet();

  @LazyInit @CheckForNull transient ImmutableSortedMultiset<E> descendingMultiset;

  @Override
  public ImmutableSortedMultiset<E> descendingMultiset() {
    ImmutableSortedMultiset<E> result = descendingMultiset;
    if (result == null) {

            

Reported by PMD.

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

Line: 29

              @GwtCompatible
@Immutable(containerOf = {"R", "C", "V"})
@ElementTypesAreNonnullByDefault
final class SparseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
  static final ImmutableTable<Object, Object, Object> EMPTY =
      new SparseImmutableTable<>(
          ImmutableList.<Cell<Object, Object, Object>>of(), ImmutableSet.of(), ImmutableSet.of());

  private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;

            

Reported by PMD.

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

Line: 34

                    new SparseImmutableTable<>(
          ImmutableList.<Cell<Object, Object, Object>>of(), ImmutableSet.of(), ImmutableSet.of());

  private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
  private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;

  // For each cell in iteration order, the index of that cell's row key in the row key list.
  @SuppressWarnings("Immutable") // We don't modify this after construction.
  private final int[] cellRowIndices;

            

Reported by PMD.

Field rowMap has the same name as a method
Error

Line: 34

                    new SparseImmutableTable<>(
          ImmutableList.<Cell<Object, Object, Object>>of(), ImmutableSet.of(), ImmutableSet.of());

  private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
  private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;

  // For each cell in iteration order, the index of that cell's row key in the row key list.
  @SuppressWarnings("Immutable") // We don't modify this after construction.
  private final int[] cellRowIndices;

            

Reported by PMD.

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

Line: 35

                        ImmutableList.<Cell<Object, Object, Object>>of(), ImmutableSet.of(), ImmutableSet.of());

  private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
  private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;

  // For each cell in iteration order, the index of that cell's row key in the row key list.
  @SuppressWarnings("Immutable") // We don't modify this after construction.
  private final int[] cellRowIndices;


            

Reported by PMD.

Field columnMap has the same name as a method
Error

Line: 35

                        ImmutableList.<Cell<Object, Object, Object>>of(), ImmutableSet.of(), ImmutableSet.of());

  private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
  private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;

  // For each cell in iteration order, the index of that cell's row key in the row key list.
  @SuppressWarnings("Immutable") // We don't modify this after construction.
  private final int[] cellRowIndices;


            

Reported by PMD.

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

Line: 39

              
  // For each cell in iteration order, the index of that cell's row key in the row key list.
  @SuppressWarnings("Immutable") // We don't modify this after construction.
  private final int[] cellRowIndices;

  // For each cell in iteration order, the index of that cell's column key in the list of column
  // keys present in that row.
  @SuppressWarnings("Immutable") // We don't modify this after construction.
  private final int[] cellColumnInRowIndices;

            

Reported by PMD.

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

Line: 44

                // For each cell in iteration order, the index of that cell's column key in the list of column
  // keys present in that row.
  @SuppressWarnings("Immutable") // We don't modify this after construction.
  private final int[] cellColumnInRowIndices;

  SparseImmutableTable(
      ImmutableList<Cell<R, C, V>> cellList,
      ImmutableSet<R> rowSpace,
      ImmutableSet<C> columnSpace) {

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 53

                  Map<R, Integer> rowIndex = Maps.indexMap(rowSpace);
    Map<R, Map<C, V>> rows = Maps.newLinkedHashMap();
    for (R row : rowSpace) {
      rows.put(row, new LinkedHashMap<C, V>());
    }
    Map<C, Map<R, V>> columns = Maps.newLinkedHashMap();
    for (C col : columnSpace) {
      columns.put(col, new LinkedHashMap<R, V>());
    }

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 57

                  }
    Map<C, Map<R, V>> columns = Maps.newLinkedHashMap();
    for (C col : columnSpace) {
      columns.put(col, new LinkedHashMap<R, V>());
    }
    int[] cellRowIndices = new int[cellList.size()];
    int[] cellColumnInRowIndices = new int[cellList.size()];
    for (int i = 0; i < cellList.size(); i++) {
      Cell<R, C, V> cell = cellList.get(i);

            

Reported by PMD.

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

Line: 117

                @Override
  Cell<R, C, V> getCell(int index) {
    int rowIndex = cellRowIndices[index];
    Entry<R, ImmutableMap<C, V>> rowEntry = rowMap.entrySet().asList().get(rowIndex);
    ImmutableMap<C, V> row = rowEntry.getValue();
    int columnIndex = cellColumnInRowIndices[index];
    Entry<C, V> colEntry = row.entrySet().asList().get(columnIndex);
    return cellOf(rowEntry.getKey(), colEntry.getKey(), colEntry.getValue());
  }

            

Reported by PMD.

android/guava/src/com/google/common/base/Throwables.java
28 issues
Avoid throwing raw exception types.
Design

Line: 243

                @Deprecated
  public static RuntimeException propagate(Throwable throwable) {
    throwIfUnchecked(throwable);
    throw new RuntimeException(throwable);
  }

  /**
   * Returns the innermost cause of {@code throwable}. The first throwable in a chain provides
   * context from when the error or exception was initially detected. Example usage:

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 444

                  try {
      return method.invoke(receiver, params);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
      throw propagate(e.getCause());
    }
  }


            

Reported by PMD.

Avoid reassigning parameters such as 'throwable'
Design

Line: 256

                 *
   * @throws IllegalArgumentException if there is a loop in the causal chain
   */
  public static Throwable getRootCause(Throwable throwable) {
    // Keep a second pointer that slowly walks the causal chain. If the fast pointer ever catches
    // the slower pointer, then there's a loop.
    Throwable slowPointer = throwable;
    boolean advanceSlowPointer = false;


            

Reported by PMD.

Avoid reassigning parameters such as 'throwable'
Design

Line: 294

                 * @throws IllegalArgumentException if there is a loop in the causal chain
   */
  @Beta // TODO(kevinb): decide best return type
  public static List<Throwable> getCausalChain(Throwable throwable) {
    checkNotNull(throwable);
    List<Throwable> causes = new ArrayList<>(4);
    causes.add(throwable);

    // Keep a second pointer that slowly walks the causal chain. If the fast pointer ever catches

            

Reported by PMD.

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

Line: 50

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Throwables {
  private Throwables() {}

  /**
   * Throws {@code throwable} if it is an instance of {@code declaredType}. Example usage:
   *

            

Reported by PMD.

Possible God Class (WMC=52, ATFD=12, TCC=2.381%)
Design

Line: 50

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Throwables {
  private Throwables() {}

  /**
   * Throws {@code throwable} if it is an instance of {@code declaredType}. Example usage:
   *

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 263

                  boolean advanceSlowPointer = false;

    Throwable cause;
    while ((cause = throwable.getCause()) != null) {
      throwable = cause;

      if (throwable == slowPointer) {
        throw new IllegalArgumentException("Loop in causal chain detected.", throwable);
      }

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 266

                  while ((cause = throwable.getCause()) != null) {
      throwable = cause;

      if (throwable == slowPointer) {
        throw new IllegalArgumentException("Loop in causal chain detected.", throwable);
      }
      if (advanceSlowPointer) {
        slowPointer = slowPointer.getCause();
      }

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 305

                  boolean advanceSlowPointer = false;

    Throwable cause;
    while ((cause = throwable.getCause()) != null) {
      throwable = cause;
      causes.add(throwable);

      if (throwable == slowPointer) {
        throw new IllegalArgumentException("Loop in causal chain detected.", throwable);

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 309

                    throwable = cause;
      causes.add(throwable);

      if (throwable == slowPointer) {
        throw new IllegalArgumentException("Loop in causal chain detected.", throwable);
      }
      if (advanceSlowPointer) {
        slowPointer = slowPointer.getCause();
      }

            

Reported by PMD.