Enable PMD rule PrimitiveWrapperInstantiation and fix violations

This commit is contained in:
Manuel Fuhr 2023-05-09 22:13:57 +02:00
parent 7a6d3bd9d9
commit 28f205c1ad
12 changed files with 20 additions and 21 deletions

View file

@ -29,7 +29,7 @@ public class CompactMapTest {
for (int i = 0; i < mapsize; i++) {
String s = "" + i;
long k = mapsize < 10 ? i : rand.nextInt(20000);
Long KK = new Long(k);
Long KK = k;
if (!hmap.containsKey(KK)) {
hmap.put(KK, s);
@ -44,7 +44,7 @@ public class CompactMapTest {
cmap_fast = new FrozenLongMap<>(cmap_fast);
}
long k = mapsize < 10 ? i : rand.nextInt(20000);
Long KK = new Long(k);
Long KK = k;
String s = hmap.get(KK);
boolean contained = hmap.containsKey(KK);

View file

@ -28,7 +28,7 @@ public class CompactSetTest {
for (int i = 0; i < setsize; i++) {
long k = setsize < 10 ? i : rand.nextInt(20000);
Long KK = new Long(k);
Long KK = k;
if (!hset.contains(KK)) {
hset.add(KK);
@ -43,7 +43,7 @@ public class CompactSetTest {
cset_fast = new FrozenLongSet(cset_fast);
}
long k = setsize < 10 ? i : rand.nextInt(20000);
Long KK = new Long(k);
Long KK = k;
boolean contained = hset.contains(KK);
Assert.assertEquals("contains missmatch (slow)", contained, cset_slow.contains(k));

View file

@ -22,15 +22,15 @@ public class DenseLongMapTest {
for (int i = 0; i < mapsize; i++) {
int value = i % 255;
long k = (long) (rand.nextDouble() * keyrange);
Long KK = new Long(k);
Long KK = k;
hmap.put(KK, new Integer(value));
hmap.put(KK, value);
dmap.put(k, value); // duplicate puts allowed!
}
for (int i = 0; i < trycount; i++) {
long k = (long) (rand.nextDouble() * keyrange);
Long KK = new Long(k);
Long KK = k;
Integer VV = hmap.get(KK);
int hvalue = VV == null ? -1 : VV.intValue();
int dvalue = dmap.getInt(k);
@ -53,12 +53,12 @@ public class DenseLongMapTest {
DenseLongMap dmap = new DenseLongMap(512);
for (int i = 0; i < mapputs; i++) {
long k = (long) (rand.nextDouble() * keyrange);
hset.add(new Long(k));
hset.add(k);
dmap.put(k, 0);
}
for (int i = 0; i < trycount; i++) {
long k = (long) (rand.nextDouble() * keyrange);
boolean hcontains = hset.contains(new Long(k));
boolean hcontains = hset.contains(k);
boolean dcontains = dmap.getInt(k) == 0;
if (hcontains != dcontains) {