The following issues were found
android/guava-tests/test/com/google/common/collect/NewCustomTableTest.java
10 issues
Line: 49
return table;
}
public void testRowKeySetOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
Reported by PMD.
Line: 50
}
public void testRowKeySetOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
Reported by PMD.
Line: 51
public void testRowKeySetOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
Reported by PMD.
Line: 51
public void testRowKeySetOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
Reported by PMD.
Line: 54
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
}
}
Reported by PMD.
Line: 56
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
}
}
Reported by PMD.
Line: 56
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
}
}
Reported by PMD.
Line: 56
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
}
}
Reported by PMD.
Line: 36
@Override
protected Table<String, Integer, Character> create(Object... data) {
Supplier<TreeMap<Integer, Character>> factory =
new Supplier<TreeMap<Integer, Character>>() {
@Override
public TreeMap<Integer, Character> get() {
return Maps.newTreeMap();
}
Reported by PMD.
Line: 36
@Override
protected Table<String, Integer, Character> create(Object... data) {
Supplier<TreeMap<Integer, Character>> factory =
new Supplier<TreeMap<Integer, Character>>() {
@Override
public TreeMap<Integer, Character> get() {
return Maps.newTreeMap();
}
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/MinimalCollection.java
10 issues
Line: 58
if (!allowNulls) {
for (Object element : contents) {
if (element == null) {
throw new NullPointerException();
}
}
}
}
Reported by PMD.
Line: 74
if (!allowNulls) {
// behave badly
if (object == null) {
throw new NullPointerException();
}
}
Platform.checkCast(type, object); // behave badly
return Arrays.asList(contents).contains(object);
}
Reported by PMD.
Line: 87
for (Object object : collection) {
// behave badly
if (object == null) {
throw new NullPointerException();
}
}
}
return super.containsAll(collection);
}
Reported by PMD.
Line: 32
* @author Kevin Bourrillion
*/
@GwtCompatible
public class MinimalCollection<E> extends AbstractCollection<E> {
// TODO: expose allow nulls parameter?
public static <E> MinimalCollection<E> of(E... contents) {
return new MinimalCollection<E>(Object.class, true, contents);
}
Reported by PMD.
Line: 44
return new MinimalCollection<E>(type, true, contents);
}
private final E[] contents;
private final Class<? super E> type;
private final boolean allowNulls;
// Package-private so that it can be extended.
MinimalCollection(Class<? super E> type, boolean allowNulls, E... contents) {
Reported by PMD.
Line: 45
}
private final E[] contents;
private final Class<? super E> type;
private final boolean allowNulls;
// Package-private so that it can be extended.
MinimalCollection(Class<? super E> type, boolean allowNulls, E... contents) {
// TODO: consider making it shuffle the contents to test iteration order.
Reported by PMD.
Line: 46
private final E[] contents;
private final Class<? super E> type;
private final boolean allowNulls;
// Package-private so that it can be extended.
MinimalCollection(Class<? super E> type, boolean allowNulls, E... contents) {
// TODO: consider making it shuffle the contents to test iteration order.
this.contents = Platform.clone(contents);
Reported by PMD.
Line: 73
public boolean contains(Object object) {
if (!allowNulls) {
// behave badly
if (object == null) {
throw new NullPointerException();
}
}
Platform.checkCast(type, object); // behave badly
return Arrays.asList(contents).contains(object);
Reported by PMD.
Line: 78
}
}
Platform.checkCast(type, object); // behave badly
return Arrays.asList(contents).contains(object);
}
@Override
public boolean containsAll(Collection<?> collection) {
if (!allowNulls) {
Reported by PMD.
Line: 96
@Override
public Iterator<E> iterator() {
return Arrays.asList(contents).iterator();
}
@Override
public Object[] toArray() {
Object[] result = new Object[contents.length];
Reported by PMD.
android/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java
10 issues
Line: 32
public class ToStringHelperBenchmark {
@Param({"0", "1", "5"})
int dataSize;
@Param({"false", "true"})
boolean omitNulls;
enum Dataset {
Reported by PMD.
Line: 35
int dataSize;
@Param({"false", "true"})
boolean omitNulls;
enum Dataset {
SMALL {
void addEntries(MoreObjects.ToStringHelper helper) {
helper
Reported by PMD.
Line: 40
enum Dataset {
SMALL {
void addEntries(MoreObjects.ToStringHelper helper) {
helper
.add(SHORT_NAME, 10)
.addValue(10L)
.add(SHORT_NAME, 3.14f)
.addValue(3.14d)
.add(LONG_NAME, false)
Reported by PMD.
Line: 40
enum Dataset {
SMALL {
void addEntries(MoreObjects.ToStringHelper helper) {
helper
.add(SHORT_NAME, 10)
.addValue(10L)
.add(SHORT_NAME, 3.14f)
.addValue(3.14d)
.add(LONG_NAME, false)
Reported by PMD.
Line: 40
enum Dataset {
SMALL {
void addEntries(MoreObjects.ToStringHelper helper) {
helper
.add(SHORT_NAME, 10)
.addValue(10L)
.add(SHORT_NAME, 3.14f)
.addValue(3.14d)
.add(LONG_NAME, false)
Reported by PMD.
Line: 40
enum Dataset {
SMALL {
void addEntries(MoreObjects.ToStringHelper helper) {
helper
.add(SHORT_NAME, 10)
.addValue(10L)
.add(SHORT_NAME, 3.14f)
.addValue(3.14d)
.add(LONG_NAME, false)
Reported by PMD.
Line: 40
enum Dataset {
SMALL {
void addEntries(MoreObjects.ToStringHelper helper) {
helper
.add(SHORT_NAME, 10)
.addValue(10L)
.add(SHORT_NAME, 3.14f)
.addValue(3.14d)
.add(LONG_NAME, false)
Reported by PMD.
Line: 114
void addEntries(MoreObjects.ToStringHelper helper) {}
}
@Param Dataset dataset;
private static final String SHORT_NAME = "userId";
private static final String LONG_NAME = "fluxCapacitorFailureRate95Percentile";
private MoreObjects.ToStringHelper newHelper() {
Reported by PMD.
Line: 135
for (int j = 0; j < dataSize; ++j) {
dataset.addEntries(helper);
}
dummy ^= helper.toString().hashCode();
}
return dummy;
}
// When omitEmptyValues() is released, remove this method and add a new @Param "omitEmptyValues".
Reported by PMD.
Line: 135
for (int j = 0; j < dataSize; ++j) {
dataset.addEntries(helper);
}
dummy ^= helper.toString().hashCode();
}
return dummy;
}
// When omitEmptyValues() is released, remove this method and add a new @Param "omitEmptyValues".
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/TestsForQueuesInJavaUtil.java
10 issues
Line: 44
* @author Jared Levy
*/
@GwtIncompatible
public class TestsForQueuesInJavaUtil {
public static Test suite() {
return new TestsForQueuesInJavaUtil().allTests();
}
public Test allTests() {
Reported by PMD.
Line: 45
*/
@GwtIncompatible
public class TestsForQueuesInJavaUtil {
public static Test suite() {
return new TestsForQueuesInJavaUtil().allTests();
}
public Test allTests() {
TestSuite suite = new TestSuite();
Reported by PMD.
Line: 94
return Collections.emptySet();
}
public Test testsForArrayDeque() {
return QueueTestSuiteBuilder.using(
new TestStringQueueGenerator() {
@Override
public Queue<String> create(String[] elements) {
return new ArrayDeque<>(MinimalCollection.of(elements));
Reported by PMD.
Line: 109
.createTestSuite();
}
public Test testsForLinkedList() {
return QueueTestSuiteBuilder.using(
new TestStringQueueGenerator() {
@Override
public Queue<String> create(String[] elements) {
return new LinkedList<>(MinimalCollection.of(elements));
Reported by PMD.
Line: 128
.createTestSuite();
}
public Test testsForArrayBlockingQueue() {
return QueueTestSuiteBuilder.using(
new TestStringQueueGenerator() {
@Override
public Queue<String> create(String[] elements) {
return new ArrayBlockingQueue<>(100, false, MinimalCollection.of(elements));
Reported by PMD.
Line: 143
.createTestSuite();
}
public Test testsForConcurrentLinkedQueue() {
return QueueTestSuiteBuilder.using(
new TestStringQueueGenerator() {
@Override
public Queue<String> create(String[] elements) {
return new ConcurrentLinkedQueue<>(MinimalCollection.of(elements));
Reported by PMD.
Line: 158
.createTestSuite();
}
public Test testsForLinkedBlockingDeque() {
return QueueTestSuiteBuilder.using(
new TestStringQueueGenerator() {
@Override
public Queue<String> create(String[] elements) {
return new LinkedBlockingDeque<>(MinimalCollection.of(elements));
Reported by PMD.
Line: 173
.createTestSuite();
}
public Test testsForLinkedBlockingQueue() {
return QueueTestSuiteBuilder.using(
new TestStringQueueGenerator() {
@Override
public Queue<String> create(String[] elements) {
return new LinkedBlockingQueue<>(MinimalCollection.of(elements));
Reported by PMD.
Line: 193
// also mean that the iterator returns the head element first, which those
// don't.
public Test testsForPriorityBlockingQueue() {
return QueueTestSuiteBuilder.using(
new TestStringQueueGenerator() {
@Override
public Queue<String> create(String[] elements) {
return new PriorityBlockingQueue<>(MinimalCollection.of(elements));
Reported by PMD.
Line: 207
.createTestSuite();
}
public Test testsForPriorityQueue() {
return QueueTestSuiteBuilder.using(
new TestStringQueueGenerator() {
@Override
public Queue<String> create(String[] elements) {
return new PriorityQueue<>(MinimalCollection.of(elements));
Reported by PMD.
android/guava-tests/benchmark/com/google/common/collect/ImmutableListCreationBenchmark.java
10 issues
Line: 31
public class ImmutableListCreationBenchmark {
@Param({"10", "1000", "1000000"})
int size;
private static final Object OBJECT = new Object();
@Benchmark
int builderAdd(int reps) {
Reported by PMD.
Line: 44
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
dummy += builder.build().size();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 54
int size = this.size;
int dummy = 0;
for (int rep = 0; rep < reps; rep++) {
ImmutableList.Builder<Object> builder = new ImmutableList.Builder<>(size);
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
dummy += builder.build().size();
}
Reported by PMD.
Line: 58
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
dummy += builder.build().size();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 72
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
dummy += ImmutableList.copyOf(builder).size();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 86
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
tmp += ImmutableList.copyOf(builder).size();
}
return tmp;
}
}
Reported by PMD.
Line: 37
@Benchmark
int builderAdd(int reps) {
int size = this.size;
int dummy = 0;
for (int rep = 0; rep < reps; rep++) {
ImmutableList.Builder<Object> builder = ImmutableList.builder();
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
Reported by PMD.
Line: 51
@Benchmark
int preSizedBuilderAdd(int reps) {
int size = this.size;
int dummy = 0;
for (int rep = 0; rep < reps; rep++) {
ImmutableList.Builder<Object> builder = new ImmutableList.Builder<>(size);
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
Reported by PMD.
Line: 65
@Benchmark
int copyArrayList(int reps) {
int size = this.size;
int dummy = 0;
for (int rep = 0; rep < reps; rep++) {
List<Object> builder = Lists.newArrayList();
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
Reported by PMD.
Line: 79
@Benchmark
int copyPreSizedArrayList(int reps) {
int size = this.size;
int tmp = 0;
for (int rep = 0; rep < reps; rep++) {
List<Object> builder = Lists.newArrayListWithCapacity(size);
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapToStringTester.java
10 issues
Line: 38
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapToStringTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringEmpty() {
assertEquals("{}", multimap().toString());
}
Reported by PMD.
Line: 41
@CollectionSize.Require(ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringEmpty() {
assertEquals("{}", multimap().toString());
}
@CollectionSize.Require(ONE)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringSingleton() {
Reported by PMD.
Line: 44
assertEquals("{}", multimap().toString());
}
@CollectionSize.Require(ONE)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringSingleton() {
assertEquals("{" + k0() + "=[" + v0() + "]}", multimap().toString());
}
Reported by PMD.
Line: 47
@CollectionSize.Require(ONE)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringSingleton() {
assertEquals("{" + k0() + "=[" + v0() + "]}", multimap().toString());
}
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
@MapFeature.Require(ALLOWS_NULL_KEYS)
Reported by PMD.
Line: 50
assertEquals("{" + k0() + "=[" + v0() + "]}", multimap().toString());
}
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testToStringWithNullKey() {
initMultimapWithNullKey();
testToStringMatchesAsMap();
Reported by PMD.
Line: 58
testToStringMatchesAsMap();
}
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testToStringWithNullValue() {
initMultimapWithNullValue();
testToStringMatchesAsMap();
Reported by PMD.
Line: 66
testToStringMatchesAsMap();
}
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringMatchesAsMap() {
assertEquals(multimap().asMap().toString(), multimap().toString());
}
}
Reported by PMD.
Line: 68
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringMatchesAsMap() {
assertEquals(multimap().asMap().toString(), multimap().toString());
}
}
Reported by PMD.
Line: 68
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringMatchesAsMap() {
assertEquals(multimap().asMap().toString(), multimap().toString());
}
}
Reported by PMD.
Line: 68
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToStringMatchesAsMap() {
assertEquals(multimap().asMap().toString(), multimap().toString());
}
}
Reported by PMD.
android/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java
10 issues
Line: 99
*/
protected ArrayBasedUnicodeEscaper(
ArrayBasedEscaperMap escaperMap,
int safeMin,
int safeMax,
@Nullable String unsafeReplacement) {
checkNotNull(escaperMap); // GWT specific check (do not optimize)
this.replacements = escaperMap.getReplacementArray();
this.replacementsLength = replacements.length;
Reported by PMD.
Line: 100
protected ArrayBasedUnicodeEscaper(
ArrayBasedEscaperMap escaperMap,
int safeMin,
int safeMax,
@Nullable String unsafeReplacement) {
checkNotNull(escaperMap); // GWT specific check (do not optimize)
this.replacements = escaperMap.getReplacementArray();
this.replacementsLength = replacements.length;
if (safeMax < safeMin) {
Reported by PMD.
Line: 182
/* Overridden for performance. */
@Override
protected final int nextEscapeIndex(CharSequence csq, int index, int end) {
while (index < end) {
char c = csq.charAt(index);
if ((c < replacementsLength && replacements[c] != null)
|| c > safeMaxChar
|| c < safeMinChar) {
Reported by PMD.
Line: 49
@ElementTypesAreNonnullByDefault
public abstract class ArrayBasedUnicodeEscaper extends UnicodeEscaper {
// The replacement array (see ArrayBasedEscaperMap).
private final char[][] replacements;
// The number of elements in the replacement array.
private final int replacementsLength;
// The first code point in the safe range.
private final int safeMin;
// The last code point in the safe range.
Reported by PMD.
Line: 51
// The replacement array (see ArrayBasedEscaperMap).
private final char[][] replacements;
// The number of elements in the replacement array.
private final int replacementsLength;
// The first code point in the safe range.
private final int safeMin;
// The last code point in the safe range.
private final int safeMax;
Reported by PMD.
Line: 53
// The number of elements in the replacement array.
private final int replacementsLength;
// The first code point in the safe range.
private final int safeMin;
// The last code point in the safe range.
private final int safeMax;
// Cropped values used in the fast path range checks.
private final char safeMinChar;
Reported by PMD.
Line: 55
// The first code point in the safe range.
private final int safeMin;
// The last code point in the safe range.
private final int safeMax;
// Cropped values used in the fast path range checks.
private final char safeMinChar;
private final char safeMaxChar;
Reported by PMD.
Line: 58
private final int safeMax;
// Cropped values used in the fast path range checks.
private final char safeMinChar;
private final char safeMaxChar;
/**
* Creates a new ArrayBasedUnicodeEscaper instance with the given replacement map and specified
* safe range. If {@code safeMax < safeMin} then no code points are considered safe.
Reported by PMD.
Line: 59
// Cropped values used in the fast path range checks.
private final char safeMinChar;
private final char safeMaxChar;
/**
* Creates a new ArrayBasedUnicodeEscaper instance with the given replacement map and specified
* safe range. If {@code safeMax < safeMin} then no code points are considered safe.
*
Reported by PMD.
Line: 101
ArrayBasedEscaperMap escaperMap,
int safeMin,
int safeMax,
@Nullable String unsafeReplacement) {
checkNotNull(escaperMap); // GWT specific check (do not optimize)
this.replacements = escaperMap.getReplacementArray();
this.replacementsLength = replacements.length;
if (safeMax < safeMin) {
// If the safe range is empty, set the range limits to opposite extremes
Reported by PMD.
android/guava/src/com/google/common/base/CaseFormat.java
10 issues
Line: 137
StringBuilder out = null;
int i = 0;
int j = -1;
while ((j = wordBoundary.indexIn(s, ++j)) != -1) {
if (i == 0) {
// include some extra space for separators
out = new StringBuilder(s.length() + 4 * format.wordSeparator.length());
out.append(format.normalizeFirstWord(s.substring(i, j)));
} else {
Reported by PMD.
Line: 140
while ((j = wordBoundary.indexIn(s, ++j)) != -1) {
if (i == 0) {
// include some extra space for separators
out = new StringBuilder(s.length() + 4 * format.wordSeparator.length());
out.append(format.normalizeFirstWord(s.substring(i, j)));
} else {
requireNonNull(out).append(format.normalizeWord(s.substring(i, j)));
}
out.append(format.wordSeparator);
Reported by PMD.
Line: 140
while ((j = wordBoundary.indexIn(s, ++j)) != -1) {
if (i == 0) {
// include some extra space for separators
out = new StringBuilder(s.length() + 4 * format.wordSeparator.length());
out.append(format.normalizeFirstWord(s.substring(i, j)));
} else {
requireNonNull(out).append(format.normalizeWord(s.substring(i, j)));
}
out.append(format.wordSeparator);
Reported by PMD.
Line: 143
out = new StringBuilder(s.length() + 4 * format.wordSeparator.length());
out.append(format.normalizeFirstWord(s.substring(i, j)));
} else {
requireNonNull(out).append(format.normalizeWord(s.substring(i, j)));
}
out.append(format.wordSeparator);
i = j + wordSeparator.length();
}
return (i == 0)
Reported by PMD.
Line: 150
}
return (i == 0)
? format.normalizeFirstWord(s)
: requireNonNull(out).append(format.normalizeWord(s.substring(i))).toString();
}
/**
* Returns a {@code Converter} that converts strings from this format to {@code targetFormat}.
*
Reported by PMD.
Line: 150
}
return (i == 0)
? format.normalizeFirstWord(s)
: requireNonNull(out).append(format.normalizeWord(s.substring(i))).toString();
}
/**
* Returns a {@code Converter} that converts strings from this format to {@code targetFormat}.
*
Reported by PMD.
Line: 165
private static final class StringConverter extends Converter<String, String>
implements Serializable {
private final CaseFormat sourceFormat;
private final CaseFormat targetFormat;
StringConverter(CaseFormat sourceFormat, CaseFormat targetFormat) {
this.sourceFormat = checkNotNull(sourceFormat);
this.targetFormat = checkNotNull(targetFormat);
Reported by PMD.
Line: 166
implements Serializable {
private final CaseFormat sourceFormat;
private final CaseFormat targetFormat;
StringConverter(CaseFormat sourceFormat, CaseFormat targetFormat) {
this.sourceFormat = checkNotNull(sourceFormat);
this.targetFormat = checkNotNull(targetFormat);
}
Reported by PMD.
Line: 134
/** Enum values can override for performance reasons. */
String convert(CaseFormat format, String s) {
// deal with camel conversion
StringBuilder out = null;
int i = 0;
int j = -1;
while ((j = wordBoundary.indexIn(s, ++j)) != -1) {
if (i == 0) {
// include some extra space for separators
Reported by PMD.
Line: 137
StringBuilder out = null;
int i = 0;
int j = -1;
while ((j = wordBoundary.indexIn(s, ++j)) != -1) {
if (i == 0) {
// include some extra space for separators
out = new StringBuilder(s.length() + 4 * format.wordSeparator.length());
out.append(format.normalizeFirstWord(s.substring(i, j)));
} else {
Reported by PMD.
android/guava/src/com/google/common/primitives/UnsignedBytes.java
10 issues
Line: 329
&& (BYTE_ARRAY_BASE_OFFSET % 8) == 0
// sanity check - this should never fail
&& theUnsafe.arrayIndexScale(byte[].class) == 1)) {
throw new Error(); // force fallback to PureJavaComparator
}
}
/**
* Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. Replace with a simple
Reported by PMD.
Line: 362
}
});
} catch (java.security.PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
@Override
public int compare(byte[] left, byte[] right) {
Reported by PMD.
Line: 48
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class UnsignedBytes {
private UnsignedBytes() {}
/**
* The largest power of two that can be represented as an unsigned {@code byte}.
*
Reported by PMD.
Line: 289
* available.
*/
@VisibleForTesting
static class LexicographicalComparatorHolder {
static final String UNSAFE_COMPARATOR_NAME =
LexicographicalComparatorHolder.class.getName() + "$UnsafeComparator";
static final Comparator<byte[]> BEST_COMPARATOR = getBestComparator();
Reported by PMD.
Line: 341
*/
private static sun.misc.Unsafe getUnsafe() {
try {
return sun.misc.Unsafe.getUnsafe();
} catch (SecurityException e) {
// that's okay; try reflection instead
}
try {
return java.security.AccessController.doPrivileged(
Reported by PMD.
Line: 342
private static sun.misc.Unsafe getUnsafe() {
try {
return sun.misc.Unsafe.getUnsafe();
} catch (SecurityException e) {
// that's okay; try reflection instead
}
try {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
Reported by PMD.
Line: 362
}
});
} catch (java.security.PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
@Override
public int compare(byte[] left, byte[] right) {
Reported by PMD.
Line: 443
Class<?> theClass = Class.forName(UNSAFE_COMPARATOR_NAME);
// requireNonNull is safe because the class is an enum.
Object[] constants = requireNonNull(theClass.getEnumConstants());
// yes, UnsafeComparator does implement Comparator<byte[]>
@SuppressWarnings("unchecked")
Comparator<byte[]> comparator = (Comparator<byte[]>) constants[0];
return comparator;
Reported by PMD.
Line: 449
@SuppressWarnings("unchecked")
Comparator<byte[]> comparator = (Comparator<byte[]>) constants[0];
return comparator;
} catch (Throwable t) { // ensure we really catch *everything*
return lexicographicalComparatorJavaImpl();
}
}
}
Reported by PMD.
Line: 29
import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.Comparator;
import sun.misc.Unsafe;
/**
* Static utility methods pertaining to {@code byte} primitives that interpret values as
* <i>unsigned</i> (that is, any negative value {@code b} is treated as the positive value {@code
* 256 + b}). The corresponding methods that treat the values as signed are found in {@link
Reported by PMD.
android/guava/src/com/google/common/base/Converter.java
10 issues
Line: 142
*
* [*] In annotating this class, we're ignoring LegacyConverter.
*/
public abstract class Converter<A, B> implements Function<A, B> {
private final boolean handleNullAutomatically;
// We lazily cache the reverse view to avoid allocating on every call to reverse().
@LazyInit @RetainedWith @CheckForNull private transient Converter<B, A> reverse;
Reported by PMD.
Line: 143
* [*] In annotating this class, we're ignoring LegacyConverter.
*/
public abstract class Converter<A, B> implements Function<A, B> {
private final boolean handleNullAutomatically;
// We lazily cache the reverse view to avoid allocating on every call to reverse().
@LazyInit @RetainedWith @CheckForNull private transient Converter<B, A> reverse;
/** Constructor for use by subclasses. */
Reported by PMD.
Line: 146
private final boolean handleNullAutomatically;
// We lazily cache the reverse view to avoid allocating on every call to reverse().
@LazyInit @RetainedWith @CheckForNull private transient Converter<B, A> reverse;
/** Constructor for use by subclasses. */
protected Converter() {
this(true);
}
Reported by PMD.
Line: 318
private static final class ReverseConverter<A, B> extends Converter<B, A>
implements Serializable {
final Converter<A, B> original;
ReverseConverter(Converter<A, B> original) {
this.original = original;
}
Reported by PMD.
Line: 398
private static final class ConverterComposition<A, B, C> extends Converter<A, C>
implements Serializable {
final Converter<A, B> first;
final Converter<B, C> second;
ConverterComposition(Converter<A, B> first, Converter<B, C> second) {
this.first = first;
this.second = second;
Reported by PMD.
Line: 399
private static final class ConverterComposition<A, B, C> extends Converter<A, C>
implements Serializable {
final Converter<A, B> first;
final Converter<B, C> second;
ConverterComposition(Converter<A, B> first, Converter<B, C> second) {
this.first = first;
this.second = second;
}
Reported by PMD.
Line: 511
* interchangeable.
*/
@Override
public boolean equals(@CheckForNull Object object) {
return super.equals(object);
}
// Static converters
Reported by PMD.
Line: 537
return new FunctionBasedConverter<>(forwardFunction, backwardFunction);
}
private static final class FunctionBasedConverter<A, B> extends Converter<A, B>
implements Serializable {
private final Function<? super A, ? extends B> forwardFunction;
private final Function<? super B, ? extends A> backwardFunction;
private FunctionBasedConverter(
Reported by PMD.
Line: 539
private static final class FunctionBasedConverter<A, B> extends Converter<A, B>
implements Serializable {
private final Function<? super A, ? extends B> forwardFunction;
private final Function<? super B, ? extends A> backwardFunction;
private FunctionBasedConverter(
Function<? super A, ? extends B> forwardFunction,
Function<? super B, ? extends A> backwardFunction) {
Reported by PMD.
Line: 540
private static final class FunctionBasedConverter<A, B> extends Converter<A, B>
implements Serializable {
private final Function<? super A, ? extends B> forwardFunction;
private final Function<? super B, ? extends A> backwardFunction;
private FunctionBasedConverter(
Function<? super A, ? extends B> forwardFunction,
Function<? super B, ? extends A> backwardFunction) {
this.forwardFunction = checkNotNull(forwardFunction);
Reported by PMD.