The following issues were found
android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java
21 issues
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);
/** Returns the empty array. */
public static ImmutableDoubleArray of() {
return EMPTY;
Reported by PMD.
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);
/** Returns the empty array. */
public static ImmutableDoubleArray of() {
return EMPTY;
Reported by PMD.
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);
/** Returns the empty array. */
public static ImmutableDoubleArray of() {
return EMPTY;
Reported by PMD.
Line: 164
if (values instanceof Collection) {
return copyOf((Collection<Double>) values);
}
return builder().addAll(values).build();
}
/**
* Returns a new, empty builder for {@link ImmutableDoubleArray} instances, sized to hold up to
* {@code initialCapacity} values without resizing. The returned builder is not thread-safe.
Reported by PMD.
Line: 164
if (values instanceof Collection) {
return copyOf((Collection<Double>) values);
}
return builder().addAll(values).build();
}
/**
* Returns a new, empty builder for {@link ImmutableDoubleArray} instances, sized to hold up to
* {@code initialCapacity} values without resizing. The returned builder is not thread-safe.
Reported by PMD.
Line: 200
*/
@CanIgnoreReturnValue
public static final class Builder {
private double[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new double[initialCapacity];
}
Reported by PMD.
Line: 201
@CanIgnoreReturnValue
public static final class Builder {
private double[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new double[initialCapacity];
}
Reported by PMD.
Line: 201
@CanIgnoreReturnValue
public static final class Builder {
private double[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new double[initialCapacity];
}
Reported by PMD.
Line: 308
// The array is never mutated after storing in this field and the construction strategies ensure
// it doesn't escape this class
@SuppressWarnings("Immutable")
private final double[] array;
/*
* TODO(kevinb): evaluate the trade-offs of going bimorphic to save these two fields from most
* instances. Note that the instances that would get smaller are the right set to care about
* optimizing, because the rest have the option of calling `trimmed`.
Reported by PMD.
Line: 317
*/
private final transient int start; // it happens that we only serialize instances where this is 0
private final int end; // exclusive
private ImmutableDoubleArray(double[] array) {
this(array, 0, array.length);
}
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
21 issues
Line: 194
@Override
public Integer get() {
throw new RuntimeException("Oops");
}
}
}
Reported by PMD.
Line: 39
protected static final int SLOW_FUNC_VALID_INPUT_DATA = 3;
private static final String RESULT_DATA = "SUCCESS";
private SettableFuture<String> outputFuture;
// Signals that the function is waiting to complete
private CountDownLatch funcIsWaitingLatch;
// Signals the function so it will complete
private CountDownLatch funcCompletionLatch;
Reported by PMD.
Line: 41
private SettableFuture<String> outputFuture;
// Signals that the function is waiting to complete
private CountDownLatch funcIsWaitingLatch;
// Signals the function so it will complete
private CountDownLatch funcCompletionLatch;
@Override
protected ListenableFuture<String> buildChainingFuture(ListenableFuture<Integer> inputFuture) {
Reported by PMD.
Line: 43
// Signals that the function is waiting to complete
private CountDownLatch funcIsWaitingLatch;
// Signals the function so it will complete
private CountDownLatch funcCompletionLatch;
@Override
protected ListenableFuture<String> buildChainingFuture(ListenableFuture<Integer> inputFuture) {
outputFuture = SettableFuture.create();
funcIsWaitingLatch = new CountDownLatch(1);
Reported by PMD.
Line: 61
private class ChainingFunction implements AsyncFunction<Integer, String> {
@Override
public ListenableFuture<String> apply(Integer input) throws Exception {
switch (input) {
case VALID_INPUT_DATA:
outputFuture.set(RESULT_DATA);
break;
case SLOW_OUTPUT_VALID_INPUT_DATA:
break; // do nothing to the result
Reported by PMD.
Line: 78
}
}
public void testFutureGetThrowsFunctionException() throws Exception {
inputFuture.set(EXCEPTION_DATA);
listener.assertException(EXCEPTION);
}
public void testFutureGetThrowsCancellationIfInputCancelled() throws Exception {
Reported by PMD.
Line: 83
listener.assertException(EXCEPTION);
}
public void testFutureGetThrowsCancellationIfInputCancelled() throws Exception {
inputFuture.cancel(true); // argument is ignored
try {
resultFuture.get();
fail("Result future must throw CancellationException" + " if input future is cancelled.");
} catch (CancellationException expected) {
Reported by PMD.
Line: 92
}
}
public void testFutureGetThrowsCancellationIfOutputCancelled() throws Exception {
inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA);
outputFuture.cancel(true); // argument is ignored
try {
resultFuture.get();
fail(
Reported by PMD.
Line: 104
}
}
public void testAsyncToString() throws Exception {
inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA);
assertThat(resultFuture.toString()).contains(outputFuture.toString());
}
public void testFutureCancelBeforeInputCompletion() throws Exception {
Reported by PMD.
Line: 106
public void testAsyncToString() throws Exception {
inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA);
assertThat(resultFuture.toString()).contains(outputFuture.toString());
}
public void testFutureCancelBeforeInputCompletion() throws Exception {
assertTrue(resultFuture.cancel(true));
assertTrue(resultFuture.isCancelled());
Reported by PMD.
android/guava/src/com/google/common/hash/BloomFilter.java
21 issues
Line: 350
@VisibleForTesting
static <T extends @Nullable Object> BloomFilter<T> create(
Funnel<? super T> funnel, long expectedInsertions, double fpp, Strategy strategy) {
checkNotNull(funnel);
checkArgument(
expectedInsertions >= 0, "Expected insertions (%s) must be >= 0", expectedInsertions);
checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
Reported by PMD.
Line: 462
* @param p false positive rate (must be 0 < p < 1)
*/
@VisibleForTesting
static long optimalNumOfBits(long n, double p) {
if (p == 0) {
p = Double.MIN_VALUE;
}
return (long) (-n * Math.log(p) / (Math.log(2) * Math.log(2)));
}
Reported by PMD.
Line: 68
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class BloomFilter<T extends @Nullable Object> implements Predicate<T>, Serializable {
/**
* A strategy to translate T instances, to {@code numHashFunctions} bit indexes.
*
* <p>Implementations should be collections of pure functions (i.e. stateless).
*/
Reported by PMD.
Line: 68
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class BloomFilter<T extends @Nullable Object> implements Predicate<T>, Serializable {
/**
* A strategy to translate T instances, to {@code numHashFunctions} bit indexes.
*
* <p>Implementations should be collections of pure functions (i.e. stateless).
*/
Reported by PMD.
Line: 108
}
/** The bit set of the BloomFilter (not necessarily power of 2!) */
private final LockFreeBitArray bits;
/** Number of hashes per element */
private final int numHashFunctions;
/** The funnel to translate Ts to bytes */
Reported by PMD.
Line: 111
private final LockFreeBitArray bits;
/** Number of hashes per element */
private final int numHashFunctions;
/** The funnel to translate Ts to bytes */
private final Funnel<? super T> funnel;
/** The strategy we employ to map an element T to {@code numHashFunctions} bit indexes. */
Reported by PMD.
Line: 114
private final int numHashFunctions;
/** The funnel to translate Ts to bytes */
private final Funnel<? super T> funnel;
/** The strategy we employ to map an element T to {@code numHashFunctions} bit indexes. */
private final Strategy strategy;
/** Creates a BloomFilter. */
Reported by PMD.
Line: 117
private final Funnel<? super T> funnel;
/** The strategy we employ to map an element T to {@code numHashFunctions} bit indexes. */
private final Strategy strategy;
/** Creates a BloomFilter. */
private BloomFilter(
LockFreeBitArray bits, int numHashFunctions, Funnel<? super T> funnel, Strategy strategy) {
checkArgument(numHashFunctions > 0, "numHashFunctions (%s) must be > 0", numHashFunctions);
Reported by PMD.
Line: 235
*/
public boolean isCompatible(BloomFilter<T> that) {
checkNotNull(that);
return this != that
&& this.numHashFunctions == that.numHashFunctions
&& this.bitSize() == that.bitSize()
&& this.strategy.equals(that.strategy)
&& this.funnel.equals(that.funnel);
}
Reported by PMD.
Line: 253
*/
public void putAll(BloomFilter<T> that) {
checkNotNull(that);
checkArgument(this != that, "Cannot combine a BloomFilter with itself.");
checkArgument(
this.numHashFunctions == that.numHashFunctions,
"BloomFilters must have the same number of hash functions (%s != %s)",
this.numHashFunctions,
that.numHashFunctions);
Reported by PMD.
android/guava/src/com/google/common/primitives/ImmutableLongArray.java
21 issues
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);
/** Returns the empty array. */
public static ImmutableLongArray of() {
return EMPTY;
Reported by PMD.
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);
/** Returns the empty array. */
public static ImmutableLongArray of() {
return EMPTY;
Reported by PMD.
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);
/** Returns the empty array. */
public static ImmutableLongArray of() {
return EMPTY;
Reported by PMD.
Line: 163
if (values instanceof Collection) {
return copyOf((Collection<Long>) values);
}
return builder().addAll(values).build();
}
/**
* Returns a new, empty builder for {@link ImmutableLongArray} instances, sized to hold up to
* {@code initialCapacity} values without resizing. The returned builder is not thread-safe.
Reported by PMD.
Line: 163
if (values instanceof Collection) {
return copyOf((Collection<Long>) values);
}
return builder().addAll(values).build();
}
/**
* Returns a new, empty builder for {@link ImmutableLongArray} instances, sized to hold up to
* {@code initialCapacity} values without resizing. The returned builder is not thread-safe.
Reported by PMD.
Line: 199
*/
@CanIgnoreReturnValue
public static final class Builder {
private long[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new long[initialCapacity];
}
Reported by PMD.
Line: 200
@CanIgnoreReturnValue
public static final class Builder {
private long[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new long[initialCapacity];
}
Reported by PMD.
Line: 200
@CanIgnoreReturnValue
public static final class Builder {
private long[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new long[initialCapacity];
}
Reported by PMD.
Line: 307
// The array is never mutated after storing in this field and the construction strategies ensure
// it doesn't escape this class
@SuppressWarnings("Immutable")
private final long[] array;
/*
* TODO(kevinb): evaluate the trade-offs of going bimorphic to save these two fields from most
* instances. Note that the instances that would get smaller are the right set to care about
* optimizing, because the rest have the option of calling `trimmed`.
Reported by PMD.
Line: 316
*/
private final transient int start; // it happens that we only serialize instances where this is 0
private final int end; // exclusive
private ImmutableLongArray(long[] array) {
this(array, 0, array.length);
}
Reported by PMD.
android/guava/src/com/google/common/primitives/ImmutableIntArray.java
21 issues
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);
/** Returns the empty array. */
public static ImmutableIntArray of() {
return EMPTY;
Reported by PMD.
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);
/** Returns the empty array. */
public static ImmutableIntArray of() {
return EMPTY;
Reported by PMD.
Line: 84
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);
/** Returns the empty array. */
public static ImmutableIntArray of() {
return EMPTY;
Reported by PMD.
Line: 161
if (values instanceof Collection) {
return copyOf((Collection<Integer>) values);
}
return builder().addAll(values).build();
}
/**
* Returns a new, empty builder for {@link ImmutableIntArray} instances, sized to hold up to
* {@code initialCapacity} values without resizing. The returned builder is not thread-safe.
Reported by PMD.
Line: 161
if (values instanceof Collection) {
return copyOf((Collection<Integer>) values);
}
return builder().addAll(values).build();
}
/**
* Returns a new, empty builder for {@link ImmutableIntArray} instances, sized to hold up to
* {@code initialCapacity} values without resizing. The returned builder is not thread-safe.
Reported by PMD.
Line: 197
*/
@CanIgnoreReturnValue
public static final class Builder {
private int[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new int[initialCapacity];
}
Reported by PMD.
Line: 198
@CanIgnoreReturnValue
public static final class Builder {
private int[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new int[initialCapacity];
}
Reported by PMD.
Line: 198
@CanIgnoreReturnValue
public static final class Builder {
private int[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new int[initialCapacity];
}
Reported by PMD.
Line: 305
// The array is never mutated after storing in this field and the construction strategies ensure
// it doesn't escape this class
@SuppressWarnings("Immutable")
private final int[] array;
/*
* TODO(kevinb): evaluate the trade-offs of going bimorphic to save these two fields from most
* instances. Note that the instances that would get smaller are the right set to care about
* optimizing, because the rest have the option of calling `trimmed`.
Reported by PMD.
Line: 314
*/
private final transient int start; // it happens that we only serialize instances where this is 0
private final int end; // exclusive
private ImmutableIntArray(int[] array) {
this(array, 0, array.length);
}
Reported by PMD.
android/guava/src/com/google/common/collect/ForwardingMap.java
21 issues
Line: 61
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingMap<K extends @Nullable Object, V extends @Nullable Object>
extends ForwardingObject implements Map<K, V> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
protected ForwardingMap() {}
Reported by PMD.
Line: 72
@Override
public int size() {
return delegate().size();
}
@Override
public boolean isEmpty() {
return delegate().isEmpty();
Reported by PMD.
Line: 77
@Override
public boolean isEmpty() {
return delegate().isEmpty();
}
@CanIgnoreReturnValue
@Override
@CheckForNull
Reported by PMD.
Line: 84
@Override
@CheckForNull
public V remove(@CheckForNull Object key) {
return delegate().remove(key);
}
@Override
public void clear() {
delegate().clear();
Reported by PMD.
Line: 89
@Override
public void clear() {
delegate().clear();
}
@Override
public boolean containsKey(@CheckForNull Object key) {
return delegate().containsKey(key);
Reported by PMD.
Line: 94
@Override
public boolean containsKey(@CheckForNull Object key) {
return delegate().containsKey(key);
}
@Override
public boolean containsValue(@CheckForNull Object value) {
return delegate().containsValue(value);
Reported by PMD.
Line: 99
@Override
public boolean containsValue(@CheckForNull Object value) {
return delegate().containsValue(value);
}
@Override
@CheckForNull
public V get(@CheckForNull Object key) {
Reported by PMD.
Line: 105
@Override
@CheckForNull
public V get(@CheckForNull Object key) {
return delegate().get(key);
}
@CanIgnoreReturnValue
@Override
@CheckForNull
Reported by PMD.
Line: 112
@Override
@CheckForNull
public V put(@ParametricNullness K key, @ParametricNullness V value) {
return delegate().put(key, value);
}
@Override
public void putAll(Map<? extends K, ? extends V> map) {
delegate().putAll(map);
Reported by PMD.
Line: 117
@Override
public void putAll(Map<? extends K, ? extends V> map) {
delegate().putAll(map);
}
@Override
public Set<K> keySet() {
return delegate().keySet();
Reported by PMD.
android/guava/src/com/google/common/collect/ForwardingMultimap.java
21 issues
Line: 43
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends ForwardingObject implements Multimap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingMultimap() {}
@Override
Reported by PMD.
Line: 53
@Override
public Map<K, Collection<V>> asMap() {
return delegate().asMap();
}
@Override
public void clear() {
delegate().clear();
Reported by PMD.
Line: 58
@Override
public void clear() {
delegate().clear();
}
@Override
public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
return delegate().containsEntry(key, value);
Reported by PMD.
Line: 63
@Override
public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
return delegate().containsEntry(key, value);
}
@Override
public boolean containsKey(@CheckForNull Object key) {
return delegate().containsKey(key);
Reported by PMD.
Line: 68
@Override
public boolean containsKey(@CheckForNull Object key) {
return delegate().containsKey(key);
}
@Override
public boolean containsValue(@CheckForNull Object value) {
return delegate().containsValue(value);
Reported by PMD.
Line: 73
@Override
public boolean containsValue(@CheckForNull Object value) {
return delegate().containsValue(value);
}
@Override
public Collection<Entry<K, V>> entries() {
return delegate().entries();
Reported by PMD.
Line: 78
@Override
public Collection<Entry<K, V>> entries() {
return delegate().entries();
}
@Override
public Collection<V> get(@ParametricNullness K key) {
return delegate().get(key);
Reported by PMD.
Line: 83
@Override
public Collection<V> get(@ParametricNullness K key) {
return delegate().get(key);
}
@Override
public boolean isEmpty() {
return delegate().isEmpty();
Reported by PMD.
Line: 88
@Override
public boolean isEmpty() {
return delegate().isEmpty();
}
@Override
public Multiset<K> keys() {
return delegate().keys();
Reported by PMD.
Line: 93
@Override
public Multiset<K> keys() {
return delegate().keys();
}
@Override
public Set<K> keySet() {
return delegate().keySet();
Reported by PMD.
android/guava-tests/test/com/google/common/io/CharSinkTest.java
21 issues
Line: 39
private static final String STRING = ASCII + I18N;
private TestCharSink sink;
@Override
public void setUp() {
sink = new TestCharSink();
}
Reported by PMD.
Line: 41
private TestCharSink sink;
@Override
public void setUp() {
sink = new TestCharSink();
}
public void testOpenBufferedStream() throws IOException {
Reported by PMD.
Line: 46
sink = new TestCharSink();
}
public void testOpenBufferedStream() throws IOException {
Writer writer = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
writer.write(STRING);
Reported by PMD.
Line: 46
sink = new TestCharSink();
}
public void testOpenBufferedStream() throws IOException {
Writer writer = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
writer.write(STRING);
Reported by PMD.
Line: 47
}
public void testOpenBufferedStream() throws IOException {
Writer writer = sink.openBufferedStream();
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
writer.write(STRING);
writer.close();
Reported by PMD.
Line: 51
assertTrue(sink.wasStreamOpened());
assertFalse(sink.wasStreamClosed());
writer.write(STRING);
writer.close();
assertTrue(sink.wasStreamClosed());
assertEquals(STRING, sink.getString());
}
Reported by PMD.
Line: 52
assertFalse(sink.wasStreamClosed());
writer.write(STRING);
writer.close();
assertTrue(sink.wasStreamClosed());
assertEquals(STRING, sink.getString());
}
Reported by PMD.
Line: 58
assertEquals(STRING, sink.getString());
}
public void testWrite_string() throws IOException {
assertEquals("", sink.getString());
sink.write(STRING);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertEquals(STRING, sink.getString());
Reported by PMD.
Line: 58
assertEquals(STRING, sink.getString());
}
public void testWrite_string() throws IOException {
assertEquals("", sink.getString());
sink.write(STRING);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertEquals(STRING, sink.getString());
Reported by PMD.
Line: 66
assertEquals(STRING, sink.getString());
}
public void testWriteFrom_reader() throws IOException {
StringReader reader = new StringReader(STRING);
sink.writeFrom(reader);
assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed());
assertEquals(STRING, sink.getString());
Reported by PMD.
android/guava-tests/test/com/google/common/hash/Murmur3Hash128Test.java
21 issues
Line: 29
/** Tests for {@link Murmur3_128HashFunction}. */
public class Murmur3Hash128Test extends TestCase {
public void testKnownValues() {
assertHash(0, 0x629942693e10f867L, 0x92db0b82baeb5347L, "hell");
assertHash(1, 0xa78ddff5adae8d10L, 0x128900ef20900135L, "hello");
assertHash(2, 0x8a486b23f422e826L, 0xf962a2c58947765fL, "hello ");
assertHash(3, 0x2ea59f466f6bed8cL, 0xc610990acc428a17L, "hello w");
assertHash(4, 0x79f6305a386c572cL, 0x46305aed3483b94eL, "hello wo");
Reported by PMD.
Line: 29
/** Tests for {@link Murmur3_128HashFunction}. */
public class Murmur3Hash128Test extends TestCase {
public void testKnownValues() {
assertHash(0, 0x629942693e10f867L, 0x92db0b82baeb5347L, "hell");
assertHash(1, 0xa78ddff5adae8d10L, 0x128900ef20900135L, "hello");
assertHash(2, 0x8a486b23f422e826L, 0xf962a2c58947765fL, "hello ");
assertHash(3, 0x2ea59f466f6bed8cL, 0xc610990acc428a17L, "hello w");
assertHash(4, 0x79f6305a386c572cL, 0x46305aed3483b94eL, "hello wo");
Reported by PMD.
Line: 43
// Known output from Python smhasher
HashCode foxHash =
murmur3_128(0).hashString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8);
assertEquals("6c1b07bc7bbc4be347939ac4a93c437a", foxHash.toString());
}
private static void assertHash(int seed, long expected1, long expected2, String stringInput) {
HashCode expected = toHashCode(expected1, expected2);
Reported by PMD.
Line: 44
// Known output from Python smhasher
HashCode foxHash =
murmur3_128(0).hashString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8);
assertEquals("6c1b07bc7bbc4be347939ac4a93c437a", foxHash.toString());
}
private static void assertHash(int seed, long expected1, long expected2, String stringInput) {
HashCode expected = toHashCode(expected1, expected2);
byte[] input = HashTestUtils.ascii(stringInput);
Reported by PMD.
Line: 44
// Known output from Python smhasher
HashCode foxHash =
murmur3_128(0).hashString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8);
assertEquals("6c1b07bc7bbc4be347939ac4a93c437a", foxHash.toString());
}
private static void assertHash(int seed, long expected1, long expected2, String stringInput) {
HashCode expected = toHashCode(expected1, expected2);
byte[] input = HashTestUtils.ascii(stringInput);
Reported by PMD.
Line: 50
private static void assertHash(int seed, long expected1, long expected2, String stringInput) {
HashCode expected = toHashCode(expected1, expected2);
byte[] input = HashTestUtils.ascii(stringInput);
assertEquals(expected, murmur3_128(seed).hashBytes(input));
assertEquals(expected, murmur3_128(seed).newHasher().putBytes(input).hash());
}
/** Returns a {@link HashCode} for a sequence of longs, in big-endian order. */
private static HashCode toHashCode(long... longs) {
Reported by PMD.
Line: 50
private static void assertHash(int seed, long expected1, long expected2, String stringInput) {
HashCode expected = toHashCode(expected1, expected2);
byte[] input = HashTestUtils.ascii(stringInput);
assertEquals(expected, murmur3_128(seed).hashBytes(input));
assertEquals(expected, murmur3_128(seed).newHasher().putBytes(input).hash());
}
/** Returns a {@link HashCode} for a sequence of longs, in big-endian order. */
private static HashCode toHashCode(long... longs) {
Reported by PMD.
Line: 51
HashCode expected = toHashCode(expected1, expected2);
byte[] input = HashTestUtils.ascii(stringInput);
assertEquals(expected, murmur3_128(seed).hashBytes(input));
assertEquals(expected, murmur3_128(seed).newHasher().putBytes(input).hash());
}
/** Returns a {@link HashCode} for a sequence of longs, in big-endian order. */
private static HashCode toHashCode(long... longs) {
ByteBuffer bb = ByteBuffer.wrap(new byte[longs.length * 8]).order(ByteOrder.LITTLE_ENDIAN);
Reported by PMD.
Line: 51
HashCode expected = toHashCode(expected1, expected2);
byte[] input = HashTestUtils.ascii(stringInput);
assertEquals(expected, murmur3_128(seed).hashBytes(input));
assertEquals(expected, murmur3_128(seed).newHasher().putBytes(input).hash());
}
/** Returns a {@link HashCode} for a sequence of longs, in big-endian order. */
private static HashCode toHashCode(long... longs) {
ByteBuffer bb = ByteBuffer.wrap(new byte[longs.length * 8]).order(ByteOrder.LITTLE_ENDIAN);
Reported by PMD.
Line: 51
HashCode expected = toHashCode(expected1, expected2);
byte[] input = HashTestUtils.ascii(stringInput);
assertEquals(expected, murmur3_128(seed).hashBytes(input));
assertEquals(expected, murmur3_128(seed).newHasher().putBytes(input).hash());
}
/** Returns a {@link HashCode} for a sequence of longs, in big-endian order. */
private static HashCode toHashCode(long... longs) {
ByteBuffer bb = ByteBuffer.wrap(new byte[longs.length * 8]).order(ByteOrder.LITTLE_ENDIAN);
Reported by PMD.
android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java
21 issues
Line: 42
*/
@GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array
public class CompactHashSetTest extends TestCase {
public static Test suite() {
List<Feature<?>> allFeatures =
Arrays.<Feature<?>>asList(
CollectionSize.ANY,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
Reported by PMD.
Line: 79
for (int i = 0; i < 100; i++) {
set.remove(i);
}
set.trimToSize();
return set;
}
})
.named("CompactHashSet#TrimToSize")
.withFeatures(allFeatures)
Reported by PMD.
Line: 89
return suite;
}
public void testAllocArraysDefault() {
CompactHashSet<Integer> set = CompactHashSet.create();
assertThat(set.needsAllocArrays()).isTrue();
assertThat(set.elements).isNull();
set.add(1);
Reported by PMD.
Line: 89
return suite;
}
public void testAllocArraysDefault() {
CompactHashSet<Integer> set = CompactHashSet.create();
assertThat(set.needsAllocArrays()).isTrue();
assertThat(set.elements).isNull();
set.add(1);
Reported by PMD.
Line: 91
public void testAllocArraysDefault() {
CompactHashSet<Integer> set = CompactHashSet.create();
assertThat(set.needsAllocArrays()).isTrue();
assertThat(set.elements).isNull();
set.add(1);
assertThat(set.needsAllocArrays()).isFalse();
assertThat(set.elements).hasLength(CompactHashing.DEFAULT_SIZE);
Reported by PMD.
Line: 91
public void testAllocArraysDefault() {
CompactHashSet<Integer> set = CompactHashSet.create();
assertThat(set.needsAllocArrays()).isTrue();
assertThat(set.elements).isNull();
set.add(1);
assertThat(set.needsAllocArrays()).isFalse();
assertThat(set.elements).hasLength(CompactHashing.DEFAULT_SIZE);
Reported by PMD.
Line: 92
public void testAllocArraysDefault() {
CompactHashSet<Integer> set = CompactHashSet.create();
assertThat(set.needsAllocArrays()).isTrue();
assertThat(set.elements).isNull();
set.add(1);
assertThat(set.needsAllocArrays()).isFalse();
assertThat(set.elements).hasLength(CompactHashing.DEFAULT_SIZE);
}
Reported by PMD.
Line: 94
assertThat(set.needsAllocArrays()).isTrue();
assertThat(set.elements).isNull();
set.add(1);
assertThat(set.needsAllocArrays()).isFalse();
assertThat(set.elements).hasLength(CompactHashing.DEFAULT_SIZE);
}
public void testAllocArraysExpectedSize() {
Reported by PMD.
Line: 95
assertThat(set.elements).isNull();
set.add(1);
assertThat(set.needsAllocArrays()).isFalse();
assertThat(set.elements).hasLength(CompactHashing.DEFAULT_SIZE);
}
public void testAllocArraysExpectedSize() {
for (int i = 0; i <= CompactHashing.DEFAULT_SIZE; i++) {
Reported by PMD.
Line: 95
assertThat(set.elements).isNull();
set.add(1);
assertThat(set.needsAllocArrays()).isFalse();
assertThat(set.elements).hasLength(CompactHashing.DEFAULT_SIZE);
}
public void testAllocArraysExpectedSize() {
for (int i = 0; i <= CompactHashing.DEFAULT_SIZE; i++) {
Reported by PMD.