Skip to content

Commit 224bd73

Browse files
Fix remaining SpotBugs UC_USELESS_CONDITION warnings
Fixed multiple instances of 'Condition has no effect' (UC_USELESS_CONDITION) in core classes: * CodenameOne/src/com/codename1/util/MathUtil.java: Fixed bitwise shift logic in `ieee754_pow` (`>>>` to `>>`) to restore correct negative number handling. * CodenameOne/src/com/codename1/ui/MenuBar.java: Removed redundant `COMMAND_BEHAVIOR_ICS` check. * CodenameOne/src/com/codename1/ui/Component.java: Removed duplicate `!animateBackground` check. * CodenameOne/src/com/codename1/ui/ComponentGroup.java: Removed redundant `if (count > 1)` check. * CodenameOne/src/com/codename1/ui/html/CSSParser.java: Removed redundant whitespace check. * CodenameOne/src/com/codename1/ui/html/HTMLComponent.java: Removed redundant whitespace check. * CodenameOne/src/com/codename1/xml/XMLParser.java: Removed redundant whitespace check. * CodenameOne/src/com/codename1/ui/html/CSSEngine.java: Removed redundant whitespace check. * CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java: Refactored `setCommandBehavior` condition logic.
1 parent b871934 commit 224bd73

File tree

9 files changed

+15
-18
lines changed

9 files changed

+15
-18
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7447,10 +7447,10 @@ public int getCommandBehavior() {
74477447
* @param commandBehavior the commandBehavior to set
74487448
*/
74497449
public void setCommandBehavior(int commandBehavior) {
7450-
// PMD Fix (CollapsibleIfStatements): Combine touch capability and behavior checks.
7451-
boolean touch = isTouchDevice();
7452-
if (!touch && commandBehavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR) {
7453-
commandBehavior = Display.COMMAND_BEHAVIOR_SOFTKEY;
7450+
if (commandBehavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR) {
7451+
if (!isTouchDevice()) {
7452+
commandBehavior = Display.COMMAND_BEHAVIOR_SOFTKEY;
7453+
}
74547454
}
74557455
this.commandBehavior = commandBehavior;
74567456
notifyCommandBehavior(commandBehavior);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6542,7 +6542,7 @@ public boolean animate() {
65426542
}
65436543

65446544
if (!animateBackground && (destScrollY == -1 || destScrollY == scrollY) &&
6545-
!animateBackground && m == null && draggedMotionY == null &&
6545+
m == null && draggedMotionY == null &&
65466546
draggedMotionX == null && !dragActivated) {
65476547
tryDeregisterAnimated();
65486548
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,11 @@ private void updateUIIDs() {
151151
} else {
152152
Component c = getComponentAt(0);
153153
updateUIID(elementPrefix(c) + "First", c);
154-
if (count > 1) {
155-
c = getComponentAt(count - 1);
156-
updateUIID(elementPrefix(c) + "Last", c);
157-
for (int iter = 1; iter < count - 1; iter++) {
158-
c = getComponentAt(iter);
159-
updateUIID(elementPrefix(c), c);
160-
}
154+
c = getComponentAt(count - 1);
155+
updateUIID(elementPrefix(c) + "Last", c);
156+
for (int iter = 1; iter < count - 1; iter++) {
157+
c = getComponentAt(iter);
158+
updateUIID(elementPrefix(c), c);
161159
}
162160
}
163161
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,6 @@ public void addCommand(Command cmd) {
10561056
}
10571057
if (parent.getBackCommand() != cmd) {
10581058
if ((behavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK ||
1059-
behavior == Display.COMMAND_BEHAVIOR_ICS ||
10601059
behavior == Display.COMMAND_BEHAVIOR_SIDE_NAVIGATION)
10611060
&& parent.getTitle() != null && parent.getTitle().length() > 0) {
10621061
synchronizeCommandsWithButtonsInBackbutton();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ private void setNowrapRecursive(final HTMLElement element) {
807807
String newText = "";
808808
for (int c = 0; c < text.length(); c++) {
809809
char ch = text.charAt(c);
810-
if ((ch == ' ') || (ch == 10) || (ch == 13) || (ch == '\t') || (ch == '\n')) {
810+
if ((ch == ' ') || (ch == '\n') || (ch == '\r') || (ch == '\t')) {
811811
if (!word.equals("")) {
812812
newText += word + " ";
813813
word = "";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static void setCSSSupportedMediaTypes(String[] supportedMediaTypes) {
8787
* @return true if the character is a white space, false otherwise
8888
*/
8989
static boolean isWhiteSpace(char ch) {
90-
return ((ch == ' ') || (ch == '\n') || (ch == '\t') || (ch == 10) || (ch == 13));
90+
return ((ch == ' ') || (ch == '\n') || (ch == '\t') || (ch == '\r'));
9191
}
9292

9393

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ Vector getWords(String text, int align, boolean returnComps) {
20282028
}
20292029
word = "";
20302030
} else {
2031-
if ((ch == ' ') || (ch == 10) || (ch == 13) || (ch == '\t') || (ch == '\n')) {
2031+
if ((ch == ' ') || (ch == '\n') || (ch == '\r') || (ch == '\t')) {
20322032
if (word.length() != 0) {
20332033
if (returnComps) {
20342034
words.addElement(addString(leadSpace + word + ' ', align));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ private static final double ieee754_pow(double x, double y) {
619619
}
620620
}
621621

622-
n = (hx >>> 31) + 1;
622+
n = (hx >> 31) + 1;
623623

624624
/* (x<0)**(non-int) is NaN */
625625
if ((n | yisint) == 0) {

CodenameOne/src/com/codename1/xml/XMLParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ protected void parseTagContent(Element element, Reader is) throws IOException {
522522
* @return true if the character is a white space, false otherwise
523523
*/
524524
protected boolean isWhiteSpace(char ch) {
525-
return ((ch == ' ') || (ch == '\n') || (ch == '\t') || (ch == 10) || (ch == 13));
525+
return ((ch == ' ') || (ch == '\n') || (ch == '\t') || (ch == '\r'));
526526
}
527527

528528
/**

0 commit comments

Comments
 (0)