Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/scripts/generate-quality-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,22 @@ def _is_exempt(f: Finding) -> bool:
"SimplifyBooleanReturns",
"UnusedLocalVariable",
"UnnecessaryConstructor",
"UnnecessaryImport"
"UnnecessaryImport",
"AvoidStringBufferField",
"LogicInversion",
"DefaultLabelNotLastInSwitchStmt",
"SingularField",
"InstantiationToGetClass",
"UnnecessaryModifier",
"FinalFieldCouldBeStatic",
"AvoidInstanceofChecksInCatchClause",
"AvoidUsingOctalValues",
"NonThreadSafeSingleton",
"ComparisonWithNaN",
"DontUseFloatTypeForLoopIndices",
"MissingStaticMethodInNonInstantiatableClass",
"OverrideBothEqualsAndHashcode",
"UnnecessarySemicolon"
}
violations = [f for f in pmd.findings if f.rule in forbidden_pmd_rules]
if violations:
Expand Down
3 changes: 1 addition & 2 deletions CodenameOne/src/com/codename1/ads/InnerActive.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class InnerActive extends AdsService { // PMD Fix: UnusedPrivateField rem

private static final String protocolVersion = "Sm2m-1.5.3";
private static boolean testAds = true;
private final String REQUEST_URL = "http://m2m1.inner-active.com/simpleM2M/clientRequestHtmlAd";
private static final String REQUEST_URL = "http://m2m1.inner-active.com/simpleM2M/clientRequestHtmlAd";
//Distribution channel ID
private int po = 559;
private String os;
Expand Down Expand Up @@ -160,7 +160,6 @@ public boolean equals(Object o) {
return super.equals(o) &&
po == that.po &&
banner == that.banner &&
REQUEST_URL.equals(that.REQUEST_URL) &&
(os == null ? that.os == null : os.equals(that.os)) &&
(hid == null ? that.hid == null : hid.equals(that.hid));
}
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/annotations/Async.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
* @author egor
*/
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass")
public final class Async {

/**
Expand Down
4 changes: 1 addition & 3 deletions CodenameOne/src/com/codename1/charts/compat/PathMeasure.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@
public class PathMeasure {

private final GeneralPath path;
private final boolean forceClosed;

public PathMeasure(GeneralPath p, boolean b) {
path = p;
forceClosed = b;
if (forceClosed && path != null) {
if (b && path != null) {
path.closePath();
}
}
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/components/Accordion.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void expand(Component body) {
if (autoClose) {
for (Component cc : this) {
AccordionContent c = (AccordionContent) cc;
c.openClose(!(body == c.body));
c.openClose(body != c.body);
}
} else {
for (Component cc : this) {
Expand Down
3 changes: 1 addition & 2 deletions CodenameOne/src/com/codename1/components/Ads.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,7 @@ public String[] getPropertyNames() {
*/
@Override
public Class[] getPropertyTypes() {
Class c = new String[0].getClass();
return new Class[]{String.class, Integer.class, String.class, String.class, String.class, String.class, c};
return new Class[]{String.class, Integer.class, String.class, String.class, String.class, String.class, String.class};
}

/**
Expand Down
1 change: 0 additions & 1 deletion CodenameOne/src/com/codename1/facebook/FaceBookAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,6 @@ public GetPostActionListener(Post post, ActionListener<NetworkEvent> callback) {
@Override
public void actionPerformed(NetworkEvent evt) {
final Object val = evt.getMetaData();
;
if (val instanceof Vector) {
final Vector v = (Vector) val;
final Object o = v.elementAt(0);
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/facebook/ui/LikeButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public String[] getPropertyNames() {
*/
@Override
public Class[] getPropertyTypes() {
return new Class[]{String.class, String.class, String.class, String.class, new String[0].getClass()};
return new Class[]{String.class, String.class, String.class, String.class, String.class};
}

/**
Expand Down
24 changes: 4 additions & 20 deletions CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,44 +223,28 @@ private static int round(double d) {
* This is a temporary workaround for an XMLVM Bug!
*/
public static Class getStringArrayClass() {
try {
return String[].class;
} catch (Throwable t) {
return new String[0].getClass();
}
return String[].class;
}

/**
* This is a temporary workaround for an XMLVM Bug!
*/
public static Class getStringArray2DClass() {
try {
return String[][].class;
} catch (Throwable t) {
return new String[1][].getClass();
}
return String[][].class;
}

/**
* This is a temporary workaround for an XMLVM Bug!
*/
public static Class getImageArrayClass() {
try {
return Image[].class;
} catch (Throwable t) {
return new Image[0].getClass();
}
return Image[].class;
}

/**
* This is a temporary workaround for an XMLVM Bug!
*/
public static Class getObjectArrayClass() {
try {
return Object[].class;
} catch (Throwable t) {
return new Object[0].getClass();
}
return Object[].class;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/io/JSONSanitizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ final class JSONSanitizer {
* If {@code null}, then no unclean constructs have been found in
* {@code jsonish} yet.
*/
@SuppressWarnings("PMD.AvoidStringBufferField")
private StringBuilder sanitizedJson;
/**
* The length of the prefix of {@link #jsonish} that has been written onto
Expand Down Expand Up @@ -236,7 +237,7 @@ private static boolean canonicalizeNumber(
if (fractionEnd == sanEnd) {
expStart = expEnd = sanEnd;
} else {
if (!('e' == (sanitizedJson.charAt(fractionEnd) | 32))) {
if ('e' != (sanitizedJson.charAt(fractionEnd) | 32)) {
throw new RuntimeException("AssertionError: 'e' == (sanitizedJson.charAt(fractionEnd) | 32))");
}
expStart = fractionEnd + 1;
Expand Down
9 changes: 8 additions & 1 deletion CodenameOne/src/com/codename1/io/NetworkManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public void removeErrorListener(ActionListener<NetworkEvent> e) {
*
* @param al action listener
*/
public final void addProgressListener(ActionListener<NetworkEvent> al) {
public void addProgressListener(ActionListener<NetworkEvent> al) {
if (progressListeners == null) {
progressListeners = new EventDispatcher();
progressListeners.setBlocking(false);
Expand Down Expand Up @@ -1076,5 +1076,12 @@ public boolean equals(Object o) {
return this == o;
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (aps != null ? aps.hashCode() : 0);
result = 31 * result + currentAP;
return result;
}
}
}
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/io/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ public static void readFully(InputStream i, byte b[]) throws IOException {
* input stream does not support reading after close, or
* another I/O error occurs.
*/
public static final void readFully(InputStream i, byte b[], int off, int len) throws IOException {
public static void readFully(InputStream i, byte b[], int off, int len) throws IOException {
if (len < 0) {
throw new IndexOutOfBoundsException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class DeflaterOutputStream extends FilterOutputStream {

protected static final int DEFAULT_BUFSIZE = 512;
protected final Deflater deflater;
private final byte[] buf1 = new byte[1];
protected byte[] buffer;
protected boolean mydeflater = false;
private boolean closed = false;
Expand Down Expand Up @@ -78,8 +77,7 @@ public DeflaterOutputStream(OutputStream out,

@Override
public void write(int b) throws IOException {
buf1[0] = (byte) (b & 0xff);
write(buf1, 0, 1);
write(new byte[] {(byte) (b & 0xff)}, 0, 1);
}

@Override
Expand Down
126 changes: 63 additions & 63 deletions CodenameOne/src/com/codename1/io/gzip/InfBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,46 +401,15 @@ int proc(int r) {
case DTREE:
while (true) {
t = table;
if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) {
break;
}

int[] h;
int i;
int j;
int c;
if (index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) {
int[] h;
int i;
int j;
int c;

t = bb[0];

while (k < (t)) {
if (n != 0) {
r = Z_OK;
} else {
bitb = b;
bitk = k;
z.availIn = n;
z.totalIn += p - z.nextInIndex;
z.nextInIndex = p;
write = q;
return inflateFlush(r);
}
n--;
b |= (z.nextIn[p++] & 0xff) << k;
k += 8;
}

t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1];
c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2];

if (c < 16) {
b >>>= (t);
k -= (t);
blens[index++] = c;
} else { // c == 16..18
i = c == 18 ? 7 : c - 14;
j = c == 18 ? 11 : 3;
t = bb[0];

while (k < (t + i)) {
while (k < (t)) {
if (n != 0) {
r = Z_OK;
} else {
Expand All @@ -457,36 +426,67 @@ int proc(int r) {
k += 8;
}

b >>>= (t);
k -= (t);
t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1];
c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2];

if (c < 16) {
b >>>= (t);
k -= (t);
blens[index++] = c;
} else { // c == 16..18
i = c == 18 ? 7 : c - 14;
j = c == 18 ? 11 : 3;

while (k < (t + i)) {
if (n != 0) {
r = Z_OK;
} else {
bitb = b;
bitk = k;
z.availIn = n;
z.totalIn += p - z.nextInIndex;
z.nextInIndex = p;
write = q;
return inflateFlush(r);
}
n--;
b |= (z.nextIn[p++] & 0xff) << k;
k += 8;
}

j += (b & inflate_mask[i]);
b >>>= (t);
k -= (t);

b >>>= (i);
k -= (i);
j += (b & inflate_mask[i]);

i = index;
t = table;
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) {
blens = null;
mode = BAD;
z.msg = "invalid bit length repeat";
r = Z_DATA_ERROR;
b >>>= (i);
k -= (i);

bitb = b;
bitk = k;
z.availIn = n;
z.totalIn += p - z.nextInIndex;
z.nextInIndex = p;
write = q;
return inflateFlush(r);
}
i = index;
t = table;
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) {
blens = null;
mode = BAD;
z.msg = "invalid bit length repeat";
r = Z_DATA_ERROR;

c = c == 16 ? blens[i - 1] : 0;
do {
blens[i++] = c;
} while (--j != 0);
index = i;
bitb = b;
bitk = k;
z.availIn = n;
z.totalIn += p - z.nextInIndex;
z.nextInIndex = p;
write = q;
return inflateFlush(r);
}

c = c == 16 ? blens[i - 1] : 0;
do {
blens[i++] = c;
} while (--j != 0);
index = i;
}
} else {
break;
}
}

Expand Down
4 changes: 4 additions & 0 deletions CodenameOne/src/com/codename1/io/gzip/Inflate.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ final class Inflate {
static final private int FLAGS = 23;
static private final byte[] mark = {(byte) 0, (byte) 0, (byte) 0xff, (byte) 0xff};
private final ZStream z;

@SuppressWarnings("PMD.SingularField")
private final byte[] crcbuf = new byte[4];
int mode; // current inflate mode
// mode dependent information
Expand All @@ -93,6 +95,8 @@ final class Inflate {
int wbits; // log2(window size) (8..15, defaults to 15)
InfBlocks blocks; // current inflate_blocks state
GZIPHeader gheader = null;

@SuppressWarnings("PMD.SingularField")
private int flags;
private int need_bytes = -1;
private java.io.ByteArrayOutputStream tmp_string = null;
Expand Down
4 changes: 2 additions & 2 deletions CodenameOne/src/com/codename1/io/tar/TarEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ public void extractTarHeader(String entryName) {
header.name = new StringBuffer(name);

if (fileSystem.isDirectory(file)) {
header.mode = 040755;
header.mode = 0x41ed;
header.linkFlag = TarHeader.LF_DIR;
if (header.name.charAt(header.name.length() - 1) != '/') {
header.name.append("/");
}
header.size = 0;
} else {
header.size = fileSystem.getLength(file);
header.mode = 0100644;
header.mode = 0x81a4;
header.linkFlag = TarHeader.LF_NORMAL;
}

Expand Down
Loading
Loading