Skip to content

Commit d0e4faa

Browse files
Fix UC_USELESS_CONDITION SpotBugs warnings
Resolves "Condition has no effect" warnings in: - HTMLComponent.java (Redundant else/assignment) - CSSEngine.java (Redundant getUi() != null check) - CSSParser.java (Redundant EOF check) - RECharacter.java (Duplicate check) - ResourceThreadQueue.java (Simplified boolean check) - Component.java (Redundant isFlatten() || !opaque check) - CodenameOneImplementation.java (Redundant width/height check) - MathUtil.java (Redundant huge + x > one check) - MenuBar.java (Dead code removal for ICS check) - ComponentGroup.java (Refactored logic) - Updated generate-quality-report.py to enforce this rule.
1 parent f3e35c7 commit d0e4faa

File tree

9 files changed

+10
-20
lines changed

9 files changed

+10
-20
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7960,9 +7960,6 @@ public boolean isSimulator() {
79607960
* @param s the style object to draw
79617961
*/
79627962
public void paintComponentBackground(Object nativeGraphics, int x, int y, int width, int height, Style s) {
7963-
if (width < 1 || height < 1) {
7964-
return;
7965-
}
79667963
Image bgImageOrig = s.getBgImage();
79677964
if (bgImageOrig == null) {
79687965
if (s.getBackgroundType() >= Style.BACKGROUND_GRADIENT_LINEAR_VERTICAL) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,9 +3219,6 @@ protected Border getBorder() {
32193219
* @param g the component graphics
32203220
*/
32213221
void paintComponentBackground(Graphics g) {
3222-
if (isFlatten() || !opaque) {
3223-
return;
3224-
}
32253222
paintBackgroundImpl(g);
32263223
}
32273224

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ void insertComponentAt(int index, Object con, Component cmp) {
106106
public void refreshTheme(boolean merge) {
107107
super.refreshTheme(merge);
108108
boolean ignoreGroup = getUIManager().isThemeConstant(groupFlag, false);
109-
if (!ignoreGroup && !forceGroup) {
109+
if (ignoreGroup || forceGroup) {
110+
updateUIIDs();
111+
} else {
110112
if (uiidsDirty) {
111113
uiidsDirty = false;
112114
int count = getComponentCount();
113115
for (int iter = 0; iter < count; iter++) {
114116
restoreUIID(getComponentAt(iter));
115117
}
116118
}
117-
} else {
118-
updateUIIDs();
119119
}
120120
}
121121

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,18 +1497,18 @@ protected Command showMenuDialog(Dialog menu) {
14971497
marginRight = marginLeft;
14981498
marginLeft = 0;
14991499
}
1500-
if (getCommandBehavior() == Display.COMMAND_BEHAVIOR_ICS) {
1500+
/*if (getCommandBehavior() == Display.COMMAND_BEHAVIOR_ICS) {
15011501
menu.setTransitionOutAnimator(transitionIn);
15021502
menu.setTransitionInAnimator(transitionOut);
15031503
int th = getTitleAreaContainer().getHeight();
15041504
return menu.show(th, height - th, marginLeft, marginRight, true);
1505-
} else {
1505+
} else {*/
15061506
if (manager.getLookAndFeel().isTouchMenus() && manager.isThemeConstant("PackTouchMenuBool", true)) {
15071507
return menu.showPacked(BorderLayout.SOUTH, true);
15081508
} else {
15091509
return menu.show(height, 0, marginLeft, marginRight, true);
15101510
}
1511-
}
1511+
//}
15121512
}
15131513

15141514
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ private boolean containsClass(String elementClass, String selectorClass) {
467467
* @param htmlC The HTMLComponent
468468
*/
469469
private void applyStyle(HTMLElement element, CSSElement selector, HTMLComponent htmlC) {
470-
if ((element.getUi() != null) && (element.getUi().size() > 0)) {
470+
if (element.getUi().size() > 0) {
471471
if (!HTMLComponent.PROCESS_HTML_MP1_ONLY) {
472472
String reset = selector.getAttributeById(CSSElement.CSS_COUNTER_RESET);
473473
if (reset != null) {

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 (c != (char) -1 && isWhiteSpace(c)) { //skip white spaces
110+
while (isWhiteSpace(c)) { //skip white spaces
111111
c = r.readCharFromReader();
112112
}
113113
} else {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,8 +2971,6 @@ private void processTag(HTMLElement element, int align) {
29712971
HTMLFont headerFont = (HTMLFont) fonts.get(child.getTagName());
29722972
if (headerFont != null) {
29732973
font = headerFont;
2974-
} else {
2975-
font = oldFont;
29762974
}
29772975
// No break here intentionally
29782976
case HTMLElement.TAG_P:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public void streamReady(InputStream is, DocumentInfo docInfo) {
459459
}
460460
}
461461

462-
if (cancelled == false) {
462+
if (!cancelled) {
463463
Display.getInstance().callSerially(new Runnable() {
464464
public void run() {
465465
// prevent a redirect or another thread from breaking the UI

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,7 @@ private static final double ieee754_asin(double x) {
900900
return 1.0; /* asin(|x|>1) is NaN */
901901
} else if (ix < 0x3fe00000) { /* |x|<0.5 */
902902
if (ix < 0x3e400000) { /* if |x| < 2**-27 */
903-
if (huge + x > one) {
904-
return x;/* return x with inexact if x!=0*/
905-
}
903+
return x;/* return x with inexact if x!=0*/
906904
} else {
907905
t = x * x;
908906
p = t * (pS0 + t * (pS1 + t * (pS2 + t * (pS3 + t * (pS4 + t * pS5)))));

0 commit comments

Comments
 (0)