The following issues were found
guava/src/com/google/common/collect/ForwardingNavigableSet.java
19 issues
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
guava/src/com/google/common/io/ReaderInputStream.java
19 issues
Line: 48
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class ReaderInputStream extends InputStream {
private final Reader reader;
private final CharsetEncoder encoder;
private final byte[] singleByte = new byte[1];
/**
Reported by PMD.
Line: 48
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class ReaderInputStream extends InputStream {
private final Reader reader;
private final CharsetEncoder encoder;
private final byte[] singleByte = new byte[1];
/**
Reported by PMD.
Line: 49
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class ReaderInputStream extends InputStream {
private final Reader reader;
private final CharsetEncoder encoder;
private final byte[] singleByte = new byte[1];
/**
* charBuffer holds characters that have been read from the Reader but not encoded yet. The buffer
Reported by PMD.
Line: 50
@ElementTypesAreNonnullByDefault
final class ReaderInputStream extends InputStream {
private final Reader reader;
private final CharsetEncoder encoder;
private final byte[] singleByte = new byte[1];
/**
* charBuffer holds characters that have been read from the Reader but not encoded yet. The buffer
* is perpetually "flipped" (unencoded characters between position and limit).
Reported by PMD.
Line: 51
final class ReaderInputStream extends InputStream {
private final Reader reader;
private final CharsetEncoder encoder;
private final byte[] singleByte = new byte[1];
/**
* charBuffer holds characters that have been read from the Reader but not encoded yet. The buffer
* is perpetually "flipped" (unencoded characters between position and limit).
*/
Reported by PMD.
Line: 57
* charBuffer holds characters that have been read from the Reader but not encoded yet. The buffer
* is perpetually "flipped" (unencoded characters between position and limit).
*/
private CharBuffer charBuffer;
/**
* byteBuffer holds encoded characters that have not yet been sent to the caller of the input
* stream. When encoding it is "unflipped" (encoded bytes between 0 and position) and when
* draining it is flipped (undrained bytes between position and limit).
Reported by PMD.
Line: 64
* stream. When encoding it is "unflipped" (encoded bytes between 0 and position) and when
* draining it is flipped (undrained bytes between position and limit).
*/
private ByteBuffer byteBuffer;
/** Whether we've finished reading the reader. */
private boolean endOfInput;
/** Whether we're copying encoded bytes to the caller's buffer. */
private boolean draining;
Reported by PMD.
Line: 67
private ByteBuffer byteBuffer;
/** Whether we've finished reading the reader. */
private boolean endOfInput;
/** Whether we're copying encoded bytes to the caller's buffer. */
private boolean draining;
/** Whether we've successfully flushed the encoder. */
private boolean doneFlushing;
Reported by PMD.
Line: 69
/** Whether we've finished reading the reader. */
private boolean endOfInput;
/** Whether we're copying encoded bytes to the caller's buffer. */
private boolean draining;
/** Whether we've successfully flushed the encoder. */
private boolean doneFlushing;
/**
* Creates a new input stream that will encode the characters from {@code reader} into bytes using
Reported by PMD.
Line: 71
/** Whether we're copying encoded bytes to the caller's buffer. */
private boolean draining;
/** Whether we've successfully flushed the encoder. */
private boolean doneFlushing;
/**
* Creates a new input stream that will encode the characters from {@code reader} into bytes using
* the given character set. Malformed input and unmappable characters will be replaced.
*
Reported by PMD.
guava/src/com/google/common/base/FinalizableReferenceQueue.java
19 issues
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.
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.
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.
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.
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.
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.
Line: 202
reference.clear();
try {
((FinalizableReference) reference).finalizeReferent();
} catch (Throwable t) {
logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
}
}
}
Reported by PMD.
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.
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.
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.
guava/src/com/google/common/collect/DescendingMultiset.java
19 issues
Line: 37
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class DescendingMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
implements SortedMultiset<E> {
abstract SortedMultiset<E> forwardMultiset();
@CheckForNull private transient Comparator<? super E> comparator;
@Override
Reported by PMD.
Line: 40
implements SortedMultiset<E> {
abstract SortedMultiset<E> forwardMultiset();
@CheckForNull private transient Comparator<? super E> comparator;
@Override
public Comparator<? super E> comparator() {
Comparator<? super E> result = comparator;
if (result == null) {
Reported by PMD.
Line: 46
public Comparator<? super E> comparator() {
Comparator<? super E> result = comparator;
if (result == null) {
return comparator = Ordering.from(forwardMultiset().comparator()).<E>reverse();
}
return result;
}
@CheckForNull private transient NavigableSet<E> elementSet;
Reported by PMD.
Line: 46
public Comparator<? super E> comparator() {
Comparator<? super E> result = comparator;
if (result == null) {
return comparator = Ordering.from(forwardMultiset().comparator()).<E>reverse();
}
return result;
}
@CheckForNull private transient NavigableSet<E> elementSet;
Reported by PMD.
Line: 51
return result;
}
@CheckForNull private transient NavigableSet<E> elementSet;
@Override
public NavigableSet<E> elementSet() {
NavigableSet<E> result = elementSet;
if (result == null) {
Reported by PMD.
Line: 65
@Override
@CheckForNull
public Entry<E> pollFirstEntry() {
return forwardMultiset().pollLastEntry();
}
@Override
@CheckForNull
public Entry<E> pollLastEntry() {
Reported by PMD.
Line: 71
@Override
@CheckForNull
public Entry<E> pollLastEntry() {
return forwardMultiset().pollFirstEntry();
}
@Override
public SortedMultiset<E> headMultiset(@ParametricNullness E toElement, BoundType boundType) {
return forwardMultiset().tailMultiset(toElement, boundType).descendingMultiset();
Reported by PMD.
Line: 76
@Override
public SortedMultiset<E> headMultiset(@ParametricNullness E toElement, BoundType boundType) {
return forwardMultiset().tailMultiset(toElement, boundType).descendingMultiset();
}
@Override
public SortedMultiset<E> subMultiset(
@ParametricNullness E fromElement,
Reported by PMD.
Line: 76
@Override
public SortedMultiset<E> headMultiset(@ParametricNullness E toElement, BoundType boundType) {
return forwardMultiset().tailMultiset(toElement, boundType).descendingMultiset();
}
@Override
public SortedMultiset<E> subMultiset(
@ParametricNullness E fromElement,
Reported by PMD.
Line: 85
BoundType fromBoundType,
@ParametricNullness E toElement,
BoundType toBoundType) {
return forwardMultiset()
.subMultiset(toElement, toBoundType, fromElement, fromBoundType)
.descendingMultiset();
}
@Override
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/AbstractListeningExecutorServiceTest.java
19 issues
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
guava-tests/test/com/google/common/collect/SortedListsTest.java
19 issues
Line: 31
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class SortedListsTest extends TestCase {
private static final ImmutableList<Integer> LIST_WITH_DUPS =
ImmutableList.of(1, 1, 2, 4, 4, 4, 8);
private static final ImmutableList<Integer> LIST_WITHOUT_DUPS = ImmutableList.of(1, 2, 4, 8);
Reported by PMD.
Line: 37
private static final ImmutableList<Integer> LIST_WITHOUT_DUPS = ImmutableList.of(1, 2, 4, 8);
void assertModelAgrees(
List<Integer> list,
Integer key,
int answer,
KeyPresentBehavior presentBehavior,
KeyAbsentBehavior absentBehavior) {
Reported by PMD.
Line: 37
private static final ImmutableList<Integer> LIST_WITHOUT_DUPS = ImmutableList.of(1, 2, 4, 8);
void assertModelAgrees(
List<Integer> list,
Integer key,
int answer,
KeyPresentBehavior presentBehavior,
KeyAbsentBehavior absentBehavior) {
Reported by PMD.
Line: 46
switch (presentBehavior) {
case FIRST_PRESENT:
if (list.contains(key)) {
assertEquals(list.indexOf(key), answer);
return;
}
break;
case LAST_PRESENT:
if (list.contains(key)) {
Reported by PMD.
Line: 52
break;
case LAST_PRESENT:
if (list.contains(key)) {
assertEquals(list.lastIndexOf(key), answer);
return;
}
break;
case ANY_PRESENT:
if (list.contains(key)) {
Reported by PMD.
Line: 58
break;
case ANY_PRESENT:
if (list.contains(key)) {
assertEquals(key, list.get(answer));
return;
}
break;
case FIRST_AFTER:
if (list.contains(key)) {
Reported by PMD.
Line: 64
break;
case FIRST_AFTER:
if (list.contains(key)) {
assertEquals(list.lastIndexOf(key) + 1, answer);
return;
}
break;
case LAST_BEFORE:
if (list.contains(key)) {
Reported by PMD.
Line: 70
break;
case LAST_BEFORE:
if (list.contains(key)) {
assertEquals(list.indexOf(key) - 1, answer);
return;
}
break;
default:
throw new AssertionError();
Reported by PMD.
Line: 84
}
switch (absentBehavior) {
case NEXT_LOWER:
assertEquals(nextHigherIndex - 1, answer);
return;
case NEXT_HIGHER:
assertEquals(nextHigherIndex, answer);
return;
case INVERTED_INSERTION_INDEX:
Reported by PMD.
Line: 87
assertEquals(nextHigherIndex - 1, answer);
return;
case NEXT_HIGHER:
assertEquals(nextHigherIndex, answer);
return;
case INVERTED_INSERTION_INDEX:
assertEquals(-1 - nextHigherIndex, answer);
return;
default:
Reported by PMD.
guava-tests/test/com/google/common/io/ByteSinkTest.java
19 issues
Line: 37
*/
public class ByteSinkTest extends IoTestCase {
private final byte[] bytes = newPreFilledByteArray(10000);
private TestByteSink sink;
@Override
protected void setUp() throws Exception {
Reported by PMD.
Line: 39
private final byte[] bytes = newPreFilledByteArray(10000);
private TestByteSink sink;
@Override
protected void setUp() throws Exception {
sink = new TestByteSink();
}
Reported by PMD.
Line: 41
private TestByteSink sink;
@Override
protected void setUp() throws Exception {
sink = new TestByteSink();
}
public void testOpenBufferedStream() throws IOException {
Reported by PMD.
Line: 46
sink = new TestByteSink();
}
public void testOpenBufferedStream() throws IOException {
OutputStream out = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
out.write(new byte[] {1, 2, 3, 4});
Reported by PMD.
Line: 46
sink = new TestByteSink();
}
public void testOpenBufferedStream() throws IOException {
OutputStream out = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
out.write(new byte[] {1, 2, 3, 4});
Reported by PMD.
Line: 47
}
public void testOpenBufferedStream() throws IOException {
OutputStream out = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
out.write(new byte[] {1, 2, 3, 4});
out.close();
Reported by PMD.
Line: 52
assertFalse(sink.wasStreamClosed());
out.write(new byte[] {1, 2, 3, 4});
out.close();
assertTrue(sink.wasStreamClosed());
assertArrayEquals(new byte[] {1, 2, 3, 4}, sink.getBytes());
}
Reported by PMD.
Line: 58
assertArrayEquals(new byte[] {1, 2, 3, 4}, sink.getBytes());
}
public void testWrite_bytes() throws IOException {
assertArrayEquals(new byte[0], sink.getBytes());
sink.write(bytes);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertArrayEquals(bytes, sink.getBytes());
Reported by PMD.
Line: 58
assertArrayEquals(new byte[] {1, 2, 3, 4}, sink.getBytes());
}
public void testWrite_bytes() throws IOException {
assertArrayEquals(new byte[0], sink.getBytes());
sink.write(bytes);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertArrayEquals(bytes, sink.getBytes());
Reported by PMD.
Line: 66
assertArrayEquals(bytes, sink.getBytes());
}
public void testWriteFrom_inputStream() throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
sink.writeFrom(in);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertArrayEquals(bytes, sink.getBytes());
Reported by PMD.
guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java
19 issues
Line: 47
for (int i = 0; i < reps; i++) {
String x = oldRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
throw new RuntimeException("Wrong length: " + x);
}
}
}
private static String oldRepeat(String string, int count) {
Reported by PMD.
Line: 69
for (int i = 0; i < reps; i++) {
String x = mikeRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
throw new RuntimeException("Wrong length: " + x);
}
}
}
private static String mikeRepeat(String string, int count) {
Reported by PMD.
Line: 102
for (int i = 0; i < reps; i++) {
String x = martinRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
throw new RuntimeException("Wrong length: " + x);
}
}
}
private static String martinRepeat(String string, int count) {
Reported by PMD.
Line: 74
}
}
private static String mikeRepeat(String string, int count) {
final int len = string.length();
char[] strCopy = new char[len * Integer.highestOneBit(count)];
string.getChars(0, len, strCopy, 0);
char[] array = new char[len * count];
Reported by PMD.
Line: 30
*/
public class StringsRepeatBenchmark {
@Param({"1", "5", "25", "125"})
int count;
@Param({"1", "10"})
int length;
private String originalString;
Reported by PMD.
Line: 33
int count;
@Param({"1", "10"})
int length;
private String originalString;
@BeforeExperiment
void setUp() {
Reported by PMD.
Line: 35
@Param({"1", "10"})
int length;
private String originalString;
@BeforeExperiment
void setUp() {
originalString = Strings.repeat("x", length);
}
Reported by PMD.
Line: 37
private String originalString;
@BeforeExperiment
void setUp() {
originalString = Strings.repeat("x", length);
}
@Benchmark
Reported by PMD.
Line: 46
void oldRepeat(int reps) {
for (int i = 0; i < reps; i++) {
String x = oldRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
throw new RuntimeException("Wrong length: " + x);
}
}
}
Reported by PMD.
Line: 46
void oldRepeat(int reps) {
for (int i = 0; i < reps; i++) {
String x = oldRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
throw new RuntimeException("Wrong length: " + x);
}
}
}
Reported by PMD.
guava-tests/test/com/google/common/math/QuantilesAlgorithm.java
19 issues
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.
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.
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.
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.
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.
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.
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.
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.
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.
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-tests/benchmark/com/google/common/collect/MapBenchmark.java
19 issues
Line: 40
*/
public class MapBenchmark {
@Param({"Hash", "LinkedHM", "MapMaker1", "Immutable"})
private Impl impl;
public enum Impl {
Hash {
@Override
Map<Element, Element> create(Collection<Element> keys) {
Reported by PMD.
Line: 160
}
@Param({"5", "50", "500", "5000", "50000"})
private int size;
// TODO: look at exact (==) hits vs. equals() hits?
@Param("0.9")
private double hitRate;
Reported by PMD.
Line: 164
// TODO: look at exact (==) hits vs. equals() hits?
@Param("0.9")
private double hitRate;
@Param("true")
private boolean isUserTypeFast;
// "" means no fixed seed
Reported by PMD.
Line: 167
private double hitRate;
@Param("true")
private boolean isUserTypeFast;
// "" means no fixed seed
@Param("")
private SpecialRandom random;
Reported by PMD.
Line: 171
// "" means no fixed seed
@Param("")
private SpecialRandom random;
@Param("false")
private boolean sortedData;
// the following must be set during setUp
Reported by PMD.
Line: 174
private SpecialRandom random;
@Param("false")
private boolean sortedData;
// the following must be set during setUp
private Element[] queries;
private Map<Element, Element> mapToTest;
Reported by PMD.
Line: 177
private boolean sortedData;
// the following must be set during setUp
private Element[] queries;
private Map<Element, Element> mapToTest;
private Collection<Element> values;
@BeforeExperiment
Reported by PMD.
Line: 178
// the following must be set during setUp
private Element[] queries;
private Map<Element, Element> mapToTest;
private Collection<Element> values;
@BeforeExperiment
void setUp() {
Reported by PMD.
Line: 180
private Element[] queries;
private Map<Element, Element> mapToTest;
private Collection<Element> values;
@BeforeExperiment
void setUp() {
CollectionBenchmarkSampleData sampleData =
new CollectionBenchmarkSampleData(isUserTypeFast, random, hitRate, size);
Reported by PMD.
Line: 182
private Collection<Element> values;
@BeforeExperiment
void setUp() {
CollectionBenchmarkSampleData sampleData =
new CollectionBenchmarkSampleData(isUserTypeFast, random, hitRate, size);
if (sortedData) {
Reported by PMD.