The following issues were found
guava/src/com/google/common/hash/HashCode.java
11 issues
Line: 85
* @throws IndexOutOfBoundsException if there is not enough room in {@code dest}
*/
@CanIgnoreReturnValue
public int writeBytesTo(byte[] dest, int offset, int maxLength) {
maxLength = Ints.min(maxLength, bits() / 8);
Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length);
writeBytesToImpl(dest, offset, maxLength);
return maxLength;
}
Reported by PMD.
Line: 36
* @since 11.0
*/
@ElementTypesAreNonnullByDefault
public abstract class HashCode {
HashCode() {}
/** Returns the number of bits in this hash code; a positive multiple of 8. */
public abstract int bits();
Reported by PMD.
Line: 120
}
private static final class IntHashCode extends HashCode implements Serializable {
final int hash;
IntHashCode(int hash) {
this.hash = hash;
}
Reported by PMD.
Line: 177
}
private static final class LongHashCode extends HashCode implements Serializable {
final long hash;
LongHashCode(long hash) {
this.hash = hash;
}
Reported by PMD.
Line: 252
}
private static final class BytesHashCode extends HashCode implements Serializable {
final byte[] bytes;
BytesHashCode(byte[] bytes) {
this.bytes = checkNotNull(bytes);
}
Reported by PMD.
Line: 305
@Override
byte[] getBytesInternal() {
return bytes;
}
@Override
boolean equalsSameBits(HashCode that) {
// We don't use MessageDigest.isEqual() here because its contract does not guarantee
Reported by PMD.
Line: 312
boolean equalsSameBits(HashCode that) {
// We don't use MessageDigest.isEqual() here because its contract does not guarantee
// constant-time evaluation (no short-circuiting).
if (this.bytes.length != that.getBytesInternal().length) {
return false;
}
boolean areEqual = true;
for (int i = 0; i < this.bytes.length; i++) {
Reported by PMD.
Line: 374
public final boolean equals(@CheckForNull Object object) {
if (object instanceof HashCode) {
HashCode that = (HashCode) object;
return bits() == that.bits() && equalsSameBits(that);
}
return false;
}
/**
Reported by PMD.
Line: 388
public final int hashCode() {
// If we have at least 4 bytes (32 bits), just take the first 4 bytes. Since this is
// already a (presumably) high-quality hash code, any four bytes of it will do.
if (bits() >= 32) {
return asInt();
}
// If we have less than 4 bytes, use them all.
byte[] bytes = getBytesInternal();
int val = (bytes[0] & 0xFF);
Reported by PMD.
Line: 344
"input string (%s) must have an even number of characters",
string);
byte[] bytes = new byte[string.length() / 2];
for (int i = 0; i < string.length(); i += 2) {
int ch1 = decode(string.charAt(i)) << 4;
int ch2 = decode(string.charAt(i + 1));
bytes[i / 2] = (byte) (ch1 + ch2);
}
Reported by PMD.
guava/src/com/google/common/hash/MacHashFunction.java
11 issues
Line: 37
final class MacHashFunction extends AbstractHashFunction {
@SuppressWarnings("Immutable") // cloned before each use
private final Mac prototype;
@SuppressWarnings("Immutable") // keys are immutable, but not provably so
private final Key key;
private final String toString;
Reported by PMD.
Line: 40
private final Mac prototype;
@SuppressWarnings("Immutable") // keys are immutable, but not provably so
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
Reported by PMD.
Line: 42
@SuppressWarnings("Immutable") // keys are immutable, but not provably so
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
Reported by PMD.
Line: 42
@SuppressWarnings("Immutable") // keys are immutable, but not provably so
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
Reported by PMD.
Line: 43
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
this.key = checkNotNull(key);
Reported by PMD.
Line: 43
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
this.key = checkNotNull(key);
Reported by PMD.
Line: 44
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
this.key = checkNotNull(key);
this.toString = checkNotNull(toString);
Reported by PMD.
Line: 44
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
this.key = checkNotNull(key);
this.toString = checkNotNull(toString);
Reported by PMD.
Line: 71
private static Mac getMac(String algorithmName, Key key) {
try {
Mac mac = Mac.getInstance(algorithmName);
mac.init(key);
return mac;
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e);
Reported by PMD.
Line: 99
/** Hasher that updates a {@link Mac} (message authentication code). */
private static final class MacHasher extends AbstractByteHasher {
private final Mac mac;
private boolean done;
private MacHasher(Mac mac) {
this.mac = mac;
}
Reported by PMD.
guava/src/com/google/common/primitives/Bytes.java
11 issues
Line: 126
continue outer;
}
}
return i;
}
return -1;
}
/**
Reported by PMD.
Line: 48
// javadoc?
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Bytes {
private Bytes() {}
/**
* Returns a hash code for {@code value}; equal to the result of invoking {@code ((Byte)
* value).hashCode()}.
Reported by PMD.
Line: 243
@GwtCompatible
private static class ByteArrayAsList extends AbstractList<Byte>
implements RandomAccess, Serializable {
final byte[] array;
final int start;
final int end;
ByteArrayAsList(byte[] array) {
this(array, 0, array.length);
Reported by PMD.
Line: 244
private static class ByteArrayAsList extends AbstractList<Byte>
implements RandomAccess, Serializable {
final byte[] array;
final int start;
final int end;
ByteArrayAsList(byte[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 245
implements RandomAccess, Serializable {
final byte[] array;
final int start;
final int end;
ByteArrayAsList(byte[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 251
this(array, 0, array.length);
}
ByteArrayAsList(byte[] array, int start, int end) {
this.array = array;
this.start = start;
this.end = end;
}
Reported by PMD.
Line: 330
if (object instanceof ByteArrayAsList) {
ByteArrayAsList that = (ByteArrayAsList) object;
int size = size();
if (that.size() != size) {
return false;
}
for (int i = 0; i < size; i++) {
if (array[start + i] != that.array[that.start + i]) {
return false;
Reported by PMD.
Line: 393
public static void reverse(byte[] array, int fromIndex, int toIndex) {
checkNotNull(array);
checkPositionIndexes(fromIndex, toIndex, array.length);
for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
byte tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
Reported by PMD.
Line: 166
length += array.length;
}
byte[] result = new byte[length];
int pos = 0;
for (byte[] array : arrays) {
System.arraycopy(array, 0, result, pos, array.length);
pos += array.length;
}
return result;
Reported by PMD.
Line: 213
Object[] boxedArray = collection.toArray();
int len = boxedArray.length;
byte[] array = new byte[len];
for (int i = 0; i < len; i++) {
// checkNotNull for GWT (do not optimize)
array[i] = ((Number) checkNotNull(boxedArray[i])).byteValue();
}
return array;
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
11 issues
Line: 35
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractIdleService implements Service {
/* Thread names will look like {@code "MyService STARTING"}. */
private final Supplier<String> threadNameSupplier = new ThreadNameSupplier();
@WeakOuter
Reported by PMD.
Line: 38
public abstract class AbstractIdleService implements Service {
/* Thread names will look like {@code "MyService STARTING"}. */
private final Supplier<String> threadNameSupplier = new ThreadNameSupplier();
@WeakOuter
private final class ThreadNameSupplier implements Supplier<String> {
@Override
public String get() {
Reported by PMD.
Line: 49
}
/* use AbstractService for state management */
private final Service delegate = new DelegateService();
@WeakOuter
private final class DelegateService extends AbstractService {
@Override
protected final void doStart() {
Reported by PMD.
Line: 63
try {
startUp();
notifyStarted();
} catch (Throwable t) {
notifyFailed(t);
}
}
});
}
Reported by PMD.
Line: 80
try {
shutDown();
notifyStopped();
} catch (Throwable t) {
notifyFailed(t);
}
}
});
}
Reported by PMD.
Line: 89
@Override
public String toString() {
return AbstractIdleService.this.toString();
}
}
/** Constructor for use by subclasses. */
protected AbstractIdleService() {}
Reported by PMD.
Line: 89
@Override
public String toString() {
return AbstractIdleService.this.toString();
}
}
/** Constructor for use by subclasses. */
protected AbstractIdleService() {}
Reported by PMD.
Line: 97
protected AbstractIdleService() {}
/** Start the service. */
protected abstract void startUp() throws Exception;
/** Stop the service. */
protected abstract void shutDown() throws Exception;
/**
Reported by PMD.
Line: 100
protected abstract void startUp() throws Exception;
/** Stop the service. */
protected abstract void shutDown() throws Exception;
/**
* Returns the {@link Executor} that will be used to run this service. Subclasses may override
* this method to use a custom {@link Executor}, which may configure its worker thread with a
* specific name, thread group or priority. The returned executor's {@link
Reported by PMD.
Line: 113
return new Executor() {
@Override
public void execute(Runnable command) {
MoreExecutors.newThread(threadNameSupplier.get(), command).start();
}
};
}
@Override
Reported by PMD.
android/guava/src/com/google/common/hash/Crc32cHashFunction.java
11 issues
Line: 364
^ STRIDE_TABLE[0][word >>> 24];
}
static int combine(int csum, int crc) {
csum ^= crc;
for (int i = 0; i < 4; i++) {
csum = (csum >>> 8) ^ BYTE_TABLE[csum & 0xFF];
}
return csum;
Reported by PMD.
Line: 364
^ STRIDE_TABLE[0][word >>> 24];
}
static int combine(int csum, int crc) {
csum ^= crc;
for (int i = 0; i < 4; i++) {
csum = (csum >>> 8) ^ BYTE_TABLE[csum & 0xFF];
}
return csum;
Reported by PMD.
Line: 63
super(16);
}
private boolean finished = false;
/*
* This trick allows us to avoid having separate states for "first four ints" and "all other
* four int chunks." The state we want after the first four bytes is
*
Reported by PMD.
Line: 63
super(16);
}
private boolean finished = false;
/*
* This trick allows us to avoid having separate states for "first four ints" and "all other
* four int chunks." The state we want after the first four bytes is
*
Reported by PMD.
Line: 77
* ...so we set crc0 so that computeForWord(crc0) = -1 and xoring it with the first int
* gives us the desired result. computeForWord(0) == 0, so all the others do the right thing.
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
Reported by PMD.
Line: 78
* gives us the desired result. computeForWord(0) == 0, so all the others do the right thing.
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
Reported by PMD.
Line: 78
* gives us the desired result. computeForWord(0) == 0, so all the others do the right thing.
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
Reported by PMD.
Line: 79
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
if (finished) {
Reported by PMD.
Line: 79
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
if (finished) {
Reported by PMD.
Line: 80
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
if (finished) {
throw new IllegalStateException(
Reported by PMD.
android/guava/src/com/google/common/hash/HashCode.java
11 issues
Line: 85
* @throws IndexOutOfBoundsException if there is not enough room in {@code dest}
*/
@CanIgnoreReturnValue
public int writeBytesTo(byte[] dest, int offset, int maxLength) {
maxLength = Ints.min(maxLength, bits() / 8);
Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length);
writeBytesToImpl(dest, offset, maxLength);
return maxLength;
}
Reported by PMD.
Line: 36
* @since 11.0
*/
@ElementTypesAreNonnullByDefault
public abstract class HashCode {
HashCode() {}
/** Returns the number of bits in this hash code; a positive multiple of 8. */
public abstract int bits();
Reported by PMD.
Line: 120
}
private static final class IntHashCode extends HashCode implements Serializable {
final int hash;
IntHashCode(int hash) {
this.hash = hash;
}
Reported by PMD.
Line: 177
}
private static final class LongHashCode extends HashCode implements Serializable {
final long hash;
LongHashCode(long hash) {
this.hash = hash;
}
Reported by PMD.
Line: 252
}
private static final class BytesHashCode extends HashCode implements Serializable {
final byte[] bytes;
BytesHashCode(byte[] bytes) {
this.bytes = checkNotNull(bytes);
}
Reported by PMD.
Line: 305
@Override
byte[] getBytesInternal() {
return bytes;
}
@Override
boolean equalsSameBits(HashCode that) {
// We don't use MessageDigest.isEqual() here because its contract does not guarantee
Reported by PMD.
Line: 312
boolean equalsSameBits(HashCode that) {
// We don't use MessageDigest.isEqual() here because its contract does not guarantee
// constant-time evaluation (no short-circuiting).
if (this.bytes.length != that.getBytesInternal().length) {
return false;
}
boolean areEqual = true;
for (int i = 0; i < this.bytes.length; i++) {
Reported by PMD.
Line: 374
public final boolean equals(@CheckForNull Object object) {
if (object instanceof HashCode) {
HashCode that = (HashCode) object;
return bits() == that.bits() && equalsSameBits(that);
}
return false;
}
/**
Reported by PMD.
Line: 388
public final int hashCode() {
// If we have at least 4 bytes (32 bits), just take the first 4 bytes. Since this is
// already a (presumably) high-quality hash code, any four bytes of it will do.
if (bits() >= 32) {
return asInt();
}
// If we have less than 4 bytes, use them all.
byte[] bytes = getBytesInternal();
int val = (bytes[0] & 0xFF);
Reported by PMD.
Line: 344
"input string (%s) must have an even number of characters",
string);
byte[] bytes = new byte[string.length() / 2];
for (int i = 0; i < string.length(); i += 2) {
int ch1 = decode(string.charAt(i)) << 4;
int ch2 = decode(string.charAt(i + 1));
bytes[i / 2] = (byte) (ch1 + ch2);
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
11 issues
Line: 50
@Override
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(SortedMapNavigationTester.class);
return testers;
}
@Override
public TestSuite createTestSuite() {
Reported by PMD.
Line: 56
@Override
public TestSuite createTestSuite() {
if (!getFeatures().contains(KNOWN_ORDER)) {
List<Feature<?>> features = Helpers.copyToList(getFeatures());
features.add(KNOWN_ORDER);
withFeatures(features);
}
return super.createTestSuite();
Reported by PMD.
Line: 58
public TestSuite createTestSuite() {
if (!getFeatures().contains(KNOWN_ORDER)) {
List<Feature<?>> features = Helpers.copyToList(getFeatures());
features.add(KNOWN_ORDER);
withFeatures(features);
}
return super.createTestSuite();
}
Reported by PMD.
Line: 71
parentBuilder) {
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
}
Reported by PMD.
Line: 114
final Bound from,
final Bound to) {
final TestSortedMapGenerator<K, V> delegate =
(TestSortedMapGenerator<K, V>) parentBuilder.getSubjectGenerator().getInnerGenerator();
List<Feature<?>> features = new ArrayList<>();
features.add(NoRecurse.SUBMAP);
features.addAll(parentBuilder.getFeatures());
Reported by PMD.
Line: 120
features.add(NoRecurse.SUBMAP);
features.addAll(parentBuilder.getFeatures());
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subMap " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
Line: 120
features.add(NoRecurse.SUBMAP);
features.addAll(parentBuilder.getFeatures());
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subMap " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
Line: 120
features.add(NoRecurse.SUBMAP);
features.addAll(parentBuilder.getFeatures());
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subMap " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
Line: 120
features.add(NoRecurse.SUBMAP);
features.addAll(parentBuilder.getFeatures());
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subMap " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
Line: 120
features.add(NoRecurse.SUBMAP);
features.addAll(parentBuilder.getFeatures());
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subMap " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
11 issues
Line: 45
@Override
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(SortedSetNavigationTester.class);
return testers;
}
@Override
public TestSuite createTestSuite() {
Reported by PMD.
Line: 51
@Override
public TestSuite createTestSuite() {
if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
List<Feature<?>> features = Helpers.copyToList(getFeatures());
features.add(CollectionFeature.KNOWN_ORDER);
withFeatures(features);
}
return super.createTestSuite();
Reported by PMD.
Line: 53
public TestSuite createTestSuite() {
if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
List<Feature<?>> features = Helpers.copyToList(getFeatures());
features.add(CollectionFeature.KNOWN_ORDER);
withFeatures(features);
}
return super.createTestSuite();
}
Reported by PMD.
Line: 65
parentBuilder) {
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
}
Reported by PMD.
Line: 87
final Bound from,
final Bound to) {
final TestSortedSetGenerator<E> delegate =
(TestSortedSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();
List<Feature<?>> features = new ArrayList<>(parentBuilder.getFeatures());
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
features.add(CollectionFeature.SUBSET_VIEW);
Reported by PMD.
Line: 93
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
features.add(CollectionFeature.SUBSET_VIEW);
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subSet " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
Line: 93
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
features.add(CollectionFeature.SUBSET_VIEW);
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subSet " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
Line: 93
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
features.add(CollectionFeature.SUBSET_VIEW);
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subSet " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
Line: 93
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
features.add(CollectionFeature.SUBSET_VIEW);
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subSet " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
Line: 93
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
features.add(CollectionFeature.SUBSET_VIEW);
return newBuilderUsing(delegate, to, from)
.named(parentBuilder.getName() + " subSet " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
.withSetUp(parentBuilder.getSetUp())
.withTearDown(parentBuilder.getTearDown())
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/NavigableSetTestSuiteBuilder.java
11 issues
Line: 54
parentBuilder) {
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
if (!parentBuilder.getFeatures().contains(SUBSET_VIEW)) {
// Other combinations are inherited from SortedSetTestSuiteBuilder.
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
Reported by PMD.
Line: 62
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
}
if (!parentBuilder.getFeatures().contains(DESCENDING_VIEW)) {
derivedSuites.add(createDescendingSuite(parentBuilder));
}
return derivedSuites;
}
Reported by PMD.
Line: 76
}
@Override
NavigableSet<E> createSubSet(SortedSet<E> sortedSet, E firstExclusive, E lastExclusive) {
NavigableSet<E> set = (NavigableSet<E>) sortedSet;
if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) {
return set.headSet(lastInclusive, true);
} else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) {
return set.tailSet(firstExclusive, false);
Reported by PMD.
Line: 106
?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
parentBuilder) {
final TestSetGenerator<E> delegate =
(TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();
List<Feature<?>> features = new ArrayList<>();
features.add(DESCENDING_VIEW);
features.addAll(parentBuilder.getFeatures());
Reported by PMD.
Line: 138
@Override
public Set<E> create(Object... elements) {
NavigableSet<E> navigableSet = (NavigableSet<E>) delegate.create(elements);
return navigableSet.descendingSet();
}
})
.named(parentBuilder.getName() + " descending")
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
Reported by PMD.
Line: 150
@Override
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(NavigableSetNavigationTester.class);
return testers;
}
}
Reported by PMD.
Line: 105
final FeatureSpecificTestSuiteBuilder<
?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
parentBuilder) {
final TestSetGenerator<E> delegate =
(TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();
List<Feature<?>> features = new ArrayList<>();
features.add(DESCENDING_VIEW);
features.addAll(parentBuilder.getFeatures());
Reported by PMD.
Line: 105
final FeatureSpecificTestSuiteBuilder<
?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
parentBuilder) {
final TestSetGenerator<E> delegate =
(TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();
List<Feature<?>> features = new ArrayList<>();
features.add(DESCENDING_VIEW);
features.addAll(parentBuilder.getFeatures());
Reported by PMD.
Line: 105
final FeatureSpecificTestSuiteBuilder<
?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
parentBuilder) {
final TestSetGenerator<E> delegate =
(TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();
List<Feature<?>> features = new ArrayList<>();
features.add(DESCENDING_VIEW);
features.addAll(parentBuilder.getFeatures());
Reported by PMD.
Line: 105
final FeatureSpecificTestSuiteBuilder<
?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
parentBuilder) {
final TestSetGenerator<E> delegate =
(TestSetGenerator<E>) parentBuilder.getSubjectGenerator().getInnerGenerator();
List<Feature<?>> features = new ArrayList<>();
features.add(DESCENDING_VIEW);
features.addAll(parentBuilder.getFeatures());
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/NavigableMapTestSuiteBuilder.java
11 issues
Line: 153
}
@Override
public Iterable<Entry<K, V>> order(List<Entry<K, V>> insertionOrder) {
insertionOrder = castOrCopyToList(delegate.order(insertionOrder));
reverse(insertionOrder);
return insertionOrder;
}
Reported by PMD.
Line: 52
@Override
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(NavigableMapNavigationTester.class);
return testers;
}
@Override
protected List<TestSuite> createDerivedSuites(
Reported by PMD.
Line: 63
parentBuilder) {
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (!parentBuilder.getFeatures().contains(NoRecurse.DESCENDING)) {
derivedSuites.add(createDescendingSuite(parentBuilder));
}
if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
// Other combinations are inherited from SortedMapTestSuiteBuilder.
Reported by PMD.
Line: 67
derivedSuites.add(createDescendingSuite(parentBuilder));
}
if (!parentBuilder.getFeatures().contains(NoRecurse.SUBMAP)) {
// Other combinations are inherited from SortedMapTestSuiteBuilder.
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
Reported by PMD.
Line: 93
}
@Override
NavigableMap<K, V> createSubMap(SortedMap<K, V> sortedMap, K firstExclusive, K lastExclusive) {
NavigableMap<K, V> map = (NavigableMap<K, V>) sortedMap;
if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) {
return map.headMap(lastInclusive, true);
} else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) {
return map.tailMap(firstExclusive, false);
Reported by PMD.
Line: 123
?, ? extends OneSizeTestContainerGenerator<Map<K, V>, Entry<K, V>>>
parentBuilder) {
final TestSortedMapGenerator<K, V> delegate =
(TestSortedMapGenerator<K, V>) parentBuilder.getSubjectGenerator().getInnerGenerator();
List<Feature<?>> features = new ArrayList<>();
features.add(NoRecurse.DESCENDING);
features.addAll(parentBuilder.getFeatures());
Reported by PMD.
Line: 149
@Override
public NavigableMap<K, V> create(Object... entries) {
NavigableMap<K, V> map = (NavigableMap<K, V>) delegate.create(entries);
return map.descendingMap();
}
@Override
public Iterable<Entry<K, V>> order(List<Entry<K, V>> insertionOrder) {
insertionOrder = castOrCopyToList(delegate.order(insertionOrder));
Reported by PMD.
Line: 165
@Override
public Entry<K, V> belowSamplesLesser() {
return delegate().aboveSamplesGreater();
}
@Override
public Entry<K, V> belowSamplesGreater() {
return delegate().aboveSamplesLesser();
Reported by PMD.
Line: 170
@Override
public Entry<K, V> belowSamplesGreater() {
return delegate().aboveSamplesLesser();
}
@Override
public Entry<K, V> aboveSamplesLesser() {
return delegate().belowSamplesGreater();
Reported by PMD.
Line: 175
@Override
public Entry<K, V> aboveSamplesLesser() {
return delegate().belowSamplesGreater();
}
@Override
public Entry<K, V> aboveSamplesGreater() {
return delegate().belowSamplesLesser();
Reported by PMD.