Skip to content

Commit f3e35c7

Browse files
Fix UC_USELESS_CONDITION SpotBugs warnings
Resolves "Condition has no effect" warnings in: - HTMLComponent.java (Redundant SUPPORT_CSS check, fix variable shadowing) - CSSEngine.java (Redundant indent >= 0 check) - CSSParser.java (Incorrect EOF check for char) - RECharacter.java (Duplicate whitespace check) - Updated generate-quality-report.py to enforce this rule.
1 parent 36d92ee commit f3e35c7

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,9 +1338,7 @@ private void applyStyleToUIElement(Component ui, CSSElement selector, HTMLElemen
13381338

13391339
// Text indentation
13401340
int indent = selector.getAttrLengthVal(CSSElement.CSS_TEXT_INDENT, ui, htmlC.getWidth());
1341-
if (indent >= 0) { // Only positive (0 also as it may cancel previous margins)
1342-
setTextIndentationRecursive(ui, indent);
1343-
}
1341+
setTextIndentationRecursive(ui, indent);
13441342

13451343
//
13461344
// Font

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private char handleCSSComment(ExtInputStreamReader r) throws IOException {
107107
c = r.readCharFromReader();
108108
}
109109
c = r.readCharFromReader();
110-
while (((int) c) != -1 && isWhiteSpace(c)) { //skip white spaces
110+
while (c != (char) -1 && isWhiteSpace(c)) { //skip white spaces
111111
c = r.readCharFromReader();
112112
}
113113
} else {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ public void run() {
18011801
//newLine(Component.LEFT); //flush buffer
18021802
mainContainer.applyRTL((dir != null) && (dir.equalsIgnoreCase("rtl")));
18031803

1804-
if ((SUPPORT_CSS) && (loadCSS)) {
1804+
if (loadCSS) {
18051805
body.setAssociatedComponents(mainContainer);
18061806
if (threadQueue.getCSSCount() == -1) { // If there are no pending external CSS, we can already process the CSS
18071807
applyAllCSS(); // Note that this doesn't have to be on EDT as the main container is still not displayed
@@ -2968,9 +2968,9 @@ private void processTag(HTMLElement element, int align) {
29682968
case HTMLElement.TAG_H4:
29692969
case HTMLElement.TAG_H5:
29702970
case HTMLElement.TAG_H6:
2971-
HTMLFont f = (HTMLFont) fonts.get(child.getTagName());
2972-
if (f != null) {
2973-
font = f;
2971+
HTMLFont headerFont = (HTMLFont) fonts.get(child.getTagName());
2972+
if (headerFont != null) {
2973+
font = headerFont;
29742974
} else {
29752975
font = oldFont;
29762976
}

CodenameOne/src/com/codename1/util/regex/RECharacter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static boolean isWhitespace(char c) {
150150
return ((type == SPACE_SEPARATOR || type == LINE_SEPARATOR ||
151151
type == PARAGRAPH_SEPARATOR) && !(c == 0x00A0 || c == 0x2007 ||
152152
c == 0x202F)) || c == 0x0009 || c == 0x000A || c == 0x000B ||
153-
c == 0x000C || c == 0x000D || c == 0x0009 || c == 0x001C ||
153+
c == 0x000C || c == 0x000D || c == 0x001C ||
154154
c == 0x001D || c == 0x001E || c == 0x001F;
155155
}
156156

0 commit comments

Comments
 (0)