Skip to content

Commit ce41dd3

Browse files
committed
Fixed compilation issues and hardened build
1 parent 7e5e039 commit ce41dd3

File tree

4 files changed

+35
-79
lines changed

4 files changed

+35
-79
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,31 @@ def main() -> None:
787787
"EQ_GETCLASS_AND_CLASS_CONSTANT",
788788
"EQ_UNUSUAL",
789789
"ES_COMPARING_STRINGS_WITH_EQ",
790-
"FI_EMPTY"
790+
"FI_EMPTY",
791+
"ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD",
792+
"DM_GC",
793+
"CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE",
794+
"BC_UNCONFIRMED_CAST",
795+
"BC_UNCONFIRMED_CAST_OF_RETURN_VALUE",
796+
"CN_IDIOM_NO_SUPER_CALL",
797+
"DM_BOOLEAN_CTOR",
798+
"DM_CONVERT_CASE",
799+
"DM_EXIT",
800+
"EI_EXPOSE_REP",
801+
"EI_EXPOSE_REP2",
802+
"EI_EXPOSE_STATIC_REP2",
803+
"EQ_COMPARETO_USE_OBJECT_EQUALS",
804+
"MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
805+
"MS_EXPOSE_REP",
806+
"NM_CONFUSING",
807+
"NO_NOTIFY_NOT_NOTIFYALL",
808+
"NP_BOOLEAN_RETURN_NULL",
809+
"PZLA_PREFER_ZERO_LENGTH_ARRAYS",
810+
"REFLC_REFLECTION_MAY_INCREASE_ACCESSIBILITY_OF_CLASS",
811+
"UI_INHERITANCE_UNSAFE_GETRESOURCE",
812+
"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD",
813+
"UW_UNCOND_WAIT",
814+
"SIC_INNER_SHOULD_BE_STATIC_ANON"
791815
}
792816
violations = [
793817
f for f in spotbugs.findings

CodenameOne/src/com/codename1/testing/TestUtils.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,26 +1144,6 @@ private static void assertRelativeErrorExceeded(double expected, double actual,
11441144
}
11451145
}
11461146

