The following issues were found
android/guava/src/com/google/common/collect/Tables.java
23 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
Reported by PMD.
Line: 122
}
if (obj instanceof Cell) {
Cell<?, ?, ?> other = (Cell<?, ?, ?>) obj;
return Objects.equal(getRowKey(), other.getRowKey())
&& Objects.equal(getColumnKey(), other.getColumnKey())
&& Objects.equal(getValue(), other.getValue());
}
return false;
}
Reported by PMD.
Line: 123
if (obj instanceof Cell) {
Cell<?, ?, ?> other = (Cell<?, ?, ?>) obj;
return Objects.equal(getRowKey(), other.getRowKey())
&& Objects.equal(getColumnKey(), other.getColumnKey())
&& Objects.equal(getValue(), other.getValue());
}
return false;
}
Reported by PMD.
Line: 124
Cell<?, ?, ?> other = (Cell<?, ?, ?>) obj;
return Objects.equal(getRowKey(), other.getRowKey())
&& Objects.equal(getColumnKey(), other.getColumnKey())
&& Objects.equal(getValue(), other.getValue());
}
return false;
}
@Override
Reported by PMD.
Line: 161
private static class TransposeTable<
C extends @Nullable Object, R extends @Nullable Object, V extends @Nullable Object>
extends AbstractTable<C, R, V> {
final Table<R, C, V> original;
TransposeTable(Table<R, C, V> original) {
this.original = checkNotNull(original);
}
Reported by PMD.
Line: 162
private static class TransposeTable<
C extends @Nullable Object, R extends @Nullable Object, V extends @Nullable Object>
extends AbstractTable<C, R, V> {
final Table<R, C, V> original;
TransposeTable(Table<R, C, V> original) {
this.original = checkNotNull(original);
}
Reported by PMD.
Line: 271
@SuppressWarnings("unchecked")
@Override
Iterator<Cell<C, R, V>> cellIterator() {
return Iterators.transform(original.cellSet().iterator(), (Function) TRANSPOSE_CELL);
}
}
/**
* Creates a table that uses the specified backing map and factory. It can generate a table based
Reported by PMD.
Line: 359
C extends @Nullable Object,
V1 extends @Nullable Object,
V2 extends @Nullable Object>
extends AbstractTable<R, C, V2> {
final Table<R, C, V1> fromTable;
final Function<? super V1, V2> function;
TransformedTable(Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
this.fromTable = checkNotNull(fromTable);
Reported by PMD.
Line: 360
V1 extends @Nullable Object,
V2 extends @Nullable Object>
extends AbstractTable<R, C, V2> {
final Table<R, C, V1> fromTable;
final Function<? super V1, V2> function;
TransformedTable(Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
this.fromTable = checkNotNull(fromTable);
this.function = checkNotNull(function);
Reported by PMD.
Line: 361
V2 extends @Nullable Object>
extends AbstractTable<R, C, V2> {
final Table<R, C, V1> fromTable;
final Function<? super V1, V2> function;
TransformedTable(Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
this.fromTable = checkNotNull(fromTable);
this.function = checkNotNull(function);
}
Reported by PMD.
android/guava/src/com/google/common/math/DoubleMath.java
23 issues
Line: 184
*/
// #roundIntermediate, java.lang.Math.getExponent, com.google.common.math.DoubleUtils
@GwtIncompatible
public static BigInteger roundToBigInteger(double x, RoundingMode mode) {
x = roundIntermediate(x, mode);
if (MIN_LONG_AS_DOUBLE - x < 1.0 & x < MAX_LONG_AS_DOUBLE_PLUS_ONE) {
return BigInteger.valueOf((long) x);
}
int exponent = getExponent(x);
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class DoubleMath {
/*
* This method returns a value y such that rounding y DOWN (towards zero) gives the same result as
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class DoubleMath {
/*
* This method returns a value y such that rounding y DOWN (towards zero) gives the same result as
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class DoubleMath {
/*
* This method returns a value y such that rounding y DOWN (towards zero) gives the same result as
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
Reported by PMD.
Line: 56
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
static double roundIntermediate(double x, RoundingMode mode) {
if (!isFinite(x)) {
throw new ArithmeticException("input is infinite or NaN");
}
switch (mode) {
case UNNECESSARY:
Reported by PMD.
Line: 56
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
static double roundIntermediate(double x, RoundingMode mode) {
if (!isFinite(x)) {
throw new ArithmeticException("input is infinite or NaN");
}
switch (mode) {
case UNNECESSARY:
Reported by PMD.
Line: 95
case HALF_UP:
{
double z = rint(x);
if (abs(x - z) == 0.5) {
return x + copySign(0.5, x);
} else {
return z;
}
}
Reported by PMD.
Line: 105
case HALF_DOWN:
{
double z = rint(x);
if (abs(x - z) == 0.5) {
return x;
} else {
return z;
}
}
Reported by PMD.
Line: 191
}
int exponent = getExponent(x);
long significand = getSignificand(x);
BigInteger result = BigInteger.valueOf(significand).shiftLeft(exponent - SIGNIFICAND_BITS);
return (x < 0) ? result.negate() : result;
}
/**
* Returns {@code true} if {@code x} is exactly equal to {@code 2^k} for some finite integer
Reported by PMD.
Line: 192
int exponent = getExponent(x);
long significand = getSignificand(x);
BigInteger result = BigInteger.valueOf(significand).shiftLeft(exponent - SIGNIFICAND_BITS);
return (x < 0) ? result.negate() : result;
}
/**
* Returns {@code true} if {@code x} is exactly equal to {@code 2^k} for some finite integer
* {@code k}.
Reported by PMD.
guava-tests/benchmark/com/google/common/util/concurrent/SingleThreadAbstractFutureBenchmark.java
23 issues
Line: 35
/** A benchmark that times how long it takes to add a given number of */
@VmOptions({"-Xms8g", "-Xmx8g"})
public class SingleThreadAbstractFutureBenchmark {
@Param Impl impl;
private final Exception exception = new Exception();
private Facade<?> notDoneFuture;
@BeforeExperiment
Reported by PMD.
Line: 37
public class SingleThreadAbstractFutureBenchmark {
@Param Impl impl;
private final Exception exception = new Exception();
private Facade<?> notDoneFuture;
@BeforeExperiment
void setUp() throws Exception {
notDoneFuture = impl.newFacade();
Reported by PMD.
Line: 38
@Param Impl impl;
private final Exception exception = new Exception();
private Facade<?> notDoneFuture;
@BeforeExperiment
void setUp() throws Exception {
notDoneFuture = impl.newFacade();
}
Reported by PMD.
Line: 40
private final Exception exception = new Exception();
private Facade<?> notDoneFuture;
@BeforeExperiment
void setUp() throws Exception {
notDoneFuture = impl.newFacade();
}
@Benchmark
Reported by PMD.
Line: 41
private Facade<?> notDoneFuture;
@BeforeExperiment
void setUp() throws Exception {
notDoneFuture = impl.newFacade();
}
@Benchmark
public long timeComplete_Normal(int reps) throws Exception {
Reported by PMD.
Line: 46
}
@Benchmark
public long timeComplete_Normal(int reps) throws Exception {
long r = 0;
List<Facade<Integer>> list = new ArrayList<>(reps);
for (int i = 0; i < reps; i++) {
final Facade<Integer> localFuture = impl.newFacade();
list.add(localFuture);
Reported by PMD.
Line: 52
for (int i = 0; i < reps; i++) {
final Facade<Integer> localFuture = impl.newFacade();
list.add(localFuture);
localFuture.set(i);
}
for (int i = 0; i < reps; i++) {
r += list.get(i).get();
}
return r;
Reported by PMD.
Line: 55
localFuture.set(i);
}
for (int i = 0; i < reps; i++) {
r += list.get(i).get();
}
return r;
}
@Benchmark
Reported by PMD.
Line: 61
}
@Benchmark
public long timeComplete_Failure(int reps) throws Exception {
long r = 0;
List<Facade<Integer>> list = new ArrayList<>(reps);
for (int i = 0; i < reps; i++) {
final Facade<Integer> localFuture = impl.newFacade();
list.add(localFuture);
Reported by PMD.
Line: 67
for (int i = 0; i < reps; i++) {
final Facade<Integer> localFuture = impl.newFacade();
list.add(localFuture);
localFuture.setException(exception);
}
for (int i = 0; i < reps; i++) {
Facade<Integer> facade = list.get(i);
try {
facade.get();
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapRemoveEntryTester.java
23 issues
Line: 40
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapRemoveEntryTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_supportedPresent() {
assertTrue(getMap().remove(k0(), v0()));
expectMissing(e0());
}
Reported by PMD.
Line: 43
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_supportedPresent() {
assertTrue(getMap().remove(k0(), v0()));
expectMissing(e0());
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedPresentKeyWrongValue() {
Reported by PMD.
Line: 47
expectMissing(e0());
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedPresentKeyWrongValue() {
assertFalse(getMap().remove(k0(), v3()));
expectUnchanged();
}
Reported by PMD.
Line: 49
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedPresentKeyWrongValue() {
assertFalse(getMap().remove(k0(), v3()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedWrongKeyPresentValue() {
Reported by PMD.
Line: 53
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedWrongKeyPresentValue() {
assertFalse(getMap().remove(k3(), v0()));
expectUnchanged();
}
Reported by PMD.
Line: 55
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedWrongKeyPresentValue() {
assertFalse(getMap().remove(k3(), v0()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedAbsentKeyAbsentValue() {
Reported by PMD.
Line: 59
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedAbsentKeyAbsentValue() {
assertFalse(getMap().remove(k3(), v3()));
expectUnchanged();
}
Reported by PMD.
Line: 61
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedAbsentKeyAbsentValue() {
assertFalse(getMap().remove(k3(), v3()));
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_KEY_QUERIES)
public void testRemove_nullKeyQueriesUnsupported() {
Reported by PMD.
Line: 65
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_KEY_QUERIES)
public void testRemove_nullKeyQueriesUnsupported() {
try {
assertFalse(getMap().remove(null, v3()));
} catch (NullPointerException tolerated) {
// since the operation would be a no-op, the exception is not required
Reported by PMD.
Line: 68
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_KEY_QUERIES)
public void testRemove_nullKeyQueriesUnsupported() {
try {
assertFalse(getMap().remove(null, v3()));
} catch (NullPointerException tolerated) {
// since the operation would be a no-op, the exception is not required
}
expectUnchanged();
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapReplaceTester.java
23 issues
Line: 42
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapReplaceTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplace_supportedPresent() {
try {
assertEquals(v0(), getMap().replace(k0(), v3()));
expectReplacement(entry(k0(), v3()));
Reported by PMD.
Line: 46
@CollectionSize.Require(absent = ZERO)
public void testReplace_supportedPresent() {
try {
assertEquals(v0(), getMap().replace(k0(), v3()));
expectReplacement(entry(k0(), v3()));
} catch (ClassCastException tolerated) { // for ClassToInstanceMap
expectUnchanged();
}
}
Reported by PMD.
Line: 53
}
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplace_supportedPresentNoChange() {
assertEquals(v0(), getMap().replace(k0(), v0()));
expectUnchanged();
}
Reported by PMD.
Line: 56
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplace_supportedPresentNoChange() {
assertEquals(v0(), getMap().replace(k0(), v0()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testReplace_supportedAbsent() {
Reported by PMD.
Line: 60
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testReplace_supportedAbsent() {
assertNull(getMap().replace(k3(), v3()));
expectUnchanged();
}
Reported by PMD.
Line: 62
@MapFeature.Require(SUPPORTS_PUT)
public void testReplace_supportedAbsent() {
assertNull(getMap().replace(k3(), v3()));
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 66
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testReplace_presentNullValueUnsupported() {
try {
getMap().replace(k0(), null);
fail("Expected NullPointerException");
Reported by PMD.
Line: 70
@CollectionSize.Require(absent = ZERO)
public void testReplace_presentNullValueUnsupported() {
try {
getMap().replace(k0(), null);
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
}
expectUnchanged();
}
Reported by PMD.
Line: 72
try {
getMap().replace(k0(), null);
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
}
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUE_QUERIES)
Reported by PMD.
Line: 72
try {
getMap().replace(k0(), null);
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
}
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUE_QUERIES)
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/ConcurrentMapRemoveTester.java
23 issues
Line: 45
return (ConcurrentMap<K, V>) super.getMap();
}
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_supportedPresent() {
assertTrue(getMap().remove(k0(), v0()));
expectMissing(e0());
}
Reported by PMD.
Line: 48
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_supportedPresent() {
assertTrue(getMap().remove(k0(), v0()));
expectMissing(e0());
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedPresentKeyWrongValue() {
Reported by PMD.
Line: 52
expectMissing(e0());
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedPresentKeyWrongValue() {
assertFalse(getMap().remove(k0(), v3()));
expectUnchanged();
}
Reported by PMD.
Line: 54
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedPresentKeyWrongValue() {
assertFalse(getMap().remove(k0(), v3()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedWrongKeyPresentValue() {
Reported by PMD.
Line: 58
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedWrongKeyPresentValue() {
assertFalse(getMap().remove(k3(), v0()));
expectUnchanged();
}
Reported by PMD.
Line: 60
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedWrongKeyPresentValue() {
assertFalse(getMap().remove(k3(), v0()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedAbsentKeyAbsentValue() {
Reported by PMD.
Line: 64
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedAbsentKeyAbsentValue() {
assertFalse(getMap().remove(k3(), v3()));
expectUnchanged();
}
Reported by PMD.
Line: 66
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemove_supportedAbsentKeyAbsentValue() {
assertFalse(getMap().remove(k3(), v3()));
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_KEY_QUERIES)
public void testRemove_nullKeyQueriesUnsupported() {
Reported by PMD.
Line: 70
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_KEY_QUERIES)
public void testRemove_nullKeyQueriesUnsupported() {
try {
assertFalse(getMap().remove(null, v3()));
} catch (NullPointerException tolerated) {
// since the operation would be a no-op, the exception is not required
Reported by PMD.
Line: 73
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_KEY_QUERIES)
public void testRemove_nullKeyQueriesUnsupported() {
try {
assertFalse(getMap().remove(null, v3()));
} catch (NullPointerException tolerated) {
// since the operation would be a no-op, the exception is not required
}
expectUnchanged();
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/ConcurrentMapPutIfAbsentTester.java
23 issues
Line: 47
return (ConcurrentMap<K, V>) super.getMap();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutIfAbsent_supportedAbsent() {
assertNull("putIfAbsent(notPresent, value) should return null", putIfAbsent(e3()));
expectAdded(e3());
}
Reported by PMD.
Line: 53
expectAdded(e3());
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutIfAbsent_supportedPresent() {
assertEquals(
"putIfAbsent(present, value) should return existing value",
v0(),
Reported by PMD.
Line: 59
assertEquals(
"putIfAbsent(present, value) should return existing value",
v0(),
getMap().putIfAbsent(k0(), v3()));
expectUnchanged();
}
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutIfAbsent_unsupportedAbsent() {
Reported by PMD.
Line: 63
expectUnchanged();
}
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutIfAbsent_unsupportedAbsent() {
try {
putIfAbsent(e3());
fail("putIfAbsent(notPresent, value) should throw");
} catch (UnsupportedOperationException expected) {
Reported by PMD.
Line: 74
expectMissing(e3());
}
@MapFeature.Require(absent = SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutIfAbsent_unsupportedPresentExistingValue() {
try {
assertEquals(
"putIfAbsent(present, existingValue) should return present or throw",
Reported by PMD.
Line: 82
"putIfAbsent(present, existingValue) should return present or throw",
v0(),
putIfAbsent(e0()));
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
@MapFeature.Require(absent = SUPPORTS_PUT)
Reported by PMD.
Line: 87
expectUnchanged();
}
@MapFeature.Require(absent = SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutIfAbsent_unsupportedPresentDifferentValue() {
try {
getMap().putIfAbsent(k0(), v3());
} catch (UnsupportedOperationException tolerated) {
Reported by PMD.
Line: 91
@CollectionSize.Require(absent = ZERO)
public void testPutIfAbsent_unsupportedPresentDifferentValue() {
try {
getMap().putIfAbsent(k0(), v3());
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
Reported by PMD.
Line: 92
public void testPutIfAbsent_unsupportedPresentDifferentValue() {
try {
getMap().putIfAbsent(k0(), v3());
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_KEYS)
Reported by PMD.
Line: 97
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_KEYS)
public void testPutIfAbsent_nullKeyUnsupported() {
try {
getMap().putIfAbsent(null, v3());
fail("putIfAbsent(null, value) should throw");
} catch (NullPointerException expected) {
Reported by PMD.
guava-tests/test/com/google/common/math/QuantilesAlgorithmTest.java
23 issues
Line: 43
Sets.difference(
ImmutableSet.copyOf(QuantilesAlgorithm.values()), ImmutableSet.of(REFERENCE_ALGORITHM));
private double[] dataset;
@Override
protected void setUp() {
dataset = new double[DATASET_SIZE];
for (int i = 0; i < DATASET_SIZE; i++) {
Reported by PMD.
Line: 45
private double[] dataset;
@Override
protected void setUp() {
dataset = new double[DATASET_SIZE];
for (int i = 0; i < DATASET_SIZE; i++) {
dataset[i] = RNG.nextDouble();
}
Reported by PMD.
Line: 53
}
}
public void testSingleQuantile_median() {
double referenceValue = REFERENCE_ALGORITHM.singleQuantile(1, 2, dataset.clone());
for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
.that(algorithm.singleQuantile(1, 2, dataset.clone()))
.isWithin(ALLOWED_ERROR)
Reported by PMD.
Line: 56
public void testSingleQuantile_median() {
double referenceValue = REFERENCE_ALGORITHM.singleQuantile(1, 2, dataset.clone());
for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
.that(algorithm.singleQuantile(1, 2, dataset.clone()))
.isWithin(ALLOWED_ERROR)
.of(referenceValue);
}
}
Reported by PMD.
Line: 56
public void testSingleQuantile_median() {
double referenceValue = REFERENCE_ALGORITHM.singleQuantile(1, 2, dataset.clone());
for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
.that(algorithm.singleQuantile(1, 2, dataset.clone()))
.isWithin(ALLOWED_ERROR)
.of(referenceValue);
}
}
Reported by PMD.
Line: 56
public void testSingleQuantile_median() {
double referenceValue = REFERENCE_ALGORITHM.singleQuantile(1, 2, dataset.clone());
for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
.that(algorithm.singleQuantile(1, 2, dataset.clone()))
.isWithin(ALLOWED_ERROR)
.of(referenceValue);
}
}
Reported by PMD.
Line: 63
}
}
public void testSingleQuantile_percentile99() {
double referenceValue = REFERENCE_ALGORITHM.singleQuantile(99, 100, dataset.clone());
for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
.that(algorithm.singleQuantile(99, 100, dataset.clone()))
.isWithin(ALLOWED_ERROR)
Reported by PMD.
Line: 66
public void testSingleQuantile_percentile99() {
double referenceValue = REFERENCE_ALGORITHM.singleQuantile(99, 100, dataset.clone());
for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
.that(algorithm.singleQuantile(99, 100, dataset.clone()))
.isWithin(ALLOWED_ERROR)
.of(referenceValue);
}
}
Reported by PMD.
Line: 66
public void testSingleQuantile_percentile99() {
double referenceValue = REFERENCE_ALGORITHM.singleQuantile(99, 100, dataset.clone());
for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
.that(algorithm.singleQuantile(99, 100, dataset.clone()))
.isWithin(ALLOWED_ERROR)
.of(referenceValue);
}
}
Reported by PMD.
Line: 66
public void testSingleQuantile_percentile99() {
double referenceValue = REFERENCE_ALGORITHM.singleQuantile(99, 100, dataset.clone());
for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
.that(algorithm.singleQuantile(99, 100, dataset.clone()))
.isWithin(ALLOWED_ERROR)
.of(referenceValue);
}
}
Reported by PMD.
guava-tests/benchmark/com/google/common/base/AsciiBenchmark.java
23 issues
Line: 39
private static final String NONALPHA = "0123456789`~-_=+[]{}|;:',.<>/?!@#$%^&*()\"\\";
@Param({"20", "2000"})
int size;
@Param({"2", "20"})
int nonAlphaRatio; // one non-alpha char per this many chars
@Param boolean noWorkToDo;
Reported by PMD.
Line: 42
int size;
@Param({"2", "20"})
int nonAlphaRatio; // one non-alpha char per this many chars
@Param boolean noWorkToDo;
Random random;
String testString;
Reported by PMD.
Line: 44
@Param({"2", "20"})
int nonAlphaRatio; // one non-alpha char per this many chars
@Param boolean noWorkToDo;
Random random;
String testString;
@BeforeExperiment
Reported by PMD.
Line: 46
@Param boolean noWorkToDo;
Random random;
String testString;
@BeforeExperiment
void setUp() {
random = new Random(0xdeadbeef); // fix the seed so results are comparable across runs
Reported by PMD.
Line: 47
@Param boolean noWorkToDo;
Random random;
String testString;
@BeforeExperiment
void setUp() {
random = new Random(0xdeadbeef); // fix the seed so results are comparable across runs
Reported by PMD.
Line: 49
Random random;
String testString;
@BeforeExperiment
void setUp() {
random = new Random(0xdeadbeef); // fix the seed so results are comparable across runs
int nonAlpha = size / nonAlphaRatio;
int alpha = size - nonAlpha;
Reported by PMD.
Line: 82
int dummy = 0;
for (int i = 0; i < reps; i++) {
dummy += Ascii.toUpperCase(string).length();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 93
int dummy = 0;
for (int i = 0; i < reps; i++) {
dummy += charSequenceToUpperCase(string).length();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 104
int dummy = 0;
for (int i = 0; i < reps; i++) {
dummy += string.toUpperCase(Locale.US).length();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 112
@Benchmark
boolean equalsIgnoreCaseCharSequence(int reps) {
// This benchmark has no concept of "noWorkToDo".
String upperString = testString.toUpperCase();
CharSequence testSeq = new StringBuilder(testString);
CharSequence upperSeq = new StringBuilder(upperString);
CharSequence[] lhs = new CharSequence[] {testString, testSeq, testString, testSeq};
CharSequence[] rhs = new CharSequence[] {upperString, upperString, upperSeq, upperSeq};
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/SortedMultisetTestSuiteBuilder.java
23 issues
Line: 77
@Override
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(MultisetNavigationTester.class);
return testers;
}
@Override
TestSuite createElementSetTestSuite(
Reported by PMD.
Line: 118
List<TestSuite> createDerivedSuites(SortedMultisetTestSuiteBuilder<E> parentBuilder) {
List<TestSuite> derivedSuites = Lists.newArrayList();
if (!parentBuilder.getFeatures().contains(NoRecurse.DESCENDING)) {
derivedSuites.add(createDescendingSuite(parentBuilder));
}
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
derivedSuites.add(createReserializedSuite(parentBuilder));
Reported by PMD.
Line: 122
derivedSuites.add(createDescendingSuite(parentBuilder));
}
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
derivedSuites.add(createReserializedSuite(parentBuilder));
}
if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMULTISET)) {
derivedSuites.add(createSubMultisetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
Reported by PMD.
Line: 126
derivedSuites.add(createReserializedSuite(parentBuilder));
}
if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMULTISET)) {
derivedSuites.add(createSubMultisetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
derivedSuites.add(createSubMultisetSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
derivedSuites.add(createSubMultisetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
derivedSuites.add(createSubMultisetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
derivedSuites.add(createSubMultisetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
Reported by PMD.
Line: 154
features.remove(SERIALIZABLE);
}
SortedMultiset<E> emptyMultiset = (SortedMultiset<E>) delegate.create();
final Comparator<? super E> comparator = emptyMultiset.comparator();
SampleElements<E> samples = delegate.samples();
@SuppressWarnings("unchecked")
List<E> samplesList =
Arrays.asList(samples.e0(), samples.e1(), samples.e2(), samples.e3(), samples.e4());
Reported by PMD.
Line: 155
}
SortedMultiset<E> emptyMultiset = (SortedMultiset<E>) delegate.create();
final Comparator<? super E> comparator = emptyMultiset.comparator();
SampleElements<E> samples = delegate.samples();
@SuppressWarnings("unchecked")
List<E> samplesList =
Arrays.asList(samples.e0(), samples.e1(), samples.e2(), samples.e3(), samples.e4());
Reported by PMD.
Line: 156
SortedMultiset<E> emptyMultiset = (SortedMultiset<E>) delegate.create();
final Comparator<? super E> comparator = emptyMultiset.comparator();
SampleElements<E> samples = delegate.samples();
@SuppressWarnings("unchecked")
List<E> samplesList =
Arrays.asList(samples.e0(), samples.e1(), samples.e2(), samples.e3(), samples.e4());
Collections.sort(samplesList, comparator);
Reported by PMD.
Line: 159
SampleElements<E> samples = delegate.samples();
@SuppressWarnings("unchecked")
List<E> samplesList =
Arrays.asList(samples.e0(), samples.e1(), samples.e2(), samples.e3(), samples.e4());
Collections.sort(samplesList, comparator);
final E firstInclusive = samplesList.get(0);
final E lastInclusive = samplesList.get(samplesList.size() - 1);
Reported by PMD.
Line: 159
SampleElements<E> samples = delegate.samples();
@SuppressWarnings("unchecked")
List<E> samplesList =
Arrays.asList(samples.e0(), samples.e1(), samples.e2(), samples.e3(), samples.e4());
Collections.sort(samplesList, comparator);
final E firstInclusive = samplesList.get(0);
final E lastInclusive = samplesList.get(samplesList.size() - 1);
Reported by PMD.
Line: 159
SampleElements<E> samples = delegate.samples();
@SuppressWarnings("unchecked")
List<E> samplesList =
Arrays.asList(samples.e0(), samples.e1(), samples.e2(), samples.e3(), samples.e4());
Collections.sort(samplesList, comparator);
final E firstInclusive = samplesList.get(0);
final E lastInclusive = samplesList.get(samplesList.size() - 1);
Reported by PMD.