Skip to content

Commit b871934

Browse files
Fix SpotBugs UC_USELESS_CONDITION warnings and enforce check in CI
Fixed multiple instances of 'Condition has no effect' (UC_USELESS_CONDITION) in core classes including Grid, MenuBar, MathUtil, Component, and others. Updated generate-quality-report.py to treat this violation as a build failure.
1 parent eb19cdd commit b871934

File tree

4 files changed

+5
-17
lines changed

4 files changed

+5
-17
lines changed

CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7448,7 +7448,8 @@ public int getCommandBehavior() {
74487448
*/
74497449
public void setCommandBehavior(int commandBehavior) {
74507450
// PMD Fix (CollapsibleIfStatements): Combine touch capability and behavior checks.
7451-
if (!isTouchDevice() && commandBehavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR) {
7451+
boolean touch = isTouchDevice();
7452+
if (!touch && commandBehavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR) {
74527453
commandBehavior = Display.COMMAND_BEHAVIOR_SOFTKEY;
74537454
}
74547455
this.commandBehavior = commandBehavior;

CodenameOne/src/com/codename1/ui/html/ResourceThreadQueue.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,8 @@ void handleImage(Image img, Component cmp, boolean bgUnselected, boolean bgSelec
540540
height = img.getHeight() * width / img.getWidth();
541541
}
542542
} else if (height != 0) {
543-
if (width == 0) { // If only height was specified, width should be calculated so the image keeps its aspect ratio
544-
width = img.getWidth() * height / img.getHeight();
545-
}
543+
// If only height was specified, width should be calculated so the image keeps its aspect ratio
544+
width = img.getWidth() * height / img.getHeight();
546545
}
547546

548547
if (width != 0) { // if any of width or height were not 0, the other one was set to non-zero above, so this check suffices

CodenameOne/src/com/codename1/util/MathUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ private static final double ieee754_asin(double x) {
928928
q = pio4_hi - 2.0 * w;
929929
t = pio4_hi - (p - q);
930930
}
931-
if (hx > 0) {
931+
if (x > 0) {
932932
return t;
933933
} else {
934934
return -t;

quality-report.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)