The following issues were found

android/guava/src/com/google/common/collect/ForwardingNavigableSet.java
19 issues
This class has too many methods, consider refactoring it.
Design

Line: 56

              @GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingNavigableSet<E extends @Nullable Object>
    extends ForwardingSortedSet<E> implements NavigableSet<E> {

  /** Constructor for use by subclasses. */
  protected ForwardingNavigableSet() {}

  @Override

            

Reported by PMD.

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

Line: 67

                @Override
  @CheckForNull
  public E lower(@ParametricNullness E e) {
    return delegate().lower(e);
  }

  /**
   * A sensible definition of {@link #lower} in terms of the {@code descendingIterator} method of
   * {@link #headSet(Object, boolean)}. If you override {@link #headSet(Object, boolean)}, you may

            

Reported by PMD.

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

Line: 77

                 */
  @CheckForNull
  protected E standardLower(@ParametricNullness E e) {
    return Iterators.getNext(headSet(e, false).descendingIterator(), null);
  }

  @Override
  @CheckForNull
  public E floor(@ParametricNullness E e) {

            

Reported by PMD.

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

Line: 83

                @Override
  @CheckForNull
  public E floor(@ParametricNullness E e) {
    return delegate().floor(e);
  }

  /**
   * A sensible definition of {@link #floor} in terms of the {@code descendingIterator} method of
   * {@link #headSet(Object, boolean)}. If you override {@link #headSet(Object, boolean)}, you may

            

Reported by PMD.

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

Line: 93

                 */
  @CheckForNull
  protected E standardFloor(@ParametricNullness E e) {
    return Iterators.getNext(headSet(e, true).descendingIterator(), null);
  }

  @Override
  @CheckForNull
  public E ceiling(@ParametricNullness E e) {

            

Reported by PMD.

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

Line: 99

                @Override
  @CheckForNull
  public E ceiling(@ParametricNullness E e) {
    return delegate().ceiling(e);
  }

  /**
   * A sensible definition of {@link #ceiling} in terms of the {@code iterator} method of {@link
   * #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may wish to

            

Reported by PMD.

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

Line: 109

                 */
  @CheckForNull
  protected E standardCeiling(@ParametricNullness E e) {
    return Iterators.getNext(tailSet(e, true).iterator(), null);
  }

  @Override
  @CheckForNull
  public E higher(@ParametricNullness E e) {

            

Reported by PMD.

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

Line: 115

                @Override
  @CheckForNull
  public E higher(@ParametricNullness E e) {
    return delegate().higher(e);
  }

  /**
   * A sensible definition of {@link #higher} in terms of the {@code iterator} method of {@link
   * #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may wish to

            

Reported by PMD.

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

Line: 125

                 */
  @CheckForNull
  protected E standardHigher(@ParametricNullness E e) {
    return Iterators.getNext(tailSet(e, false).iterator(), null);
  }

  @Override
  @CheckForNull
  public E pollFirst() {

            

Reported by PMD.

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

Line: 131

                @Override
  @CheckForNull
  public E pollFirst() {
    return delegate().pollFirst();
  }

  /**
   * A sensible definition of {@link #pollFirst} in terms of the {@code iterator} method. If you
   * override {@link #iterator} you may wish to override {@link #pollFirst} to forward to this

            

Reported by PMD.

android/guava/src/com/google/common/util/concurrent/AbstractService.java
19 issues
Possible God Class (WMC=73, ATFD=7, TCC=25.667%)
Design

Line: 53

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractService implements Service {
  private static final ListenerCallQueue.Event<Listener> STARTING_EVENT =
      new ListenerCallQueue.Event<Listener>() {
        @Override
        public void call(Listener listener) {
          listener.starting();

            

Reported by PMD.

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

Line: 53

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractService implements Service {
  private static final ListenerCallQueue.Event<Listener> STARTING_EVENT =
      new ListenerCallQueue.Event<Listener>() {
        @Override
        public void call(Listener listener) {
          listener.starting();

            

Reported by PMD.

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

Line: 120

                  };
  }

  private final Monitor monitor = new Monitor();

  private final Guard isStartable = new IsStartableGuard();

  @WeakOuter
  private final class IsStartableGuard extends Guard {

            

Reported by PMD.

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

Line: 122

              
  private final Monitor monitor = new Monitor();

  private final Guard isStartable = new IsStartableGuard();

  @WeakOuter
  private final class IsStartableGuard extends Guard {
    IsStartableGuard() {
      super(AbstractService.this.monitor);

            

Reported by PMD.

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

Line: 136

                  }
  }

  private final Guard isStoppable = new IsStoppableGuard();

  @WeakOuter
  private final class IsStoppableGuard extends Guard {
    IsStoppableGuard() {
      super(AbstractService.this.monitor);

            

Reported by PMD.

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

Line: 146

              
    @Override
    public boolean isSatisfied() {
      return state().compareTo(RUNNING) <= 0;
    }
  }

  private final Guard hasReachedRunning = new HasReachedRunningGuard();


            

Reported by PMD.

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

Line: 150

                  }
  }

  private final Guard hasReachedRunning = new HasReachedRunningGuard();

  @WeakOuter
  private final class HasReachedRunningGuard extends Guard {
    HasReachedRunningGuard() {
      super(AbstractService.this.monitor);

            

Reported by PMD.

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

Line: 160

              
    @Override
    public boolean isSatisfied() {
      return state().compareTo(RUNNING) >= 0;
    }
  }

  private final Guard isStopped = new IsStoppedGuard();


            

Reported by PMD.

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

Line: 164

                  }
  }

  private final Guard isStopped = new IsStoppedGuard();

  @WeakOuter
  private final class IsStoppedGuard extends Guard {
    IsStoppedGuard() {
      super(AbstractService.this.monitor);

            

Reported by PMD.

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

Line: 174

              
    @Override
    public boolean isSatisfied() {
      return state().compareTo(TERMINATED) >= 0;
    }
  }

  /** The listeners to notify during a state transition. */
  private final ListenerCallQueue<Listener> listeners = new ListenerCallQueue<>();

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/AbstractListeningExecutorServiceTest.java
19 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: 34

               */
public class AbstractListeningExecutorServiceTest extends TestCase {

  public void testSubmit() throws Exception {
    /*
     * Mostly just tests that TrustedListenableFutureTask are created and run; tests for
     * TrustedListenableFutureTask should ensure that listeners are called correctly.
     */


            

Reported by PMD.

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

Line: 34

               */
public class AbstractListeningExecutorServiceTest extends TestCase {

  public void testSubmit() throws Exception {
    /*
     * Mostly just tests that TrustedListenableFutureTask are created and run; tests for
     * TrustedListenableFutureTask should ensure that listeners are called correctly.
     */


            

Reported by PMD.

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

Line: 44

              
    TestRunnable runnable = new TestRunnable();
    ListenableFuture<?> runnableFuture = e.submit(runnable);
    assertThat(runnableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(runnableFuture.isDone());
    assertTrue(runnable.run);

    ListenableFuture<String> callableFuture = e.submit(new TestCallable());
    assertThat(callableFuture).isInstanceOf(TrustedListenableFutureTask.class);

            

Reported by PMD.

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

Line: 45

                  TestRunnable runnable = new TestRunnable();
    ListenableFuture<?> runnableFuture = e.submit(runnable);
    assertThat(runnableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(runnableFuture.isDone());
    assertTrue(runnable.run);

    ListenableFuture<String> callableFuture = e.submit(new TestCallable());
    assertThat(callableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(callableFuture.isDone());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  TestRunnable runnable = new TestRunnable();
    ListenableFuture<?> runnableFuture = e.submit(runnable);
    assertThat(runnableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(runnableFuture.isDone());
    assertTrue(runnable.run);

    ListenableFuture<String> callableFuture = e.submit(new TestCallable());
    assertThat(callableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(callableFuture.isDone());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                  ListenableFuture<?> runnableFuture = e.submit(runnable);
    assertThat(runnableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(runnableFuture.isDone());
    assertTrue(runnable.run);

    ListenableFuture<String> callableFuture = e.submit(new TestCallable());
    assertThat(callableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(callableFuture.isDone());
    assertEquals("foo", callableFuture.get());

            

Reported by PMD.

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

Line: 49

                  assertTrue(runnable.run);

    ListenableFuture<String> callableFuture = e.submit(new TestCallable());
    assertThat(callableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(callableFuture.isDone());
    assertEquals("foo", callableFuture.get());

    TestRunnable runnable2 = new TestRunnable();
    ListenableFuture<Integer> runnableFuture2 = e.submit(runnable2, 3);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 50

              
    ListenableFuture<String> callableFuture = e.submit(new TestCallable());
    assertThat(callableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(callableFuture.isDone());
    assertEquals("foo", callableFuture.get());

    TestRunnable runnable2 = new TestRunnable();
    ListenableFuture<Integer> runnableFuture2 = e.submit(runnable2, 3);
    assertThat(runnableFuture2).isInstanceOf(TrustedListenableFutureTask.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                  ListenableFuture<String> callableFuture = e.submit(new TestCallable());
    assertThat(callableFuture).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(callableFuture.isDone());
    assertEquals("foo", callableFuture.get());

    TestRunnable runnable2 = new TestRunnable();
    ListenableFuture<Integer> runnableFuture2 = e.submit(runnable2, 3);
    assertThat(runnableFuture2).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(runnableFuture2.isDone());

            

Reported by PMD.

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

Line: 55

              
    TestRunnable runnable2 = new TestRunnable();
    ListenableFuture<Integer> runnableFuture2 = e.submit(runnable2, 3);
    assertThat(runnableFuture2).isInstanceOf(TrustedListenableFutureTask.class);
    assertTrue(runnableFuture2.isDone());
    assertTrue(runnable2.run);
    assertEquals((Integer) 3, runnableFuture2.get());
  }


            

Reported by PMD.

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

Line: 172

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

  /**

            

Reported by PMD.

Possible God Class (WMC=50, ATFD=27, TCC=0.000%)
Design

Line: 51

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

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

            

Reported by PMD.

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

Line: 51

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

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

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 460

                public static void reverse(float[] array, int fromIndex, int toIndex) {
    checkNotNull(array);
    checkPositionIndexes(fromIndex, toIndex, array.length);
    for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
      float tmp = array[i];
      array[i] = array[j];
      array[j] = tmp;
    }
  }

            

Reported by PMD.

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

Line: 520

                @GwtCompatible
  private static class FloatArrayAsList extends AbstractList<Float>
      implements RandomAccess, Serializable {
    final float[] array;
    final int start;
    final int end;

    FloatArrayAsList(float[] array) {
      this(array, 0, array.length);

            

Reported by PMD.

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

Line: 521

                private static class FloatArrayAsList extends AbstractList<Float>
      implements RandomAccess, Serializable {
    final float[] array;
    final int start;
    final int end;

    FloatArrayAsList(float[] array) {
      this(array, 0, array.length);
    }

            

Reported by PMD.

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

Line: 522

                    implements RandomAccess, Serializable {
    final float[] array;
    final int start;
    final int end;

    FloatArrayAsList(float[] array) {
      this(array, 0, array.length);
    }


            

Reported by PMD.

The user-supplied array 'array' is stored directly.
Design

Line: 528

                    this(array, 0, array.length);
    }

    FloatArrayAsList(float[] array, int start, int end) {
      this.array = array;
      this.start = start;
      this.end = end;
    }


            

Reported by PMD.

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

Line: 607

                    if (object instanceof FloatArrayAsList) {
        FloatArrayAsList that = (FloatArrayAsList) object;
        int size = size();
        if (that.size() != size) {
          return false;
        }
        for (int i = 0; i < size; i++) {
          if (array[start + i] != that.array[that.start + i]) {
            return false;

            

Reported by PMD.

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

Line: 667

                @GwtIncompatible // regular expressions
  @CheckForNull
  public static Float tryParse(String string) {
    if (Doubles.FLOATING_POINT_PATTERN.matcher(string).matches()) {
      // TODO(lowasser): could be potentially optimized, but only with
      // extensive testing
      try {
        return Float.parseFloat(string);
      } catch (NumberFormatException e) {

            

Reported by PMD.

android/guava/src/com/google/common/io/FileBackedOutputStream.java
19 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 160

              
  private synchronized InputStream openInputStream() throws IOException {
    if (file != null) {
      return new FileInputStream(file);
    } else {
      // requireNonNull is safe because we always have either `file` or `memory`.
      requireNonNull(memory);
      return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount());
    }

            

Reported by PMD.

Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 235

                      temp.deleteOnExit();
      }
      try {
        FileOutputStream transfer = new FileOutputStream(temp);
        transfer.write(memory.getBuffer(), 0, memory.getCount());
        transfer.flush();
        // We've successfully transferred the data; switch to writing to file
        out = transfer;
      } catch (IOException e) {

            

Reported by PMD.

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

Line: 57

              @GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class FileBackedOutputStream extends OutputStream {
  private final int fileThreshold;
  private final boolean resetOnFinalize;
  private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")

            

Reported by PMD.

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

Line: 58

              @ElementTypesAreNonnullByDefault
public final class FileBackedOutputStream extends OutputStream {
  private final int fileThreshold;
  private final boolean resetOnFinalize;
  private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;

            

Reported by PMD.

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

Line: 59

              public final class FileBackedOutputStream extends OutputStream {
  private final int fileThreshold;
  private final boolean resetOnFinalize;
  private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;


            

Reported by PMD.

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

Line: 60

                private final int fileThreshold;
  private final boolean resetOnFinalize;
  private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;

  @GuardedBy("this")

            

Reported by PMD.

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

Line: 62

                private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;

  @GuardedBy("this")
  @CheckForNull
  private MemoryOutput memory;

            

Reported by PMD.

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

Line: 63

                @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;

  @GuardedBy("this")
  @CheckForNull
  private MemoryOutput memory;


            

Reported by PMD.

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

Line: 67

              
  @GuardedBy("this")
  @CheckForNull
  private MemoryOutput memory;

  @GuardedBy("this")
  @CheckForNull
  private File file;


            

Reported by PMD.

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

Line: 71

              
  @GuardedBy("this")
  @CheckForNull
  private File file;

  /** ByteArrayOutputStream that exposes its internals. */
  private static class MemoryOutput extends ByteArrayOutputStream {
    byte[] getBuffer() {
      return buf;

            

Reported by PMD.

android/guava/src/com/google/common/base/FinalizableReferenceQueue.java
19 issues
Logger calls should be surrounded by log level guards.
Design

Line: 167

                  } catch (IllegalAccessException impossible) {
      throw new AssertionError(impossible); // startFinalizer() is public
    } catch (Throwable t) {
      logger.log(
          Level.INFO,
          "Failed to start reference finalizer thread."
              + " Reference cleanup will only occur when new references are created.",
          t);
    }

            

Reported by PMD.

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

Line: 148

                }

  /** The actual reference queue that our background thread will poll. */
  final ReferenceQueue<Object> queue;

  final PhantomReference<Object> frqRef;

  /** Whether or not the background thread started successfully. */
  final boolean threadStarted;

            

Reported by PMD.

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

Line: 150

                /** The actual reference queue that our background thread will poll. */
  final ReferenceQueue<Object> queue;

  final PhantomReference<Object> frqRef;

  /** Whether or not the background thread started successfully. */
  final boolean threadStarted;

  /** Constructs a new queue. */

            

Reported by PMD.

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

Line: 153

                final PhantomReference<Object> frqRef;

  /** Whether or not the background thread started successfully. */
  final boolean threadStarted;

  /** Constructs a new queue. */
  public FinalizableReferenceQueue() {
    // We could start the finalizer lazily, but I'd rather it blow up early.
    queue = new ReferenceQueue<>();

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 166

                    threadStarted = true;
    } catch (IllegalAccessException impossible) {
      throw new AssertionError(impossible); // startFinalizer() is public
    } catch (Throwable t) {
      logger.log(
          Level.INFO,
          "Failed to start reference finalizer thread."
              + " Reference cleanup will only occur when new references are created.",
          t);

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 194

                  }

    Reference<?> reference;
    while ((reference = queue.poll()) != null) {
      /*
       * This is for the benefit of phantom references. Weak and soft references will have already
       * been cleared by this point.
       */
      reference.clear();

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 202

                    reference.clear();
      try {
        ((FinalizableReference) reference).finalizeReferent();
      } catch (Throwable t) {
        logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
      }
    }
  }


            

Reported by PMD.

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

Line: 297

                       * System class loader will (and must) be the parent.
         */
        ClassLoader finalizerLoader = newLoader(getBaseUrl());
        return finalizerLoader.loadClass(FINALIZER_CLASS_NAME);
      } catch (Exception e) {
        logger.log(Level.WARNING, LOADING_ERROR, e);
        return null;
      }
    }

            

Reported by PMD.

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

Line: 298

                       */
        ClassLoader finalizerLoader = newLoader(getBaseUrl());
        return finalizerLoader.loadClass(FINALIZER_CLASS_NAME);
      } catch (Exception e) {
        logger.log(Level.WARNING, LOADING_ERROR, e);
        return null;
      }
    }


            

Reported by PMD.

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

Line: 308

                  URL getBaseUrl() throws IOException {
      // Find URL pointing to Finalizer.class file.
      String finalizerPath = FINALIZER_CLASS_NAME.replace('.', '/') + ".class";
      URL finalizerUrl = getClass().getClassLoader().getResource(finalizerPath);
      if (finalizerUrl == null) {
        throw new FileNotFoundException(finalizerPath);
      }

      // Find URL pointing to base of class path.

            

Reported by PMD.

android/guava-tests/test/com/google/common/math/QuantilesAlgorithm.java
19 issues
The class 'QuantilesAlgorithm' has a Standard Cyclomatic Complexity of 3(Highest = 13).
Design

Line: 34

               * @author Pete Gillin
 * @since 20.0
 */
enum QuantilesAlgorithm {

  /**
   * Sorts the dataset, and picks values from it. When computing multiple quantiles, we sort once
   * and pick multiple values.
   */

            

Reported by PMD.

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

Line: 34

               * @author Pete Gillin
 * @since 20.0
 */
enum QuantilesAlgorithm {

  /**
   * Sorts the dataset, and picks values from it. When computing multiple quantiles, we sort once
   * and pick multiple values.
   */

            

Reported by PMD.

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

Line: 109

              
    @Override
    double singleQuantile(int index, int scale, double[] dataset) {
      return Quantiles.scale(scale).index(index).computeInPlace(dataset);
    }

    @Override
    Map<Integer, Double> multipleQuantiles(
        Collection<Integer> indexes, int scale, double[] dataset) {

            

Reported by PMD.

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

Line: 109

              
    @Override
    double singleQuantile(int index, int scale, double[] dataset) {
      return Quantiles.scale(scale).index(index).computeInPlace(dataset);
    }

    @Override
    Map<Integer, Double> multipleQuantiles(
        Collection<Integer> indexes, int scale, double[] dataset) {

            

Reported by PMD.

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

Line: 115

                  @Override
    Map<Integer, Double> multipleQuantiles(
        Collection<Integer> indexes, int scale, double[] dataset) {
      return Quantiles.scale(scale).indexes(indexes).computeInPlace(dataset);
    }
  },
  ;

  /**

            

Reported by PMD.

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

Line: 115

                  @Override
    Map<Integer, Double> multipleQuantiles(
        Collection<Integer> indexes, int scale, double[] dataset) {
      return Quantiles.scale(scale).indexes(indexes).computeInPlace(dataset);
    }
  },
  ;

  /**

            

Reported by PMD.

The method 'select' has a Standard Cyclomatic Complexity of 13.
Design

Line: 145

                  return array[min];
  }

  static double select(int k, double[] array) {
    // This is basically a copy of com.google.math.Rank#select, with a small change in the method
    // signature: we make k 0-based rather than 1-based; and we drop from and to, and always work on
    // the whole array.
    int from = 0;
    int to = array.length - 1;

            

Reported by PMD.

The method 'select' has a Modified Cyclomatic Complexity of 13.
Design

Line: 145

                  return array[min];
  }

  static double select(int k, double[] array) {
    // This is basically a copy of com.google.math.Rank#select, with a small change in the method
    // signature: we make k 0-based rather than 1-based; and we drop from and to, and always work on
    // the whole array.
    int from = 0;
    int to = array.length - 1;

            

Reported by PMD.

The method 'select(int, double)' has a cyclomatic complexity of 14.
Design

Line: 145

                  return array[min];
  }

  static double select(int k, double[] array) {
    // This is basically a copy of com.google.math.Rank#select, with a small change in the method
    // signature: we make k 0-based rather than 1-based; and we drop from and to, and always work on
    // the whole array.
    int from = 0;
    int to = array.length - 1;

            

Reported by PMD.

The method 'select(int, double)' has an NPath complexity of 292, current threshold is 200
Design

Line: 145

                  return array[min];
  }

  static double select(int k, double[] array) {
    // This is basically a copy of com.google.math.Rank#select, with a small change in the method
    // signature: we make k 0-based rather than 1-based; and we drop from and to, and always work on
    // the whole array.
    int from = 0;
    int to = array.length - 1;

            

Reported by PMD.

guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java
19 issues
Possible God Class (WMC=58, ATFD=20, TCC=12.500%)
Design

Line: 51

              @Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class SimpleTimeLimiter implements TimeLimiter {

  private final ExecutorService executor;

  private SimpleTimeLimiter(ExecutorService executor) {
    this.executor = checkNotNull(executor);

            

Reported by PMD.

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

Line: 51

              @Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class SimpleTimeLimiter implements TimeLimiter {

  private final ExecutorService executor;

  private SimpleTimeLimiter(ExecutorService executor) {
    this.executor = checkNotNull(executor);

            

Reported by PMD.

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

Line: 53

              @ElementTypesAreNonnullByDefault
public final class SimpleTimeLimiter implements TimeLimiter {

  private final ExecutorService executor;

  private SimpleTimeLimiter(ExecutorService executor) {
    this.executor = checkNotNull(executor);
  }


            

Reported by PMD.

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

Line: 118

                private static <T> T newProxy(Class<T> interfaceType, InvocationHandler handler) {
    Object object =
        Proxy.newProxyInstance(
            interfaceType.getClassLoader(), new Class<?>[] {interfaceType}, handler);
    return interfaceType.cast(object);
  }

  private <T extends @Nullable Object> T callWithTimeout(
      Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)

            

Reported by PMD.

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

Line: 124

              
  private <T extends @Nullable Object> T callWithTimeout(
      Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)
      throws Exception {
    checkNotNull(callable);
    checkNotNull(timeoutUnit);
    checkPositiveTimeout(timeoutDuration);

    Future<T> future = executor.submit(callable);

            

Reported by PMD.

New exception is thrown in catch block, original stack trace may be lost
Design

Line: 168

                    throw e;
    } catch (ExecutionException e) {
      wrapAndThrowExecutionExceptionOrError(e.getCause());
      throw new AssertionError();
    }
  }

  @CanIgnoreReturnValue
  @Override

            

Reported by PMD.

New exception is thrown in catch block, original stack trace may be lost
Design

Line: 190

                    throw e;
    } catch (ExecutionException e) {
      wrapAndThrowExecutionExceptionOrError(e.getCause());
      throw new AssertionError();
    }
  }

  @Override
  public void runWithTimeout(Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit)

            

Reported by PMD.

New exception is thrown in catch block, original stack trace may be lost
Design

Line: 210

                    throw e;
    } catch (ExecutionException e) {
      wrapAndThrowRuntimeExecutionExceptionOrError(e.getCause());
      throw new AssertionError();
    }
  }

  @Override
  public void runUninterruptiblyWithTimeout(

            

Reported by PMD.

New exception is thrown in catch block, original stack trace may be lost
Design

Line: 230

                    throw e;
    } catch (ExecutionException e) {
      wrapAndThrowRuntimeExecutionExceptionOrError(e.getCause());
      throw new AssertionError();
    }
  }

  private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
    Throwable cause = e.getCause();

            

Reported by PMD.

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

Line: 234

                  }
  }

  private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
    Throwable cause = e.getCause();
    if (cause == null) {
      throw e;
    }
    if (combineStackTraces) {

            

Reported by PMD.

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

Line: 172

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

  /**

            

Reported by PMD.

Possible God Class (WMC=50, ATFD=27, TCC=0.000%)
Design

Line: 51

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

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

            

Reported by PMD.

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

Line: 51

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

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

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 460

                public static void reverse(float[] array, int fromIndex, int toIndex) {
    checkNotNull(array);
    checkPositionIndexes(fromIndex, toIndex, array.length);
    for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
      float tmp = array[i];
      array[i] = array[j];
      array[j] = tmp;
    }
  }

            

Reported by PMD.

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

Line: 520

                @GwtCompatible
  private static class FloatArrayAsList extends AbstractList<Float>
      implements RandomAccess, Serializable {
    final float[] array;
    final int start;
    final int end;

    FloatArrayAsList(float[] array) {
      this(array, 0, array.length);

            

Reported by PMD.

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

Line: 521

                private static class FloatArrayAsList extends AbstractList<Float>
      implements RandomAccess, Serializable {
    final float[] array;
    final int start;
    final int end;

    FloatArrayAsList(float[] array) {
      this(array, 0, array.length);
    }

            

Reported by PMD.

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

Line: 522

                    implements RandomAccess, Serializable {
    final float[] array;
    final int start;
    final int end;

    FloatArrayAsList(float[] array) {
      this(array, 0, array.length);
    }


            

Reported by PMD.

The user-supplied array 'array' is stored directly.
Design

Line: 528

                    this(array, 0, array.length);
    }

    FloatArrayAsList(float[] array, int start, int end) {
      this.array = array;
      this.start = start;
      this.end = end;
    }


            

Reported by PMD.

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

Line: 607

                    if (object instanceof FloatArrayAsList) {
        FloatArrayAsList that = (FloatArrayAsList) object;
        int size = size();
        if (that.size() != size) {
          return false;
        }
        for (int i = 0; i < size; i++) {
          if (array[start + i] != that.array[that.start + i]) {
            return false;

            

Reported by PMD.

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

Line: 667

                @GwtIncompatible // regular expressions
  @CheckForNull
  public static Float tryParse(String string) {
    if (Doubles.FLOATING_POINT_PATTERN.matcher(string).matches()) {
      // TODO(lowasser): could be potentially optimized, but only with
      // extensive testing
      try {
        return Float.parseFloat(string);
      } catch (NumberFormatException e) {

            

Reported by PMD.

guava/src/com/google/common/io/FileBackedOutputStream.java
19 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 160

              
  private synchronized InputStream openInputStream() throws IOException {
    if (file != null) {
      return new FileInputStream(file);
    } else {
      // requireNonNull is safe because we always have either `file` or `memory`.
      requireNonNull(memory);
      return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount());
    }

            

Reported by PMD.

Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 235

                      temp.deleteOnExit();
      }
      try {
        FileOutputStream transfer = new FileOutputStream(temp);
        transfer.write(memory.getBuffer(), 0, memory.getCount());
        transfer.flush();
        // We've successfully transferred the data; switch to writing to file
        out = transfer;
      } catch (IOException e) {

            

Reported by PMD.

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

Line: 57

              @GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class FileBackedOutputStream extends OutputStream {
  private final int fileThreshold;
  private final boolean resetOnFinalize;
  private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")

            

Reported by PMD.

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

Line: 58

              @ElementTypesAreNonnullByDefault
public final class FileBackedOutputStream extends OutputStream {
  private final int fileThreshold;
  private final boolean resetOnFinalize;
  private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;

            

Reported by PMD.

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

Line: 59

              public final class FileBackedOutputStream extends OutputStream {
  private final int fileThreshold;
  private final boolean resetOnFinalize;
  private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;


            

Reported by PMD.

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

Line: 60

                private final int fileThreshold;
  private final boolean resetOnFinalize;
  private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;

  @GuardedBy("this")

            

Reported by PMD.

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

Line: 62

                private final ByteSource source;
  @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;

  @GuardedBy("this")
  @CheckForNull
  private MemoryOutput memory;

            

Reported by PMD.

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

Line: 63

                @CheckForNull private final File parentDirectory;

  @GuardedBy("this")
  private OutputStream out;

  @GuardedBy("this")
  @CheckForNull
  private MemoryOutput memory;


            

Reported by PMD.

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

Line: 67

              
  @GuardedBy("this")
  @CheckForNull
  private MemoryOutput memory;

  @GuardedBy("this")
  @CheckForNull
  private File file;


            

Reported by PMD.

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

Line: 71

              
  @GuardedBy("this")
  @CheckForNull
  private File file;

  /** ByteArrayOutputStream that exposes its internals. */
  private static class MemoryOutput extends ByteArrayOutputStream {
    byte[] getBuffer() {
      return buf;

            

Reported by PMD.