1147-
private static void assertRelativeErrorNotExceeded(float expected, float actual, double maxRelativeError) {
1148-
if (verbose) {
1149-
log("assertRelativeErrorNotExceeded(" + expected + ", " + actual + ", " + maxRelativeError + ")");
1150-
}
1151-
double relative_error = Math.abs((expected - actual) / actual) * 100;
1152-
if (relative_error > maxRelativeError) {
1153-
assertBool(false);
1154-
}
1155-
}
1156-
1157-
private static void assertRelativeErrorNotExceeded(double expected, double actual, double maxRelativeError) {
1158-
if (verbose) {
1159-
log("assertRelativeErrorNotExceeded(" + expected + ", " + actual + ", " + maxRelativeError + ")");
1160-
}
1161-
double relative_error = Math.abs((expected - actual) / actual) * 100;
1162-
if (relative_error > maxRelativeError) {
1163-
assertBool(false);
1164-
}
1165-
}
1166-
11671147
private static void assertRelativeErrorNotExceeded(float expected, float actual, double maxRelativeError, String errorMessage) {
11681148
if (verbose) {
11691149
log("assertRelativeErrorNotExceeded(" + expected + ", " + actual + ", " + maxRelativeError + ", " + errorMessage + ")");

CodenameOne/src/com/codename1/ui/BrowserComponent.java

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,6 @@ public static boolean isNativeBrowserSupported() {
290290
return Display.impl.isNativeBrowserComponentSupported();
291291
}
292292

293-
private static boolean isNumber(Object o) {
294-
if (o == null) {
295-
return false;
296-
}
297-
Class c = o.getClass();
298-
return c == Integer.class || c == Double.class || c == Float.class || c == Long.class || c == Short.class;
299-
}
300293

301294
/**
302295
* Injects parameters into a Javascript string expression. This will quote strings properly. The
@@ -548,13 +541,6 @@ private SuccessCallback<JSRef> popReturnValueCallback(int id) {
548541
return null;
549542
}
550543

551-
private JSONParser returnValueParser() {
552-
if (returnValueParser == null) {
553-
returnValueParser = new JSONParser();
554-
}
555-
return returnValueParser;
556-
}
557-
558544
@Override
559545
protected void initComponent() {
560546
super.initComponent();
@@ -1698,6 +1684,11 @@ public enum JSType {
16981684
UNDEFINED("undefined"),
16991685
BOOLEAN("boolean");
17001686

1687+
// values() doesn't work great on iOS builds
1688+
private static final JSType[] values = {
1689+
OBJECT, FUNCTION, NUMBER, STRING, UNDEFINED, BOOLEAN
1690+
};
1691+
17011692
private final String typeOfValue;
17021693

17031694
JSType(String val) {
@@ -1708,26 +1699,13 @@ public enum JSType {
17081699
* Gets the corresponding JSType for the given string type.
17091700
*
17101701
* @param type The string type as returned by the typeof operator. Possible input values are 'object', 'function', 'number', 'boolean', and 'undefined'
1711-
* @return
1702+
* @return the enum corresponding to the type
17121703
*/
17131704
public static JSType get(String type) {
1714-
if ("object".equals(type)) {
1715-
return OBJECT;
1716-
}
1717-
if ("string".equals(type)) {
1718-
return JSType.STRING;
1719-
}
1720-
if ("number".equals(type)) {
1721-
return JSType.NUMBER;
1722-
}
1723-
if ("function".equals(type)) {
1724-
return JSType.FUNCTION;
1725-
}
1726-
if ("undefined".equals(type)) {
1727-
return JSType.UNDEFINED;
1728-
}
1729-
if ("boolean".equals(type)) {
1730-
return BOOLEAN;
1705+
for(JSType t : values) {
1706+
if(t.typeOfValue.equals(type)) {
1707+
return t;
1708+
}
17311709
}
17321710
return UNDEFINED;
17331711
}
@@ -1771,15 +1749,6 @@ public String getValue() {
17711749
return value;
17721750
}
17731751

1774-
/**
1775-
* Returns the type of the value
1776-
*
1777-
* @return
1778-
*/
1779-
private String getType() {
1780-
return type;
1781-
}
1782-
17831752
/**
17841753
* Returns the type of the value.
17851754
*

CodenameOne/src/com/codename1/ui/plaf/StyleParser.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -347,19 +347,6 @@ private static String getAlignmentString(Integer alignment) {
347347
return null;
348348
}
349349

350-
private static int getPixelValue(String val) {
351-
ScalarValue v = parseSingleTRBLValue(val);
352-
switch (v.getUnit()) {
353-
case Style.UNIT_TYPE_PIXELS:
354-
return (int) Math.round(v.getValue());
355-
case Style.UNIT_TYPE_DIPS:
356-
return Display.getInstance().convertToPixels((float) v.getValue());
357-
case Style.UNIT_TYPE_SCREEN_PERCENTAGE:
358-
return (int) Math.round(Display.getInstance().getDisplayWidth() * v.getValue() / 100.0);
359-
}
360-
return 0;
361-
}
362-
363350
private static float getMMValue(String val) {
364351
ScalarValue v = parseSingleTRBLValue(val);
365352
switch (v.getUnit()) {
@@ -623,10 +610,6 @@ private static Image getImage(Resources theme, String imageStr) {
623610
return im;
624611
}
625612

626-
static Integer parseTextDecoration(String decoration) {
627-
return null;
628-
}
629-
630613
private static FontInfo parseFontSize(FontInfo out, String arg) {
631614
arg = arg.trim();
632615
ScalarValue sizeVal = parseSingleTRBLValue(arg);

0 commit comments

Comments
 (0)