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
5 changes: 4 additions & 1 deletion .github/scripts/generate-quality-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,10 @@ def _is_exempt(f: Finding) -> bool:
"UselessQualifiedThis",
"AvoidBranchingStatementAsLastInLoop",
"AvoidUsingVolatile",
"DoNotCallGarbageCollectionExplicitly"
"DoNotCallGarbageCollectionExplicitly",
"SuspiciousEqualsMethodName",
"UseUtilityClass",
"EmptyCatchBlock"
}
violations = [f for f in pmd.findings if f.rule in forbidden_pmd_rules]
if violations:
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/capture/Capture.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*
* @author Chen
*/
public class Capture {
public abstract class Capture {

/**
* Returns true if the device has camera false otherwise.
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/charts/util/ColorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @author shannah
*/
public class ColorUtil {
public abstract class ColorUtil {
public static final int LTGRAY = IColor.LightGray.argb;
public static final int BLUE = IColor.Blue.argb;
public static final int BLACK = IColor.Black.argb;
Expand Down
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/charts/views/PkgUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
/**
* @author shannah
*/
class PkgUtils {
final class PkgUtils {
private PkgUtils() {}
static Rectangle2D makeRect(double x1, double y1, double x2, double y2) {
return new Rectangle2D(x1, y1, x2 - x1, y2 - y1);
}
Expand Down
3 changes: 3 additions & 0 deletions CodenameOne/src/com/codename1/compat/java/util/Objects.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
* @author shannah
*/
public final class Objects {
private Objects() {}

/**
* 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.
*
* @param a
* @param b
* @return
*/
@SuppressWarnings("PMD.SuspiciousEqualsMethodName")
public static boolean equals(Object a, Object b) {
if (a == b) { //NOPMD CompareObjectsWithEquals
return true;
Expand Down
4 changes: 3 additions & 1 deletion CodenameOne/src/com/codename1/components/MasterDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
* @author Shai Almog
* @deprecated this was a half baked idea that made it into the public API
*/
public class MasterDetail {
public final class MasterDetail {
private MasterDetail() {}

/**
* @deprecated this was a half baked idea that made it into the public API
*/
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/io/ConnectionRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,7 @@ private Date parseDate(String date, String... formats) {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.parse(date);
} catch (Throwable t) {
Log.e(t);
}
}
return null;
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/io/FileSystemStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public void delete(String file) {
* @param file file to delete
* @param retryCount the number of times to retry
*/
@SuppressWarnings("PMD.EmptyCatchBlock")
public void deleteRetry(final String file, final int retryCount) {
try {
Util.getImplementation().deleteFile(file);
Expand Down
4 changes: 2 additions & 2 deletions CodenameOne/src/com/codename1/io/JSONParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public static void parse(Reader i, JSONParseCallback callback) throws IOExceptio
callback.keyValue(lastKey, currentToken.toString());
lastKey = null;
}
} catch (NumberFormatException err) {
} catch (NumberFormatException err) { // NOPMD EmptyCatchBlock
// this isn't a number!
}
}
Expand Down Expand Up @@ -404,7 +404,7 @@ public static void parse(Reader i, JSONParseCallback callback) throws IOExceptio
callback.keyValue(lastKey, currentToken.toString());
lastKey = null;
}
} catch (NumberFormatException err) {
} catch (NumberFormatException err) { // NOPMD EmptyCatchBlock
// this isn't a number!
}
}
Expand Down
4 changes: 2 additions & 2 deletions CodenameOne/src/com/codename1/io/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
* @author Shai Almog
* @author Miguel Mu\u00f1oz
*/
public class Preferences {
public final class Preferences {
private static final HashMap<String, ArrayList<PreferenceListener>> listenerMap = new HashMap<String, ArrayList<PreferenceListener>>();
private static Hashtable<String, Object> p;
private static String preferencesLocation = "CN1Preferences";

/**
* Block instantiation of preferences
*/
Preferences() {
private Preferences() {
}

/**
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/io/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ private <K> void selectProperties(Hashtable<K, Object> selectProperties, final b
* handling.
*/
@Deprecated
@SuppressWarnings("PMD.EmptyCatchBlock")
public void save(OutputStream out, String comment) {
try {
store(out, comment);
Expand Down
3 changes: 1 addition & 2 deletions CodenameOne/src/com/codename1/io/Socket.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,10 @@ private void throwEOF() throws IOException {
}
}

// [ddyer 12/2015]
// try to read some data into the buffer if we think there is some
// available, but don't wait if there is not. This is used to get
// additional data for a read that has more room in it's buffer.
//
@SuppressWarnings("PMD.EmptyCatchBlock")
private boolean getDataIfAvailable() {
try {
if (available() > 0) {
Expand Down
12 changes: 4 additions & 8 deletions CodenameOne/src/com/codename1/io/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
*
* @author Shai Almog
*/
public class Util {
public final class Util {
private static final Random downloadUrlSafelyRandom = new Random(System.currentTimeMillis());
private static CodenameOneImplementation implInstance;
private static Hashtable externalizables = new Hashtable();
Expand Down Expand Up @@ -110,6 +110,7 @@ public static void setIgnorCharsWhileEncoding(String s) {
ignoreCharsWhenEncoding = s;
}

private Util() {}

/**
* Helper to get a reader from an input stream with UTF-8 encoding
Expand Down Expand Up @@ -279,17 +280,12 @@ public static void writeStringToFile(File file, String contents, String charset)
if (charset == null) {
charset = "UTF-8";
}
OutputStream output = null;
OutputStream output = null; // NOPMD CloseResource - false positive
try {
output = FileSystemStorage.getInstance().openOutputStream(file.getAbsolutePath());
output.write(contents.getBytes(charset));
} finally {
if (output != null) {
try {
output.close();
} catch (Exception ex) {
}
}
cleanup(output);
}
}

Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/io/WebServiceProxyCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @author Shai Almog
*/
public class WebServiceProxyCall {
public abstract class WebServiceProxyCall {
/**
* Web protocol argument/return type
*/
Expand Down
3 changes: 3 additions & 0 deletions CodenameOne/src/com/codename1/io/gzip/GZIPInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

package com.codename1.io.gzip;

import com.codename1.io.Log;

import java.io.IOException;
import java.io.InputStream;

Expand Down Expand Up @@ -137,6 +139,7 @@ private int fill(byte[] buf) {
try {
i = in.read(buf, n, buf.length - n);
} catch (IOException e) {
Log.e(e);
}
if (i == -1) {
break;
Expand Down
2 changes: 2 additions & 0 deletions CodenameOne/src/com/codename1/io/gzip/JZlib.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public static String version() {
return version;
}

private JZlib() {}

/**
* @deprecated Use {@link #adler32Combine(long, long, long)}.
*/
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/io/rest/Rest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Chen Fishbein
*/
public class Rest {
public abstract class Rest {

/**
* Creates a GET request builder
Expand Down
4 changes: 3 additions & 1 deletion CodenameOne/src/com/codename1/io/tar/Octal.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
/**
* @author Kamran Zafar
*/
public class Octal {
public final class Octal {

private Octal() {}

/**
* Parse an octal string from a header buffer. This is used for the file
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/io/tar/TarEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public TarEntry(byte[] headerBuf) {
this.parseTarHeader(headerBuf);
}

@SuppressWarnings("PMD.SuspiciousEqualsMethodName")
public boolean equals(TarEntry it) {
return this.header.name.toString().equals(it.header.name.toString());
}
Expand Down
4 changes: 3 additions & 1 deletion CodenameOne/src/com/codename1/io/tar/TarUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
/**
* @author Kamran
*/
public class TarUtils {
public final class TarUtils {
private TarUtils() {}

/**
* Determines the tar file size of the given folder/file path
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private synchronized Map<String, Long> getExpiryTimes(boolean reload) {
try {
expiryTimes = (Map) Storage.getInstance().readObject(EXPIRATIONS_KEY);
} catch (Throwable t) {
Log.e(t);
}
if (expiryTimes == null) {
expiryTimes = new HashMap<String, Long>();
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/media/MediaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* <script src="https://gist.github.com/jsfan3/419f44a9ad49d8fc1c1e3e325d1e5422.js"></script>
* <img src="https://user-images.githubusercontent.com/1997316/78480286-02131b00-7735-11ea-8a70-5ca5512e7d92.png" alt="Demonstrates capturing of audio files and their playback using the Codename One APIs Media, MediaManager and MediaRecorderBuilder" />
*/
public class MediaManager {
public abstract class MediaManager {

/**
* A static map of audio buffers. These can be used to register an Audio buffer to receive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @author shannah
* @deprecated for internal use only.
*/
class RemoteControlCallback {
abstract class RemoteControlCallback {
private static final RemoteControlListener nullListener = new RemoteControlListener();

private static RemoteControlListener l() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*
* @author Eric Coolman
*/
class EvaluatorFactory {
abstract class EvaluatorFactory {
/**
* Construct an evaluator for a given predicate expression.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static String valueToString(Object value, int indentFactor, int indent) {
if (value instanceof String) {
return quote((String) value);
}
} catch (Exception e) {
} catch (Exception e) { // NOPMD EmptyCatchBlock
/* forget about it */
}
if (value instanceof Float || value instanceof Double ||
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/properties/SQLMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ public SelectBuilder orderBy(PropertyBase property, boolean ascending) {
* @param property the property
* @return the builder instance
*/
@SuppressWarnings("PMD.SuspiciousEqualsMethodName")
public SelectBuilder equals(PropertyBase property) {
return new SelectBuilder(property, " = ", null, null, this);
}
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/social/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ public void validateToken() throws IOException {
Preferences.set(getClass().getName() + "Token", getAccessToken().getToken());
return;
} catch (Throwable t) {
Log.e(t);
}
}

Expand Down
3 changes: 3 additions & 0 deletions CodenameOne/src/com/codename1/ui/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.codename1.components.InfiniteProgress;
import com.codename1.components.InteractionDialog;
import com.codename1.impl.CodenameOneImplementation;
import com.codename1.io.Log;
import com.codename1.ui.TextSelection.TextSelectionSupport;
import com.codename1.ui.animations.Animation;
import com.codename1.ui.animations.ComponentAnimation;
Expand Down Expand Up @@ -575,6 +576,7 @@ public static Dimension parsePreferredSize(String preferredSize, Dimension baseS
}
}
} catch (Throwable t) {
Log.e(t);
}

try {
Expand All @@ -586,6 +588,7 @@ public static Dimension parsePreferredSize(String preferredSize, Dimension baseS
baseSize.setHeight(Integer.parseInt(hStr));
}
} catch (Throwable t) {
Log.e(t);
}
return baseSize;
}
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/ui/LeadUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @author Steve Hannah
* @since 7.0
*/
class LeadUtil {
abstract class LeadUtil {

/**
* Gets the lead parent for a component, or the component itself if there is
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/ui/Transform.java
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ public Transform copy() {

}

@SuppressWarnings("PMD.SuspiciousEqualsMethodName")
public boolean equals(Transform t2) {
if (type == TYPE_IDENTITY && t2.type == TYPE_IDENTITY) {
return true;
Expand Down
5 changes: 3 additions & 2 deletions CodenameOne/src/com/codename1/ui/geom/GeneralPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -1805,8 +1805,9 @@ static class EPoint {
/**
* @author shannah
*/
static class ShapeUtil {

final static class ShapeUtil {
private ShapeUtil() {
}

/**
* Rectangle cross segment
Expand Down
3 changes: 3 additions & 0 deletions CodenameOne/src/com/codename1/ui/html/HTMLComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,7 @@ void applyAllCSS() {
*
* @param head The HEAD element of the document
*/
@SuppressWarnings("PMD.EmptyCatchBlock")
private void checkRedirect(HTMLElement head) {
if (head != null) {
HTMLElement meta = head.getFirstChildByTagId(HTMLElement.TAG_META);
Expand Down Expand Up @@ -2425,6 +2426,7 @@ private void handleImage(HTMLElement imgElement, int align, Command cmd) {
*
* @param areaTag The AREA tag
*/
@SuppressWarnings("PMD.EmptyCatchBlock")
private void handleImageMapArea(HTMLElement areaTag) {
if (curImageMap != null) {
String shape = areaTag.getAttributeById(HTMLElement.ATTR_SHAPE);
Expand Down Expand Up @@ -3993,6 +3995,7 @@ public String setPropertyValue(String name, Object value) {
* @param counterStr The counter-increment/reset property value which is the string counter name followed optionally by the factor by which to increment or the value to reset to
* @param reset true to reset, false to increment
*/
@SuppressWarnings("PMD.EmptyCatchBlock")
void incCounter(String counterStr, boolean reset) {
counterStr = counterStr.trim();
int value = reset ? 0 : 1; // 0 is the default value to reset to, while 1 is the default increment step
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/ui/html/HTMLUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static String convertHTMLCharEntity(String charEntity) {
* @param userDefinedCharEntities A hashtable containing (String,int) dentoing the char entity name and its unicode
* @return A string containing a single char, or the original char entity string (with &amp; and ;) if the char entity couldn't be resolved
*/
@SuppressWarnings("PMD.EmptyCatchBlock")
public static String convertCharEntity(String charEntity, boolean lookupHTMLentities, Hashtable userDefinedCharEntities) {
int charCode = -1;
if (charEntity.startsWith("#")) { //numbered char entity
Expand Down
Loading
Loading