The following issues were found
guava/src/com/google/common/cache/ForwardingCache.java
14 issues
Line: 49
@Override
@CheckForNull
public V getIfPresent(Object key) {
return delegate().getIfPresent(key);
}
/** @since 11.0 */
@Override
public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
Reported by PMD.
Line: 55
/** @since 11.0 */
@Override
public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
return delegate().get(key, valueLoader);
}
/** @since 11.0 */
@Override
/*
Reported by PMD.
Line: 65
* differ: <? extends Object> means "non-null types," while <?> means "all types."
*/
public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) {
return delegate().getAllPresent(keys);
}
/** @since 11.0 */
@Override
public void put(K key, V value) {
Reported by PMD.
Line: 71
/** @since 11.0 */
@Override
public void put(K key, V value) {
delegate().put(key, value);
}
/** @since 12.0 */
@Override
public void putAll(Map<? extends K, ? extends V> m) {
Reported by PMD.
Line: 77
/** @since 12.0 */
@Override
public void putAll(Map<? extends K, ? extends V> m) {
delegate().putAll(m);
}
@Override
public void invalidate(Object key) {
delegate().invalidate(key);
Reported by PMD.
Line: 82
@Override
public void invalidate(Object key) {
delegate().invalidate(key);
}
/** @since 11.0 */
@Override
// For discussion of <? extends Object>, see getAllPresent.
Reported by PMD.
Line: 89
@Override
// For discussion of <? extends Object>, see getAllPresent.
public void invalidateAll(Iterable<? extends Object> keys) {
delegate().invalidateAll(keys);
}
@Override
public void invalidateAll() {
delegate().invalidateAll();
Reported by PMD.
Line: 94
@Override
public void invalidateAll() {
delegate().invalidateAll();
}
@Override
public long size() {
return delegate().size();
Reported by PMD.
Line: 99
@Override
public long size() {
return delegate().size();
}
@Override
public CacheStats stats() {
return delegate().stats();
Reported by PMD.
Line: 104
@Override
public CacheStats stats() {
return delegate().stats();
}
@Override
public ConcurrentMap<K, V> asMap() {
return delegate().asMap();
Reported by PMD.
guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java
14 issues
Line: 41
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class LongArrayAsListTest extends TestCase {
private static List<Long> asList(Long[] values) {
long[] temp = new long[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
Reported by PMD.
Line: 51
return Longs.asList(temp);
}
@GwtIncompatible // suite
public static Test suite() {
List<ListTestSuiteBuilder<Long>> builders =
ImmutableList.of(
ListTestSuiteBuilder.using(new LongsAsListGenerator()).named("Longs.asList"),
ListTestSuiteBuilder.using(new LongsAsListHeadSubListGenerator())
Reported by PMD.
Line: 66
TestSuite suite = new TestSuite();
for (ListTestSuiteBuilder<Long> builder : builders) {
suite.addTest(
builder
.withFeatures(
CollectionSize.ONE,
CollectionSize.SEVERAL,
CollectionFeature.RESTRICTS_ELEMENTS,
ListFeature.SUPPORTS_SET)
Reported by PMD.
Line: 92
protected List<Long> create(Long[] elements) {
Long[] suffix = {Long.MIN_VALUE, Long.MAX_VALUE};
Long[] all = concat(elements, suffix);
return asList(all).subList(0, elements.length);
}
}
public static final class LongsAsListTailSubListGenerator extends TestLongListGenerator {
@Override
Reported by PMD.
Line: 101
protected List<Long> create(Long[] elements) {
Long[] prefix = {(long) 86, (long) 99};
Long[] all = concat(prefix, elements);
return asList(all).subList(2, elements.length + 2);
}
}
public static final class LongsAsListMiddleSubListGenerator extends TestLongListGenerator {
@Override
Reported by PMD.
Line: 111
Long[] prefix = {Long.MIN_VALUE, Long.MAX_VALUE};
Long[] suffix = {(long) 86, (long) 99};
Long[] all = concat(concat(prefix, elements), suffix);
return asList(all).subList(2, elements.length + 2);
}
}
private static Long[] concat(Long[] left, Long[] right) {
Long[] result = new Long[left.length + right.length];
Reported by PMD.
Line: 43
@GwtCompatible(emulated = true)
public class LongArrayAsListTest extends TestCase {
private static List<Long> asList(Long[] values) {
long[] temp = new long[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Longs.asList(temp);
Reported by PMD.
Line: 115
}
}
private static Long[] concat(Long[] left, Long[] right) {
Long[] result = new Long[left.length + right.length];
System.arraycopy(left, 0, result, 0, left.length);
System.arraycopy(right, 0, result, left.length, right.length);
return result;
}
Reported by PMD.
Line: 142
* Creates a new collection containing the given elements; implement this method instead of
* {@link #create(Object...)}.
*/
protected abstract List<Long> create(Long[] elements);
@Override
public Long[] createArray(int length) {
return new Long[length];
}
Reported by PMD.
Line: 44
public class LongArrayAsListTest extends TestCase {
private static List<Long> asList(Long[] values) {
long[] temp = new long[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Longs.asList(temp);
}
Reported by PMD.
guava/src/com/google/common/math/PairedStatsAccumulator.java
14 issues
Line: 36
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class PairedStatsAccumulator {
// These fields must satisfy the requirements of PairedStats' constructor as well as those of the
// stat methods of this class.
private final StatsAccumulator xStats = new StatsAccumulator();
private final StatsAccumulator yStats = new StatsAccumulator();
Reported by PMD.
Line: 40
// These fields must satisfy the requirements of PairedStats' constructor as well as those of the
// stat methods of this class.
private final StatsAccumulator xStats = new StatsAccumulator();
private final StatsAccumulator yStats = new StatsAccumulator();
private double sumOfProductsOfDeltas = 0.0;
/** Adds the given pair of values to the dataset. */
public void add(double x, double y) {
Reported by PMD.
Line: 40
// These fields must satisfy the requirements of PairedStats' constructor as well as those of the
// stat methods of this class.
private final StatsAccumulator xStats = new StatsAccumulator();
private final StatsAccumulator yStats = new StatsAccumulator();
private double sumOfProductsOfDeltas = 0.0;
/** Adds the given pair of values to the dataset. */
public void add(double x, double y) {
Reported by PMD.
Line: 41
// These fields must satisfy the requirements of PairedStats' constructor as well as those of the
// stat methods of this class.
private final StatsAccumulator xStats = new StatsAccumulator();
private final StatsAccumulator yStats = new StatsAccumulator();
private double sumOfProductsOfDeltas = 0.0;
/** Adds the given pair of values to the dataset. */
public void add(double x, double y) {
// We extend the recursive expression for the one-variable case at Art of Computer Programming
Reported by PMD.
Line: 41
// These fields must satisfy the requirements of PairedStats' constructor as well as those of the
// stat methods of this class.
private final StatsAccumulator xStats = new StatsAccumulator();
private final StatsAccumulator yStats = new StatsAccumulator();
private double sumOfProductsOfDeltas = 0.0;
/** Adds the given pair of values to the dataset. */
public void add(double x, double y) {
// We extend the recursive expression for the one-variable case at Art of Computer Programming
Reported by PMD.
Line: 42
// stat methods of this class.
private final StatsAccumulator xStats = new StatsAccumulator();
private final StatsAccumulator yStats = new StatsAccumulator();
private double sumOfProductsOfDeltas = 0.0;
/** Adds the given pair of values to the dataset. */
public void add(double x, double y) {
// We extend the recursive expression for the one-variable case at Art of Computer Programming
// vol. 2, Knuth, 4.2.2, (16) to the two-variable case. We have two value series x_i and y_i.
Reported by PMD.
Line: 42
// stat methods of this class.
private final StatsAccumulator xStats = new StatsAccumulator();
private final StatsAccumulator yStats = new StatsAccumulator();
private double sumOfProductsOfDeltas = 0.0;
/** Adds the given pair of values to the dataset. */
public void add(double x, double y) {
// We extend the recursive expression for the one-variable case at Art of Computer Programming
// vol. 2, Knuth, 4.2.2, (16) to the two-variable case. We have two value series x_i and y_i.
Reported by PMD.
Line: 59
// = (x_n - X_n) (y_n - Y_{n-1})
xStats.add(x);
if (isFinite(x) && isFinite(y)) {
if (xStats.count() > 1) {
sumOfProductsOfDeltas += (x - xStats.mean()) * (y - yStats.mean());
}
} else {
sumOfProductsOfDeltas = NaN;
}
Reported by PMD.
Line: 86
// in NaN naturally.
sumOfProductsOfDeltas +=
values.sumOfProductsOfDeltas()
+ (values.xStats().mean() - xStats.mean())
* (values.yStats().mean() - yStats.mean())
* values.count();
}
yStats.addAll(values.yStats());
}
Reported by PMD.
Line: 87
sumOfProductsOfDeltas +=
values.sumOfProductsOfDeltas()
+ (values.xStats().mean() - xStats.mean())
* (values.yStats().mean() - yStats.mean())
* values.count();
}
yStats.addAll(values.yStats());
}
Reported by PMD.
guava/src/com/google/common/math/ToDoubleRounder.java
14 issues
Line: 29
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ToDoubleRounder<X extends Number & Comparable<X>> {
/**
* Returns x rounded to either the greatest double less than or equal to the precise value of x,
* or the least double greater than or equal to the precise value of x.
*/
abstract double roundToDoubleArbitrarily(X x);
Reported by PMD.
Line: 29
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ToDoubleRounder<X extends Number & Comparable<X>> {
/**
* Returns x rounded to either the greatest double less than or equal to the precise value of x,
* or the least double greater than or equal to the precise value of x.
*/
abstract double roundToDoubleArbitrarily(X x);
Reported by PMD.
Line: 46
abstract X minus(X a, X b);
/** Rounds {@code x} to a {@code double}. */
final double roundToDouble(X x, RoundingMode mode) {
checkNotNull(x, "x");
checkNotNull(mode, "mode");
double roundArbitrarily = roundToDoubleArbitrarily(x);
if (Double.isInfinite(roundArbitrarily)) {
switch (mode) {
Reported by PMD.
Line: 46
abstract X minus(X a, X b);
/** Rounds {@code x} to a {@code double}. */
final double roundToDouble(X x, RoundingMode mode) {
checkNotNull(x, "x");
checkNotNull(mode, "mode");
double roundArbitrarily = roundToDoubleArbitrarily(x);
if (Double.isInfinite(roundArbitrarily)) {
switch (mode) {
Reported by PMD.
Line: 46
abstract X minus(X a, X b);
/** Rounds {@code x} to a {@code double}. */
final double roundToDouble(X x, RoundingMode mode) {
checkNotNull(x, "x");
checkNotNull(mode, "mode");
double roundArbitrarily = roundToDoubleArbitrarily(x);
if (Double.isInfinite(roundArbitrarily)) {
switch (mode) {
Reported by PMD.
Line: 46
abstract X minus(X a, X b);
/** Rounds {@code x} to a {@code double}. */
final double roundToDouble(X x, RoundingMode mode) {
checkNotNull(x, "x");
checkNotNull(mode, "mode");
double roundArbitrarily = roundToDoubleArbitrarily(x);
if (Double.isInfinite(roundArbitrarily)) {
switch (mode) {
Reported by PMD.
Line: 46
abstract X minus(X a, X b);
/** Rounds {@code x} to a {@code double}. */
final double roundToDouble(X x, RoundingMode mode) {
checkNotNull(x, "x");
checkNotNull(mode, "mode");
double roundArbitrarily = roundToDoubleArbitrarily(x);
if (Double.isInfinite(roundArbitrarily)) {
switch (mode) {
Reported by PMD.
Line: 46
abstract X minus(X a, X b);
/** Rounds {@code x} to a {@code double}. */
final double roundToDouble(X x, RoundingMode mode) {
checkNotNull(x, "x");
checkNotNull(mode, "mode");
double roundArbitrarily = roundToDoubleArbitrarily(x);
if (Double.isInfinite(roundArbitrarily)) {
switch (mode) {
Reported by PMD.
Line: 128
X deltaToFloor = minus(x, roundFloor);
X deltaToCeiling = minus(roundCeiling, x);
int diff = deltaToFloor.compareTo(deltaToCeiling);
if (diff < 0) { // closer to floor
return roundFloorAsDouble;
} else if (diff > 0) { // closer to ceiling
return roundCeilingAsDouble;
}
Reported by PMD.
Line: 72
}
}
X roundArbitrarilyAsX = toX(roundArbitrarily, RoundingMode.UNNECESSARY);
int cmpXToRoundArbitrarily = x.compareTo(roundArbitrarilyAsX);
switch (mode) {
case UNNECESSARY:
checkRoundingUnnecessary(cmpXToRoundArbitrarily == 0);
return roundArbitrarily;
case FLOOR:
Reported by PMD.
android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java
14 issues
Line: 65
*/
@Override
@CheckForNull
public final Object invoke(Object proxy, Method method, @CheckForNull @Nullable Object[] args)
throws Throwable {
if (args == null) {
args = NO_ARGS;
}
if (args.length == 0 && method.getName().equals("hashCode")) {
Reported by PMD.
Line: 65
*/
@Override
@CheckForNull
public final Object invoke(Object proxy, Method method, @CheckForNull @Nullable Object[] args)
throws Throwable {
if (args == null) {
args = NO_ARGS;
}
if (args.length == 0 && method.getName().equals("hashCode")) {
Reported by PMD.
Line: 70
if (args == null) {
args = NO_ARGS;
}
if (args.length == 0 && method.getName().equals("hashCode")) {
return hashCode();
}
if (args.length == 1
&& method.getName().equals("equals")
&& method.getParameterTypes()[0] == Object.class) {
Reported by PMD.
Line: 70
if (args == null) {
args = NO_ARGS;
}
if (args.length == 0 && method.getName().equals("hashCode")) {
return hashCode();
}
if (args.length == 1
&& method.getName().equals("equals")
&& method.getParameterTypes()[0] == Object.class) {
Reported by PMD.
Line: 74
return hashCode();
}
if (args.length == 1
&& method.getName().equals("equals")
&& method.getParameterTypes()[0] == Object.class) {
Object arg = args[0];
if (arg == null) {
return false;
}
Reported by PMD.
Line: 74
return hashCode();
}
if (args.length == 1
&& method.getName().equals("equals")
&& method.getParameterTypes()[0] == Object.class) {
Object arg = args[0];
if (arg == null) {
return false;
}
Reported by PMD.
Line: 80
if (arg == null) {
return false;
}
if (proxy == arg) {
return true;
}
return isProxyOfSameInterfaces(arg, proxy.getClass())
&& equals(Proxy.getInvocationHandler(arg));
}
Reported by PMD.
Line: 86
return isProxyOfSameInterfaces(arg, proxy.getClass())
&& equals(Proxy.getInvocationHandler(arg));
}
if (args.length == 0 && method.getName().equals("toString")) {
return toString();
}
return handleInvocation(proxy, method, args);
}
Reported by PMD.
Line: 86
return isProxyOfSameInterfaces(arg, proxy.getClass())
&& equals(Proxy.getInvocationHandler(arg));
}
if (args.length == 0 && method.getName().equals("toString")) {
return toString();
}
return handleInvocation(proxy, method, args);
}
Reported by PMD.
Line: 116
* <p>Subclasses can override this method to provide custom equality.
*/
@Override
public boolean equals(@CheckForNull Object obj) {
return super.equals(obj);
}
/**
* By default delegates to {@link Object#hashCode}. The dynamic proxies' {@code hashCode()} will
Reported by PMD.
android/guava/src/com/google/common/cache/ForwardingCache.java
14 issues
Line: 49
@Override
@CheckForNull
public V getIfPresent(Object key) {
return delegate().getIfPresent(key);
}
/** @since 11.0 */
@Override
public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
Reported by PMD.
Line: 55
/** @since 11.0 */
@Override
public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
return delegate().get(key, valueLoader);
}
/** @since 11.0 */
@Override
/*
Reported by PMD.
Line: 65
* differ: <? extends Object> means "non-null types," while <?> means "all types."
*/
public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) {
return delegate().getAllPresent(keys);
}
/** @since 11.0 */
@Override
public void put(K key, V value) {
Reported by PMD.
Line: 71
/** @since 11.0 */
@Override
public void put(K key, V value) {
delegate().put(key, value);
}
/** @since 12.0 */
@Override
public void putAll(Map<? extends K, ? extends V> m) {
Reported by PMD.
Line: 77
/** @since 12.0 */
@Override
public void putAll(Map<? extends K, ? extends V> m) {
delegate().putAll(m);
}
@Override
public void invalidate(Object key) {
delegate().invalidate(key);
Reported by PMD.
Line: 82
@Override
public void invalidate(Object key) {
delegate().invalidate(key);
}
/** @since 11.0 */
@Override
// For discussion of <? extends Object>, see getAllPresent.
Reported by PMD.
Line: 89
@Override
// For discussion of <? extends Object>, see getAllPresent.
public void invalidateAll(Iterable<? extends Object> keys) {
delegate().invalidateAll(keys);
}
@Override
public void invalidateAll() {
delegate().invalidateAll();
Reported by PMD.
Line: 94
@Override
public void invalidateAll() {
delegate().invalidateAll();
}
@Override
public long size() {
return delegate().size();
Reported by PMD.
Line: 99
@Override
public long size() {
return delegate().size();
}
@Override
public CacheStats stats() {
return delegate().stats();
Reported by PMD.
Line: 104
@Override
public CacheStats stats() {
return delegate().stats();
}
@Override
public ConcurrentMap<K, V> asMap() {
return delegate().asMap();
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
14 issues
Line: 34
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
static final class RegularEntrySet<K, V> extends ImmutableMapEntrySet<K, V> {
private final transient ImmutableMap<K, V> map;
private final transient ImmutableList<Entry<K, V>> entries;
RegularEntrySet(ImmutableMap<K, V> map, Entry<K, V>[] entries) {
Reported by PMD.
Line: 35
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
static final class RegularEntrySet<K, V> extends ImmutableMapEntrySet<K, V> {
private final transient ImmutableMap<K, V> map;
private final transient ImmutableList<Entry<K, V>> entries;
RegularEntrySet(ImmutableMap<K, V> map, Entry<K, V>[] entries) {
this(map, ImmutableList.<Entry<K, V>>asImmutableList(entries));
Reported by PMD.
Line: 36
@ElementTypesAreNonnullByDefault
abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
static final class RegularEntrySet<K, V> extends ImmutableMapEntrySet<K, V> {
private final transient ImmutableMap<K, V> map;
private final transient ImmutableList<Entry<K, V>> entries;
RegularEntrySet(ImmutableMap<K, V> map, Entry<K, V>[] entries) {
this(map, ImmutableList.<Entry<K, V>>asImmutableList(entries));
}
Reported by PMD.
Line: 76
@Override
public int size() {
return map().size();
}
@Override
public boolean contains(@CheckForNull Object object) {
if (object instanceof Entry) {
Reported by PMD.
Line: 83
public boolean contains(@CheckForNull Object object) {
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
V value = map().get(entry.getKey());
return value != null && value.equals(entry.getValue());
}
return false;
}
Reported by PMD.
Line: 83
public boolean contains(@CheckForNull Object object) {
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
V value = map().get(entry.getKey());
return value != null && value.equals(entry.getValue());
}
return false;
}
Reported by PMD.
Line: 84
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
V value = map().get(entry.getKey());
return value != null && value.equals(entry.getValue());
}
return false;
}
@Override
Reported by PMD.
Line: 84
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
V value = map().get(entry.getKey());
return value != null && value.equals(entry.getValue());
}
return false;
}
@Override
Reported by PMD.
Line: 91
@Override
boolean isPartialView() {
return map().isPartialView();
}
@Override
@GwtIncompatible // not used in GWT
boolean isHashCodeFast() {
Reported by PMD.
Line: 97
@Override
@GwtIncompatible // not used in GWT
boolean isHashCodeFast() {
return map().isHashCodeFast();
}
@Override
public int hashCode() {
return map().hashCode();
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java
14 issues
Line: 41
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class DoubleArrayAsListTest extends TestCase {
private static List<Double> asList(Double[] values) {
double[] temp = new double[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
Reported by PMD.
Line: 51
return Doubles.asList(temp);
}
@GwtIncompatible // suite
public static Test suite() {
List<ListTestSuiteBuilder<Double>> builders =
ImmutableList.of(
ListTestSuiteBuilder.using(new DoublesAsListGenerator()).named("Doubles.asList"),
ListTestSuiteBuilder.using(new DoublsAsListHeadSubListGenerator())
Reported by PMD.
Line: 66
TestSuite suite = new TestSuite();
for (ListTestSuiteBuilder<Double> builder : builders) {
suite.addTest(
builder
.withFeatures(
CollectionSize.ONE,
CollectionSize.SEVERAL,
CollectionFeature.RESTRICTS_ELEMENTS,
ListFeature.SUPPORTS_SET)
Reported by PMD.
Line: 92
protected List<Double> create(Double[] elements) {
Double[] suffix = {Double.MIN_VALUE, Double.MAX_VALUE};
Double[] all = concat(elements, suffix);
return asList(all).subList(0, elements.length);
}
}
public static final class DoublesAsListTailSubListGenerator extends TestDoubleListGenerator {
@Override
Reported by PMD.
Line: 101
protected List<Double> create(Double[] elements) {
Double[] prefix = {(double) 86, (double) 99};
Double[] all = concat(prefix, elements);
return asList(all).subList(2, elements.length + 2);
}
}
public static final class DoublesAsListMiddleSubListGenerator extends TestDoubleListGenerator {
@Override
Reported by PMD.
Line: 111
Double[] prefix = {Double.MIN_VALUE, Double.MAX_VALUE};
Double[] suffix = {(double) 86, (double) 99};
Double[] all = concat(concat(prefix, elements), suffix);
return asList(all).subList(2, elements.length + 2);
}
}
private static Double[] concat(Double[] left, Double[] right) {
Double[] result = new Double[left.length + right.length];
Reported by PMD.
Line: 43
@GwtCompatible(emulated = true)
public class DoubleArrayAsListTest extends TestCase {
private static List<Double> asList(Double[] values) {
double[] temp = new double[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Doubles.asList(temp);
Reported by PMD.
Line: 115
}
}
private static Double[] concat(Double[] left, Double[] right) {
Double[] result = new Double[left.length + right.length];
System.arraycopy(left, 0, result, 0, left.length);
System.arraycopy(right, 0, result, left.length, right.length);
return result;
}
Reported by PMD.
Line: 142
* Creates a new collection containing the given elements; implement this method instead of
* {@link #create(Object...)}.
*/
protected abstract List<Double> create(Double[] elements);
@Override
public Double[] createArray(int length) {
return new Double[length];
}
Reported by PMD.
Line: 44
public class DoubleArrayAsListTest extends TestCase {
private static List<Double> asList(Double[] values) {
double[] temp = new double[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Doubles.asList(temp);
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MapGenerators.java
14 issues
Line: 89
for (UnhashableObject value : elements) {
builder.put(key++, value);
}
return builder.build().values();
}
}
public static class ImmutableMapKeyListGenerator extends TestStringListGenerator {
@Override
Reported by PMD.
Line: 100
for (int i = 0; i < elements.length; i++) {
builder.put(elements[i], i);
}
return builder.build().keySet().asList();
}
}
public static class ImmutableMapValueListGenerator extends TestStringListGenerator {
@Override
Reported by PMD.
Line: 100
for (int i = 0; i < elements.length; i++) {
builder.put(elements[i], i);
}
return builder.build().keySet().asList();
}
}
public static class ImmutableMapValueListGenerator extends TestStringListGenerator {
@Override
Reported by PMD.
Line: 111
for (int i = 0; i < elements.length; i++) {
builder.put(i, elements[i]);
}
return builder.build().values().asList();
}
}
public static class ImmutableMapEntryListGenerator
implements TestListGenerator<Entry<String, Integer>> {
Reported by PMD.
Line: 111
for (int i = 0; i < elements.length; i++) {
builder.put(i, elements[i]);
}
return builder.build().values().asList();
}
}
public static class ImmutableMapEntryListGenerator
implements TestListGenerator<Entry<String, Integer>> {
Reported by PMD.
Line: 128
mapEntry("toaster", -2));
}
@SuppressWarnings("unchecked")
@Override
public Entry<String, Integer>[] createArray(int length) {
return new Entry[length];
}
Reported by PMD.
Line: 147
Entry<String, Integer> entry = (Entry<String, Integer>) o;
builder.put(entry);
}
return builder.build().entrySet().asList();
}
}
public static class ImmutableEnumMapGenerator extends TestEnumMapGenerator {
@Override
Reported by PMD.
Line: 147
Entry<String, Integer> entry = (Entry<String, Integer>) o;
builder.put(entry);
}
return builder.build().entrySet().asList();
}
}
public static class ImmutableEnumMapGenerator extends TestEnumMapGenerator {
@Override
Reported by PMD.
Line: 179
@Override
public int compare(Entry<AnEnum, String> left, Entry<AnEnum, String> right) {
return left.getKey().compareTo(right.getKey());
}
}.sortedCopy(insertionOrder);
}
}
Reported by PMD.
Line: 210
for (Object elem : elements) {
@SuppressWarnings("unchecked") // safe by generator contract
Entry<String, Collection<Integer>> entry = (Entry<String, Collection<Integer>>) elem;
Integer value = Iterables.getOnlyElement(entry.getValue());
builder.put(entry.getKey(), value);
}
return builder.build().asMultimap().asMap();
}
Reported by PMD.
android/guava/src/com/google/common/primitives/UnsignedLongs.java
14 issues
Line: 457
* @throws IllegalArgumentException if {@code radix} is not between {@link Character#MIN_RADIX}
* and {@link Character#MAX_RADIX}.
*/
public static String toString(long x, int radix) {
checkArgument(
radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX,
"radix (%s) must be between Character.MIN_RADIX and Character.MAX_RADIX",
radix);
if (x == 0) {
Reported by PMD.
Line: 457
* @throws IllegalArgumentException if {@code radix} is not between {@link Character#MIN_RADIX}
* and {@link Character#MAX_RADIX}.
*/
public static String toString(long x, int radix) {
checkArgument(
radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX,
"radix (%s) must be between Character.MIN_RADIX and Character.MAX_RADIX",
radix);
if (x == 0) {
Reported by PMD.
Line: 457
* @throws IllegalArgumentException if {@code radix} is not between {@link Character#MIN_RADIX}
* and {@link Character#MAX_RADIX}.
*/
public static String toString(long x, int radix) {
checkArgument(
radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX,
"radix (%s) must be between Character.MIN_RADIX and Character.MAX_RADIX",
radix);
if (x == 0) {
Reported by PMD.
Line: 54
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class UnsignedLongs {
private UnsignedLongs() {}
public static final long MAX_VALUE = -1L; // Equivalent to 2^64 - 1
/**
Reported by PMD.
Line: 54
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class UnsignedLongs {
private UnsignedLongs() {}
public static final long MAX_VALUE = -1L; // Equivalent to 2^64 - 1
/**
Reported by PMD.
Line: 338
* Long#parseLong(String)})
*/
@CanIgnoreReturnValue
public static long parseUnsignedLong(String string, int radix) {
checkNotNull(string);
if (string.length() == 0) {
throw new NumberFormatException("empty string");
}
if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
Reported by PMD.
Line: 186
*
* @since 23.1
*/
public static void sort(long[] array) {
checkNotNull(array);
sort(array, 0, array.length);
}
/**
Reported by PMD.
Line: 215
*
* @since 23.1
*/
public static void sortDescending(long[] array) {
checkNotNull(array);
sortDescending(array, 0, array.length);
}
/**
Reported by PMD.
Line: 347
throw new NumberFormatException("illegal radix: " + radix);
}
int maxSafePos = ParseOverflowDetection.maxSafeDigits[radix] - 1;
long value = 0;
for (int pos = 0; pos < string.length(); pos++) {
int digit = Character.digit(string.charAt(pos), radix);
if (digit == -1) {
throw new NumberFormatException(string);
Reported by PMD.
Line: 348
}
int maxSafePos = ParseOverflowDetection.maxSafeDigits[radix] - 1;
long value = 0;
for (int pos = 0; pos < string.length(); pos++) {
int digit = Character.digit(string.charAt(pos), radix);
if (digit == -1) {
throw new NumberFormatException(string);
}
Reported by PMD.