Skip to content

Commit 49c8c86

Browse files
authored
Fixed PMD P2 issues and UseUtilityClass, EmptyCatchBlock (#4465)
1 parent 00c88c3 commit 49c8c86

44 files changed

Lines changed: 84 additions & 37 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/scripts/generate-quality-report.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,10 @@ def _is_exempt(f: Finding) -> bool:
924924
"UselessQualifiedThis",
925925
"AvoidBranchingStatementAsLastInLoop",
926926
"AvoidUsingVolatile",
927-
"DoNotCallGarbageCollectionExplicitly"
927+
"DoNotCallGarbageCollectionExplicitly",
928+
"SuspiciousEqualsMethodName",
929+
"UseUtilityClass",
930+
"EmptyCatchBlock"
928931
}
929932
violations = [f for f in pmd.findings if f.rule in forbidden_pmd_rules]
930933
if violations:

CodenameOne/src/com/codename1/capture/Capture.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
*
5050
* @author Chen
5151
*/
52-
public class Capture {
52+
public abstract class Capture {
5353

5454
/**
5555
* Returns true if the device has camera false otherwise.

CodenameOne/src/com/codename1/charts/util/ColorUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* @author shannah
2828
*/
29-
public class ColorUtil {
29+
public abstract class ColorUtil {
3030
public static final int LTGRAY = IColor.LightGray.argb;
3131
public static final int BLUE = IColor.Blue.argb;
3232
public static final int BLACK = IColor.Black.argb;

CodenameOne/src/com/codename1/charts/views/PkgUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
/**
2828
* @author shannah
2929
*/
30-
class PkgUtils {
30+
final class PkgUtils {
31+
private PkgUtils() {}
3132
static Rectangle2D makeRect(double x1, double y1, double x2, double y2) {
3233
return new Rectangle2D(x1, y1, x2 - x1, y2 - y1);
3334
}

CodenameOne/src/com/codename1/compat/java/util/Objects.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@
3737
* @author shannah
3838
*/
3939
public final class Objects {
40+
private Objects() {}
41+
4042
/**
4143
* Returns true if the arguments are equal to each other and false otherwise. Consequently, if both arguments are null, true is returned and if exactly one argument is null, false is returned. Otherwise, equality is determined by using the equals method of the first argument.
4244
*
4345
* @param a
4446
* @param b
4547
* @return
4648
*/
49+
@SuppressWarnings("PMD.SuspiciousEqualsMethodName")
4750
public static boolean equals(Object a, Object b) {
4851
if (a == b) { //NOPMD CompareObjectsWithEquals
4952
return true;

CodenameOne/src/com/codename1/components/MasterDetail.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
* @author Shai Almog
4242
* @deprecated this was a half baked idea that made it into the public API
4343
*/
44-
public class MasterDetail {
44+
public final class MasterDetail {
45+
private MasterDetail() {}
46+
4547
/**
4648
* @deprecated this was a half baked idea that made it into the public API
4749
*/

CodenameOne/src/com/codename1/io/ConnectionRequest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,7 @@ private Date parseDate(String date, String... formats) {
14021402
SimpleDateFormat sdf = new SimpleDateFormat(format);
14031403
return sdf.parse(date);
14041404
} catch (Throwable t) {
1405+
Log.e(t);
14051406
}
14061407
}
14071408
return null;

CodenameOne/src/com/codename1/io/FileSystemStorage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public void delete(String file) {
160160
* @param file file to delete
161161
* @param retryCount the number of times to retry
162162
*/
163+
@SuppressWarnings("PMD.EmptyCatchBlock")
163164
public void deleteRetry(final String file, final int retryCount) {
164165
try {
165166
Util.getImplementation().deleteFile(file);

CodenameOne/src/com/codename1/io/JSONParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public static void parse(Reader i, JSONParseCallback callback) throws IOExceptio
366366
callback.keyValue(lastKey, currentToken.toString());
367367
lastKey = null;
368368
}
369-
} catch (NumberFormatException err) {
369+
} catch (NumberFormatException err) { // NOPMD EmptyCatchBlock
370370
// this isn't a number!
371371
}
372372
}
@@ -404,7 +404,7 @@ public static void parse(Reader i, JSONParseCallback callback) throws IOExceptio
404404
callback.keyValue(lastKey, currentToken.toString());
405405
lastKey = null;
406406
}
407-
} catch (NumberFormatException err) {
407+
} catch (NumberFormatException err) { // NOPMD EmptyCatchBlock
408408
// this isn't a number!
409409
}
410410
}

CodenameOne/src/com/codename1/io/Preferences.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
* @author Shai Almog
4848
* @author Miguel Mu\u00f1oz
4949
*/
50-
public class Preferences {
50+
public final class Preferences {
5151
private static final HashMap<String, ArrayList<PreferenceListener>> listenerMap = new HashMap<String, ArrayList<PreferenceListener>>();
5252
private static Hashtable<String, Object> p;
5353
private static String preferencesLocation = "CN1Preferences";
5454

5555
/**
5656
* Block instantiation of preferences
5757
*/
58-
Preferences() {
58+
private Preferences() {
5959
}
6060

6161
/**

0 commit comments

Comments
 (0)