The following issues were found
android/guava-tests/test/com/google/common/cache/CacheBuilderFactory.java
16 issues
Line: 37
*
* @author mike nonemacher
*/
class CacheBuilderFactory {
// Default values contain only 'null', which means don't call the CacheBuilder method (just give
// the CacheBuilder default).
private Set<Integer> concurrencyLevels = Sets.newHashSet((Integer) null);
private Set<Integer> initialCapacities = Sets.newHashSet((Integer) null);
private Set<Integer> maximumSizes = Sets.newHashSet((Integer) null);
Reported by PMD.
Line: 40
class CacheBuilderFactory {
// Default values contain only 'null', which means don't call the CacheBuilder method (just give
// the CacheBuilder default).
private Set<Integer> concurrencyLevels = Sets.newHashSet((Integer) null);
private Set<Integer> initialCapacities = Sets.newHashSet((Integer) null);
private Set<Integer> maximumSizes = Sets.newHashSet((Integer) null);
private Set<DurationSpec> expireAfterWrites = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> expireAfterAccesses = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> refreshes = Sets.newHashSet((DurationSpec) null);
Reported by PMD.
Line: 41
// Default values contain only 'null', which means don't call the CacheBuilder method (just give
// the CacheBuilder default).
private Set<Integer> concurrencyLevels = Sets.newHashSet((Integer) null);
private Set<Integer> initialCapacities = Sets.newHashSet((Integer) null);
private Set<Integer> maximumSizes = Sets.newHashSet((Integer) null);
private Set<DurationSpec> expireAfterWrites = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> expireAfterAccesses = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> refreshes = Sets.newHashSet((DurationSpec) null);
private Set<Strength> keyStrengths = Sets.newHashSet((Strength) null);
Reported by PMD.
Line: 42
// the CacheBuilder default).
private Set<Integer> concurrencyLevels = Sets.newHashSet((Integer) null);
private Set<Integer> initialCapacities = Sets.newHashSet((Integer) null);
private Set<Integer> maximumSizes = Sets.newHashSet((Integer) null);
private Set<DurationSpec> expireAfterWrites = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> expireAfterAccesses = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> refreshes = Sets.newHashSet((DurationSpec) null);
private Set<Strength> keyStrengths = Sets.newHashSet((Strength) null);
private Set<Strength> valueStrengths = Sets.newHashSet((Strength) null);
Reported by PMD.
Line: 43
private Set<Integer> concurrencyLevels = Sets.newHashSet((Integer) null);
private Set<Integer> initialCapacities = Sets.newHashSet((Integer) null);
private Set<Integer> maximumSizes = Sets.newHashSet((Integer) null);
private Set<DurationSpec> expireAfterWrites = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> expireAfterAccesses = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> refreshes = Sets.newHashSet((DurationSpec) null);
private Set<Strength> keyStrengths = Sets.newHashSet((Strength) null);
private Set<Strength> valueStrengths = Sets.newHashSet((Strength) null);
Reported by PMD.
Line: 44
private Set<Integer> initialCapacities = Sets.newHashSet((Integer) null);
private Set<Integer> maximumSizes = Sets.newHashSet((Integer) null);
private Set<DurationSpec> expireAfterWrites = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> expireAfterAccesses = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> refreshes = Sets.newHashSet((DurationSpec) null);
private Set<Strength> keyStrengths = Sets.newHashSet((Strength) null);
private Set<Strength> valueStrengths = Sets.newHashSet((Strength) null);
CacheBuilderFactory withConcurrencyLevels(Set<Integer> concurrencyLevels) {
Reported by PMD.
Line: 45
private Set<Integer> maximumSizes = Sets.newHashSet((Integer) null);
private Set<DurationSpec> expireAfterWrites = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> expireAfterAccesses = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> refreshes = Sets.newHashSet((DurationSpec) null);
private Set<Strength> keyStrengths = Sets.newHashSet((Strength) null);
private Set<Strength> valueStrengths = Sets.newHashSet((Strength) null);
CacheBuilderFactory withConcurrencyLevels(Set<Integer> concurrencyLevels) {
this.concurrencyLevels = Sets.newLinkedHashSet(concurrencyLevels);
Reported by PMD.
Line: 46
private Set<DurationSpec> expireAfterWrites = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> expireAfterAccesses = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> refreshes = Sets.newHashSet((DurationSpec) null);
private Set<Strength> keyStrengths = Sets.newHashSet((Strength) null);
private Set<Strength> valueStrengths = Sets.newHashSet((Strength) null);
CacheBuilderFactory withConcurrencyLevels(Set<Integer> concurrencyLevels) {
this.concurrencyLevels = Sets.newLinkedHashSet(concurrencyLevels);
return this;
Reported by PMD.
Line: 47
private Set<DurationSpec> expireAfterAccesses = Sets.newHashSet((DurationSpec) null);
private Set<DurationSpec> refreshes = Sets.newHashSet((DurationSpec) null);
private Set<Strength> keyStrengths = Sets.newHashSet((Strength) null);
private Set<Strength> valueStrengths = Sets.newHashSet((Strength) null);
CacheBuilderFactory withConcurrencyLevels(Set<Integer> concurrencyLevels) {
this.concurrencyLevels = Sets.newLinkedHashSet(concurrencyLevels);
return this;
}
Reported by PMD.
Line: 160
});
}
private CacheBuilder<Object, Object> createCacheBuilder(
Integer concurrencyLevel,
Integer initialCapacity,
Integer maximumSize,
DurationSpec expireAfterWrite,
DurationSpec expireAfterAccess,
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/AbstractBiMapTester.java
16 issues
Line: 50
for (Entry<K, V> entry : expected) {
reversedEntries.add(reverseEntry(entry));
}
Helpers.assertEqualIgnoringOrder(getMap().inverse().entrySet(), reversedEntries);
for (Entry<K, V> entry : expected) {
assertEquals(
"Wrong key for value " + entry.getValue(),
entry.getKey(),
Reported by PMD.
Line: 50
for (Entry<K, V> entry : expected) {
reversedEntries.add(reverseEntry(entry));
}
Helpers.assertEqualIgnoringOrder(getMap().inverse().entrySet(), reversedEntries);
for (Entry<K, V> entry : expected) {
assertEquals(
"Wrong key for value " + entry.getValue(),
entry.getKey(),
Reported by PMD.
Line: 56
assertEquals(
"Wrong key for value " + entry.getValue(),
entry.getKey(),
getMap().inverse().get(entry.getValue()));
}
}
@Override
protected void expectMissing(Entry<K, V>... entries) {
Reported by PMD.
Line: 56
assertEquals(
"Wrong key for value " + entry.getValue(),
entry.getKey(),
getMap().inverse().get(entry.getValue()));
}
}
@Override
protected void expectMissing(Entry<K, V>... entries) {
Reported by PMD.
Line: 65
super.expectMissing(entries);
for (Entry<K, V> entry : entries) {
Entry<V, K> reversed = reverseEntry(entry);
BiMap<V, K> inv = getMap().inverse();
assertFalse(
"Inverse should not contain entry " + reversed, inv.entrySet().contains(reversed));
assertFalse(
"Inverse should not contain key " + reversed.getKey(),
inv.containsKey(reversed.getKey()));
Reported by PMD.
Line: 67
Entry<V, K> reversed = reverseEntry(entry);
BiMap<V, K> inv = getMap().inverse();
assertFalse(
"Inverse should not contain entry " + reversed, inv.entrySet().contains(reversed));
assertFalse(
"Inverse should not contain key " + reversed.getKey(),
inv.containsKey(reversed.getKey()));
assertFalse(
"Inverse should not contain value " + reversed.getValue(),
Reported by PMD.
Line: 67
Entry<V, K> reversed = reverseEntry(entry);
BiMap<V, K> inv = getMap().inverse();
assertFalse(
"Inverse should not contain entry " + reversed, inv.entrySet().contains(reversed));
assertFalse(
"Inverse should not contain key " + reversed.getKey(),
inv.containsKey(reversed.getKey()));
assertFalse(
"Inverse should not contain value " + reversed.getValue(),
Reported by PMD.
Line: 69
assertFalse(
"Inverse should not contain entry " + reversed, inv.entrySet().contains(reversed));
assertFalse(
"Inverse should not contain key " + reversed.getKey(),
inv.containsKey(reversed.getKey()));
assertFalse(
"Inverse should not contain value " + reversed.getValue(),
inv.containsValue(reversed.getValue()));
/*
Reported by PMD.
Line: 70
"Inverse should not contain entry " + reversed, inv.entrySet().contains(reversed));
assertFalse(
"Inverse should not contain key " + reversed.getKey(),
inv.containsKey(reversed.getKey()));
assertFalse(
"Inverse should not contain value " + reversed.getValue(),
inv.containsValue(reversed.getValue()));
/*
* TODO(cpovirk): This is a bit stronger than super.expectMissing(), which permits a <key,
Reported by PMD.
Line: 70
"Inverse should not contain entry " + reversed, inv.entrySet().contains(reversed));
assertFalse(
"Inverse should not contain key " + reversed.getKey(),
inv.containsKey(reversed.getKey()));
assertFalse(
"Inverse should not contain value " + reversed.getValue(),
inv.containsValue(reversed.getValue()));
/*
* TODO(cpovirk): This is a bit stronger than super.expectMissing(), which permits a <key,
Reported by PMD.
android/guava-tests/test/com/google/common/escape/ArrayBasedCharEscaperTest.java
16 issues
Line: 35
'\t', "<tab>",
'&', "<and>");
public void testSafeRange() throws IOException {
// Basic escaping of unsafe chars (wrap them in {,}'s)
CharEscaper wrappingEscaper =
new ArrayBasedCharEscaper(NO_REPLACEMENTS, 'A', 'Z') {
@Override
protected char[] escapeUnsafe(char c) {
Reported by PMD.
Line: 46
};
EscaperAsserts.assertBasic(wrappingEscaper);
// '[' and '@' lie either side of [A-Z].
assertEquals("{[}FOO{@}BAR{]}", wrappingEscaper.escape("[FOO@BAR]"));
}
public void testSafeRange_maxLessThanMin() throws IOException {
// Basic escaping of unsafe chars (wrap them in {,}'s)
CharEscaper wrappingEscaper =
Reported by PMD.
Line: 49
assertEquals("{[}FOO{@}BAR{]}", wrappingEscaper.escape("[FOO@BAR]"));
}
public void testSafeRange_maxLessThanMin() throws IOException {
// Basic escaping of unsafe chars (wrap them in {,}'s)
CharEscaper wrappingEscaper =
new ArrayBasedCharEscaper(NO_REPLACEMENTS, 'Z', 'A') {
@Override
protected char[] escapeUnsafe(char c) {
Reported by PMD.
Line: 60
};
EscaperAsserts.assertBasic(wrappingEscaper);
// escape everything.
assertEquals("{[}{F}{O}{O}{]}", wrappingEscaper.escape("[FOO]"));
}
public void testDeleteUnsafeChars() throws IOException {
CharEscaper deletingEscaper =
new ArrayBasedCharEscaper(NO_REPLACEMENTS, ' ', '~') {
Reported by PMD.
Line: 63
assertEquals("{[}{F}{O}{O}{]}", wrappingEscaper.escape("[FOO]"));
}
public void testDeleteUnsafeChars() throws IOException {
CharEscaper deletingEscaper =
new ArrayBasedCharEscaper(NO_REPLACEMENTS, ' ', '~') {
private final char[] noChars = new char[0];
@Override
Reported by PMD.
Line: 74
}
};
EscaperAsserts.assertBasic(deletingEscaper);
assertEquals(
"Everything outside the printable ASCII range is deleted.",
deletingEscaper.escape(
"\tEverything\0 outside the\uD800\uDC00 "
+ "printable ASCII \uFFFFrange is \u007Fdeleted.\n"));
}
Reported by PMD.
Line: 81
+ "printable ASCII \uFFFFrange is \u007Fdeleted.\n"));
}
public void testReplacementPriority() throws IOException {
CharEscaper replacingEscaper =
new ArrayBasedCharEscaper(SIMPLE_REPLACEMENTS, ' ', '~') {
private final char[] unknown = new char[] {'?'};
@Override
Reported by PMD.
Line: 95
// Replacements are applied first regardless of whether the character is in
// the safe range or not ('&' is a safe char while '\t' and '\n' are not).
assertEquals(
"<tab>Fish <and>? Chips?<newline>", replacingEscaper.escape("\tFish &\0 Chips\r\n"));
}
}
Reported by PMD.
Line: 37
public void testSafeRange() throws IOException {
// Basic escaping of unsafe chars (wrap them in {,}'s)
CharEscaper wrappingEscaper =
new ArrayBasedCharEscaper(NO_REPLACEMENTS, 'A', 'Z') {
@Override
protected char[] escapeUnsafe(char c) {
return ("{" + c + "}").toCharArray();
}
Reported by PMD.
Line: 37
public void testSafeRange() throws IOException {
// Basic escaping of unsafe chars (wrap them in {,}'s)
CharEscaper wrappingEscaper =
new ArrayBasedCharEscaper(NO_REPLACEMENTS, 'A', 'Z') {
@Override
protected char[] escapeUnsafe(char c) {
return ("{" + c + "}").toCharArray();
}
Reported by PMD.
android/guava-tests/benchmark/com/google/common/util/concurrent/StripedBenchmark.java
16 issues
Line: 49
};
@Param({"2", "8", "64", "1024", "65536"})
int numStripes;
@Param Impl impl;
enum Impl {
EAGER {
Reported by PMD.
Line: 51
@Param({"2", "8", "64", "1024", "65536"})
int numStripes;
@Param Impl impl;
enum Impl {
EAGER {
@Override
Striped<Lock> get(int stripes) {
Reported by PMD.
Line: 76
abstract Striped<Lock> get(int stripes);
}
private Striped<Lock> striped;
private int[] stripes;
private List<Integer> bulkGetSet;
@BeforeExperiment
void setUp() {
Reported by PMD.
Line: 77
}
private Striped<Lock> striped;
private int[] stripes;
private List<Integer> bulkGetSet;
@BeforeExperiment
void setUp() {
this.striped = impl.get(numStripes);
Reported by PMD.
Line: 78
private Striped<Lock> striped;
private int[] stripes;
private List<Integer> bulkGetSet;
@BeforeExperiment
void setUp() {
this.striped = impl.get(numStripes);
stripes = new int[numStripes];
Reported by PMD.
Line: 80
private int[] stripes;
private List<Integer> bulkGetSet;
@BeforeExperiment
void setUp() {
this.striped = impl.get(numStripes);
stripes = new int[numStripes];
for (int i = 0; i < numStripes; i++) {
stripes[i] = i;
Reported by PMD.
Line: 100
}
// a place to put the locks in sizeOfPopulatedStriped so they don't get GC'd before we measure
final List<Lock> locks = new ArrayList<>(numStripes);
@Footprint
Object sizeOfPopulatedStriped() {
locks.clear();
Striped<Lock> striped = impl.get(numStripes);
Reported by PMD.
Line: 118
int numStripesLocal = numStripes;
Impl implLocal = impl;
for (long i = 0; i < reps; i++) {
rvalue += implLocal.get(numStripesLocal).hashCode();
}
return rvalue;
}
@Benchmark
Reported by PMD.
Line: 141
List<Integer> bulkGetSetLocal = bulkGetSet;
Striped<Lock> stripedLocal = striped;
for (long i = 0; i < reps; i++) {
rvalue += stripedLocal.bulkGet(bulkGetSetLocal).hashCode();
}
return rvalue;
}
}
Reported by PMD.
Line: 115
@Benchmark
long timeConstruct(long reps) {
long rvalue = 0;
int numStripesLocal = numStripes;
Impl implLocal = impl;
for (long i = 0; i < reps; i++) {
rvalue += implLocal.get(numStripesLocal).hashCode();
}
return rvalue;
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultisetCountTester.java
16 issues
Line: 44
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetCountTester<E> extends AbstractMultisetTester<E> {
public void testCount_0() {
assertEquals("multiset.count(missing) didn't return 0", 0, getMultiset().count(e3()));
}
@CollectionSize.Require(absent = ZERO)
public void testCount_1() {
Reported by PMD.
Line: 45
public class MultisetCountTester<E> extends AbstractMultisetTester<E> {
public void testCount_0() {
assertEquals("multiset.count(missing) didn't return 0", 0, getMultiset().count(e3()));
}
@CollectionSize.Require(absent = ZERO)
public void testCount_1() {
assertEquals("multiset.count(present) didn't return 1", 1, getMultiset().count(e0()));
Reported by PMD.
Line: 48
assertEquals("multiset.count(missing) didn't return 0", 0, getMultiset().count(e3()));
}
@CollectionSize.Require(absent = ZERO)
public void testCount_1() {
assertEquals("multiset.count(present) didn't return 1", 1, getMultiset().count(e0()));
}
@CollectionSize.Require(SEVERAL)
Reported by PMD.
Line: 50
@CollectionSize.Require(absent = ZERO)
public void testCount_1() {
assertEquals("multiset.count(present) didn't return 1", 1, getMultiset().count(e0()));
}
@CollectionSize.Require(SEVERAL)
public void testCount_3() {
initThreeCopies();
Reported by PMD.
Line: 53
assertEquals("multiset.count(present) didn't return 1", 1, getMultiset().count(e0()));
}
@CollectionSize.Require(SEVERAL)
public void testCount_3() {
initThreeCopies();
assertEquals("multiset.count(thriceContained) didn't return 3", 3, getMultiset().count(e0()));
}
Reported by PMD.
Line: 56
@CollectionSize.Require(SEVERAL)
public void testCount_3() {
initThreeCopies();
assertEquals("multiset.count(thriceContained) didn't return 3", 3, getMultiset().count(e0()));
}
@CollectionFeature.Require(ALLOWS_NULL_QUERIES)
public void testCount_nullAbsent() {
assertEquals("multiset.count(null) didn't return 0", 0, getMultiset().count(null));
Reported by PMD.
Line: 59
assertEquals("multiset.count(thriceContained) didn't return 3", 3, getMultiset().count(e0()));
}
@CollectionFeature.Require(ALLOWS_NULL_QUERIES)
public void testCount_nullAbsent() {
assertEquals("multiset.count(null) didn't return 0", 0, getMultiset().count(null));
}
@CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES)
Reported by PMD.
Line: 61
@CollectionFeature.Require(ALLOWS_NULL_QUERIES)
public void testCount_nullAbsent() {
assertEquals("multiset.count(null) didn't return 0", 0, getMultiset().count(null));
}
@CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES)
public void testCount_null_forbidden() {
try {
Reported by PMD.
Line: 64
assertEquals("multiset.count(null) didn't return 0", 0, getMultiset().count(null));
}
@CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES)
public void testCount_null_forbidden() {
try {
getMultiset().count(null);
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
Reported by PMD.
Line: 67
@CollectionFeature.Require(absent = ALLOWS_NULL_QUERIES)
public void testCount_null_forbidden() {
try {
getMultiset().count(null);
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
}
}
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/SetCreationTester.java
16 issues
Line: 41
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetCreationTester<E> extends AbstractSetTester<E> {
@CollectionFeature.Require(value = ALLOWS_NULL_VALUES, absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nullDuplicatesNotRejected() {
E[] array = createArrayWithNullElement();
array[0] = null;
collection = getSubjectGenerator().create(array);
Reported by PMD.
Line: 45
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nullDuplicatesNotRejected() {
E[] array = createArrayWithNullElement();
array[0] = null;
collection = getSubjectGenerator().create(array);
List<E> expectedWithDuplicateRemoved = Arrays.asList(array).subList(1, getNumElements());
expectContents(expectedWithDuplicateRemoved);
}
Reported by PMD.
Line: 46
public void testCreateWithDuplicates_nullDuplicatesNotRejected() {
E[] array = createArrayWithNullElement();
array[0] = null;
collection = getSubjectGenerator().create(array);
List<E> expectedWithDuplicateRemoved = Arrays.asList(array).subList(1, getNumElements());
expectContents(expectedWithDuplicateRemoved);
}
Reported by PMD.
Line: 48
array[0] = null;
collection = getSubjectGenerator().create(array);
List<E> expectedWithDuplicateRemoved = Arrays.asList(array).subList(1, getNumElements());
expectContents(expectedWithDuplicateRemoved);
}
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
Reported by PMD.
Line: 52
expectContents(expectedWithDuplicateRemoved);
}
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nonNullDuplicatesNotRejected() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
Reported by PMD.
Line: 57
public void testCreateWithDuplicates_nonNullDuplicatesNotRejected() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
List<E> expectedWithDuplicateRemoved = Arrays.asList(array).subList(1, getNumElements());
expectContents(expectedWithDuplicateRemoved);
}
Reported by PMD.
Line: 59
array[1] = e0();
collection = getSubjectGenerator().create(array);
List<E> expectedWithDuplicateRemoved = Arrays.asList(array).subList(1, getNumElements());
expectContents(expectedWithDuplicateRemoved);
}
@CollectionFeature.Require({ALLOWS_NULL_VALUES, REJECTS_DUPLICATES_AT_CREATION})
@CollectionSize.Require(absent = {ZERO, ONE})
Reported by PMD.
Line: 63
expectContents(expectedWithDuplicateRemoved);
}
@CollectionFeature.Require({ALLOWS_NULL_VALUES, REJECTS_DUPLICATES_AT_CREATION})
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nullDuplicatesRejected() {
E[] array = createArrayWithNullElement();
array[0] = null;
try {
Reported by PMD.
Line: 67
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nullDuplicatesRejected() {
E[] array = createArrayWithNullElement();
array[0] = null;
try {
collection = getSubjectGenerator().create(array);
fail("Should reject duplicate null elements at creation");
} catch (IllegalArgumentException expected) {
}
Reported by PMD.
Line: 69
E[] array = createArrayWithNullElement();
array[0] = null;
try {
collection = getSubjectGenerator().create(array);
fail("Should reject duplicate null elements at creation");
} catch (IllegalArgumentException expected) {
}
}
Reported by PMD.
android/guava/src/com/google/common/primitives/Booleans.java
16 issues
Line: 200
continue outer;
}
}
return i;
}
return -1;
}
/**
Reported by PMD.
Line: 46
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Booleans {
private Booleans() {}
/** Comparators for {@code Boolean} values. */
private enum BooleanComparator implements Comparator<Boolean> {
TRUE_FIRST(1, "Booleans.trueFirst()"),
Reported by PMD.
Line: 381
@GwtCompatible
private static class BooleanArrayAsList extends AbstractList<Boolean>
implements RandomAccess, Serializable {
final boolean[] array;
final int start;
final int end;
BooleanArrayAsList(boolean[] array) {
this(array, 0, array.length);
Reported by PMD.
Line: 382
private static class BooleanArrayAsList extends AbstractList<Boolean>
implements RandomAccess, Serializable {
final boolean[] array;
final int start;
final int end;
BooleanArrayAsList(boolean[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 383
implements RandomAccess, Serializable {
final boolean[] array;
final int start;
final int end;
BooleanArrayAsList(boolean[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 389
this(array, 0, array.length);
}
BooleanArrayAsList(boolean[] array, int start, int end) {
this.array = array;
this.start = start;
this.end = end;
}
Reported by PMD.
Line: 469
if (object instanceof BooleanArrayAsList) {
BooleanArrayAsList that = (BooleanArrayAsList) 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: 548
public static void reverse(boolean[] array, int fromIndex, int toIndex) {
checkNotNull(array);
checkPositionIndexes(fromIndex, toIndex, array.length);
for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
boolean tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
Reported by PMD.
Line: 186
* @param array the array to search for the sequence {@code target}
* @param target the array to search for as a sub-sequence of {@code array}
*/
public static int indexOf(boolean[] array, boolean[] target) {
checkNotNull(array, "array");
checkNotNull(target, "target");
if (target.length == 0) {
return 0;
}
Reported by PMD.
Line: 385
final int start;
final int end;
BooleanArrayAsList(boolean[] array) {
this(array, 0, array.length);
}
BooleanArrayAsList(boolean[] array, int start, int end) {
this.array = array;
Reported by PMD.
android/guava/src/com/google/common/primitives/Chars.java
16 issues
Line: 183
continue outer;
}
}
return i;
}
return -1;
}
/**
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Chars {
private Chars() {}
/**
* The number of bytes required to represent a primitive {@code char} value.
*
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Chars {
private Chars() {}
/**
* The number of bytes required to represent a primitive {@code char} value.
*
Reported by PMD.
Line: 484
public static void reverse(char[] array, int fromIndex, int toIndex) {
checkNotNull(array);
checkPositionIndexes(fromIndex, toIndex, array.length);
for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
char tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
Reported by PMD.
Line: 513
@GwtCompatible
private static class CharArrayAsList extends AbstractList<Character>
implements RandomAccess, Serializable {
final char[] array;
final int start;
final int end;
CharArrayAsList(char[] array) {
this(array, 0, array.length);
Reported by PMD.
Line: 514
private static class CharArrayAsList extends AbstractList<Character>
implements RandomAccess, Serializable {
final char[] array;
final int start;
final int end;
CharArrayAsList(char[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 515
implements RandomAccess, Serializable {
final char[] array;
final int start;
final int end;
CharArrayAsList(char[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 521
this(array, 0, array.length);
}
CharArrayAsList(char[] array, int start, int end) {
this.array = array;
this.start = start;
this.end = end;
}
Reported by PMD.
Line: 601
if (object instanceof CharArrayAsList) {
CharArrayAsList that = (CharArrayAsList) 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: 169
* @param array the array to search for the sequence {@code target}
* @param target the array to search for as a sub-sequence of {@code array}
*/
public static int indexOf(char[] array, char[] target) {
checkNotNull(array, "array");
checkNotNull(target, "target");
if (target.length == 0) {
return 0;
}
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java
16 issues
Line: 45
private static List<Short> asList(Short[] values) {
short[] temp = new short[values.length];
for (short i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Shorts.asList(temp);
}
Reported by PMD.
Line: 131
@Override
public List<Short> create(Object... elements) {
Short[] array = new Short[elements.length];
short i = 0;
for (Object e : elements) {
array[i++] = (Short) e;
}
return create(array);
}
Reported by PMD.
Line: 41
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ShortArrayAsListTest extends TestCase {
private static List<Short> asList(Short[] values) {
short[] temp = new short[values.length];
for (short i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
Reported by PMD.
Line: 51
return Shorts.asList(temp);
}
@GwtIncompatible // suite
public static Test suite() {
List<ListTestSuiteBuilder<Short>> builders =
ImmutableList.of(
ListTestSuiteBuilder.using(new ShortsAsListGenerator()).named("Shorts.asList"),
ListTestSuiteBuilder.using(new ShortsAsListHeadSubListGenerator())
Reported by PMD.
Line: 66
TestSuite suite = new TestSuite();
for (ListTestSuiteBuilder<Short> builder : builders) {
suite.addTest(
builder
.withFeatures(
CollectionSize.ONE,
CollectionSize.SEVERAL,
CollectionFeature.RESTRICTS_ELEMENTS,
ListFeature.SUPPORTS_SET)
Reported by PMD.
Line: 92
protected List<Short> create(Short[] elements) {
Short[] suffix = {Short.MIN_VALUE, Short.MAX_VALUE};
Short[] all = concat(elements, suffix);
return asList(all).subList(0, elements.length);
}
}
public static final class ShortsAsListTailSubListGenerator extends TestShortListGenerator {
@Override
Reported by PMD.
Line: 101
protected List<Short> create(Short[] elements) {
Short[] prefix = {(short) 86, (short) 99};
Short[] all = concat(prefix, elements);
return asList(all).subList(2, elements.length + 2);
}
}
public static final class ShortsAsListMiddleSubListGenerator extends TestShortListGenerator {
@Override
Reported by PMD.
Line: 111
Short[] prefix = {Short.MIN_VALUE, Short.MAX_VALUE};
Short[] suffix = {(short) 86, (short) 99};
Short[] all = concat(concat(prefix, elements), suffix);
return asList(all).subList(2, elements.length + 2);
}
}
private static Short[] concat(Short[] left, Short[] right) {
Short[] result = new Short[left.length + right.length];
Reported by PMD.
Line: 43
@GwtCompatible(emulated = true)
public class ShortArrayAsListTest extends TestCase {
private static List<Short> asList(Short[] values) {
short[] temp = new short[values.length];
for (short i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Shorts.asList(temp);
Reported by PMD.
Line: 115
}
}
private static Short[] concat(Short[] left, Short[] right) {
Short[] result = new Short[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.
android/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java
16 issues
Line: 37
protected static final int VALID_INPUT_DATA = 1;
protected static final Exception EXCEPTION = new Exception("Test exception");
protected SettableFuture<Integer> inputFuture;
protected ListenableFuture<T> resultFuture;
protected MockFutureListener listener;
@Override
protected void setUp() throws Exception {
Reported by PMD.
Line: 38
protected static final Exception EXCEPTION = new Exception("Test exception");
protected SettableFuture<Integer> inputFuture;
protected ListenableFuture<T> resultFuture;
protected MockFutureListener listener;
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 39
protected SettableFuture<Integer> inputFuture;
protected ListenableFuture<T> resultFuture;
protected MockFutureListener listener;
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 41
protected ListenableFuture<T> resultFuture;
protected MockFutureListener listener;
@Override
protected void setUp() throws Exception {
super.setUp();
inputFuture = SettableFuture.create();
resultFuture = buildChainingFuture(inputFuture);
Reported by PMD.
Line: 50
listener = new MockFutureListener(resultFuture);
}
public void testFutureGetBeforeCallback() throws Exception {
// Verify that get throws a timeout exception before the callback is called.
try {
resultFuture.get(1L, TimeUnit.MILLISECONDS);
fail("The data is not yet ready, so a TimeoutException is expected");
} catch (TimeoutException expected) {
Reported by PMD.
Line: 54
// Verify that get throws a timeout exception before the callback is called.
try {
resultFuture.get(1L, TimeUnit.MILLISECONDS);
fail("The data is not yet ready, so a TimeoutException is expected");
} catch (TimeoutException expected) {
}
}
public void testFutureGetThrowsWrappedException() throws Exception {
Reported by PMD.
Line: 59
}
}
public void testFutureGetThrowsWrappedException() throws Exception {
inputFuture.setException(EXCEPTION);
listener.assertException(EXCEPTION);
}
public void testFutureGetThrowsWrappedError() throws Exception {
Reported by PMD.
Line: 59
}
}
public void testFutureGetThrowsWrappedException() throws Exception {
inputFuture.setException(EXCEPTION);
listener.assertException(EXCEPTION);
}
public void testFutureGetThrowsWrappedError() throws Exception {
Reported by PMD.
Line: 64
listener.assertException(EXCEPTION);
}
public void testFutureGetThrowsWrappedError() throws Exception {
Error error = new Error();
inputFuture.setException(error);
// Verify that get throws an ExecutionException, caused by an Error, when
// the callback is called.
listener.assertException(error);
Reported by PMD.
Line: 64
listener.assertException(EXCEPTION);
}
public void testFutureGetThrowsWrappedError() throws Exception {
Error error = new Error();
inputFuture.setException(error);
// Verify that get throws an ExecutionException, caused by an Error, when
// the callback is called.
listener.assertException(error);
Reported by PMD.