Commit 73565cb
Fix SpotBugs "Condition has no effect" warnings (#4366)
* Fix SpotBugs "Condition has no effect" (UC_USELESS_CONDITION) warnings
Updated .github/scripts/generate-quality-report.py to fail on UC_USELESS_CONDITION.
Fixed UC_USELESS_CONDITION warnings in:
- CodenameOne/src/com/codename1/ui/layouts/mig/Grid.java
- CodenameOne/src/com/codename1/ui/MenuBar.java
- CodenameOne/src/com/codename1/util/MathUtil.java
- CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java
- CodenameOne/src/com/codename1/ui/Component.java
- CodenameOne/src/com/codename1/ui/ComponentGroup.java
- CodenameOne/src/com/codename1/ui/html/CSSEngine.java
- CodenameOne/src/com/codename1/ui/html/CSSParser.java
- CodenameOne/src/com/codename1/ui/html/HTMLComponent.java
- CodenameOne/src/com/codename1/ui/html/ResourceThreadQueue.java
- CodenameOne/src/com/codename1/ui/layouts/mig/UnitValue.java
- CodenameOne/src/com/codename1/util/regex/RECharacter.java
- CodenameOne/src/com/codename1/xml/XMLParser.java
* Fix UC_USELESS_CONDITION SpotBugs warnings
Fixed multiple occurrences of UC_USELESS_CONDITION warnings across 13 files.
Updated .github/scripts/generate-quality-report.py to fail on this violation.
Notable fixes:
- CSSParser.java: Fixed char to byte cast comparison that caused premature EOF on extended ASCII.
- ResourceThreadQueue.java: Fixed variable shadowing and added volatile to cancelled flag.
- UnitValue.java: Fixed condition checking operation type.
- XMLParser.java: Used Character.toLowerCase instead of manual range check.
- Various cleanups in Grid.java, MenuBar.java, Component.java, etc.
* Fix UC_USELESS_CONDITION SpotBugs warnings and compilation error
Fixed UC_USELESS_CONDITION warnings across 13 files and resolved a compilation error in ComponentGroup.java.
Updated .github/scripts/generate-quality-report.py to fail on this violation.
Notable fixes:
- ComponentGroup.java: Added missing import for Layout class.
- CSSParser.java: Fixed char to byte cast comparison that caused premature EOF on extended ASCII.
- ResourceThreadQueue.java: Fixed variable shadowing and added volatile to cancelled flag.
- UnitValue.java: Fixed condition checking operation type.
- XMLParser.java: Used Character.toLowerCase instead of manual range check.
- Various cleanups in Grid.java, MenuBar.java, Component.java, etc.
* Fix UC_USELESS_CONDITION SpotBugs warnings and enforce rule in CI
* 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.
* 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.
* Fix UC_USELESS_CONDITION SpotBugs warnings
Resolves "Condition has no effect" warnings in:
- CodenameOneImplementation.java (Redundant width/height check)
- MathUtil.java (Redundant huge + x > one check)
- Component.java (Redundant isFlatten() || !opaque check)
- HTMLComponent.java (Redundant else/assignment)
- ResourceThreadQueue.java (Simplified boolean check)
- CSSEngine.java (Redundant getUi() != null check)
- CSSParser.java (Redundant EOF check)
- MenuBar.java (Dead code removal for ICS check)
- ComponentGroup.java (Refactored logic)
- Updated generate-quality-report.py to enforce this rule.
* Fix UC_USELESS_CONDITION SpotBugs warnings across multiple files
This change resolves "Condition has no effect" (UC_USELESS_CONDITION) warnings reported by SpotBugs in several core classes including Component, MenuBar, CSSEngine, CSSParser, and MathUtil. It also updates the quality report generation script to enforce this rule in CI.
Key changes:
- `Component.java`: Refactored `paintLock` logic to remove redundant checks.
- `ComponentGroup.java`: Simplified boolean logic in `updateUIIDs` to avoid redundancy.
- `MenuBar.java`: Removed dead code related to deprecated ICS command behavior.
- `CSSEngine.java`: Made `fontSize` range check explicit.
- `CSSParser.java`: Improved EOF check readability in whitespace loop.
- `MathUtil.java`: Removed redundant floating-point precision checks in `asin` and `atan`.
- `.github/scripts/generate-quality-report.py`: Added `UC_USELESS_CONDITION` to the list of enforced rules.
* 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.
* 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.
* Fix remaining SpotBugs UC_USELESS_CONDITION warnings
Addressed persistent SpotBugs warnings in core classes:
* CodenameOne/src/com/codename1/util/MathUtil.java: Removed redundant `if (ix >= 0x3ff00000)` check in `ieee754_pow` as it is logically implied by previous conditions.
* CodenameOne/src/com/codename1/ui/MenuBar.java: Removed redundant `COMMAND_BEHAVIOR_SIDE_NAVIGATION` check which was impossible in the given context.
* CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java: Removed redundant `(c == 10)` check in `isWhitespace` as `\n` (10) was already checked.
* CodenameOne/src/com/codename1/ui/html/HTMLComponent.java, CSSParser.java, XMLParser.java, CSSEngine.java: Standardized whitespace checks to remove redundancy (`\n` vs 10) and ensured consistency.
These fixes clean up logic errors and redundant code flagged by strict static analysis.
* Fix SpotBugs UC_USELESS_CONDITION warnings and restore MathUtil behavior
Fixed multiple instances of 'Condition has no effect' (UC_USELESS_CONDITION) in core classes. Restored `MathUtil.ieee754_pow` to use logical right shift (`>>>`) to preserve original behavior for negative inputs, while removing the dead code blocks that SpotBugs flagged to resolve the static analysis violation.
Fixes:
* CodenameOne/src/com/codename1/util/MathUtil.java: Reverted `n` calculation to `>>>` and removed dead code blocks.
* CodenameOne/src/com/codename1/ui/MenuBar.java: Removed redundant `COMMAND_BEHAVIOR_SIDE_NAVIGATION` check.
* CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java: Removed redundant `(c == 10)` check in `isWhitespace`.
* CodenameOne/src/com/codename1/ui/html/HTMLComponent.java, CSSParser.java, XMLParser.java, CSSEngine.java: Standardized whitespace checks.
* Fix SpotBugs UC_USELESS_CONDITION warnings and correct MathUtil pow logic
Fixed multiple instances of 'Condition has no effect' (UC_USELESS_CONDITION) in core classes. Corrected `MathUtil.ieee754_pow` to use arithmetic right shift (`>>`) instead of logical right shift (`>>>`) for negative input handling, restoring correct mathematical behavior while removing the redundant `if (ix >= 0x3ff00000)` check that flagged the static analysis violation.
Fixes:
* CodenameOne/src/com/codename1/util/MathUtil.java: Corrected bitwise logic for `n` calculation and removed redundant condition.
* CodenameOne/src/com/codename1/ui/MenuBar.java: Removed redundant `COMMAND_BEHAVIOR_SIDE_NAVIGATION` check.
* CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java: Removed redundant `(c == 10)` check in `isWhitespace`.
* CodenameOne/src/com/codename1/ui/html/HTMLComponent.java, CSSParser.java, XMLParser.java, CSSEngine.java: Standardized whitespace checks.
* Update CodenameOne/src/com/codename1/xml/XMLParser.java
Co-authored-by: Copilot <[email protected]>
* Restored code that Jules removed, probably incorrectly
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Shai Almog <[email protected]>
Co-authored-by: Copilot <[email protected]>1 parent 365b110 commit 73565cb
File tree
14 files changed
+127
-171
lines changed- .github/scripts
- CodenameOne/src/com/codename1
- impl
- ui
- html
- layouts/mig
- util
- regex
- xml
14 files changed
+127
-171
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
773 | | - | |
| 773 | + | |
| 774 | + | |
774 | 775 | | |
775 | 776 | | |
776 | 777 | | |
| |||
Lines changed: 12 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3651 | 3651 | | |
3652 | 3652 | | |
3653 | 3653 | | |
3654 | | - | |
| 3654 | + | |
3655 | 3655 | | |
3656 | 3656 | | |
3657 | 3657 | | |
| |||
7447 | 7447 | | |
7448 | 7448 | | |
7449 | 7449 | | |
7450 | | - | |
7451 | | - | |
7452 | | - | |
| 7450 | + | |
| 7451 | + | |
| 7452 | + | |
| 7453 | + | |
7453 | 7454 | | |
7454 | 7455 | | |
7455 | 7456 | | |
| |||
8475 | 8476 | | |
8476 | 8477 | | |
8477 | 8478 | | |
8478 | | - | |
8479 | | - | |
8480 | | - | |
8481 | | - | |
8482 | | - | |
8483 | | - | |
8484 | | - | |
8485 | 8479 | | |
| 8480 | + | |
| 8481 | + | |
| 8482 | + | |
| 8483 | + | |
| 8484 | + | |
| 8485 | + | |
| 8486 | + | |
8486 | 8487 | | |
8487 | 8488 | | |
8488 | 8489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3548 | 3548 | | |
3549 | 3549 | | |
3550 | 3550 | | |
3551 | | - | |
3552 | | - | |
3553 | | - | |
3554 | | - | |
3555 | | - | |
3556 | | - | |
3557 | | - | |
3558 | | - | |
3559 | | - | |
3560 | | - | |
3561 | | - | |
3562 | | - | |
| 3551 | + | |
| 3552 | + | |
3563 | 3553 | | |
3564 | | - | |
| 3554 | + | |
| 3555 | + | |
3565 | 3556 | | |
3566 | 3557 | | |
3567 | 3558 | | |
| |||
5142 | 5133 | | |
5143 | 5134 | | |
5144 | 5135 | | |
5145 | | - | |
5146 | | - | |
| 5136 | + | |
| 5137 | + | |
5147 | 5138 | | |
5148 | 5139 | | |
5149 | 5140 | | |
| |||
5816 | 5807 | | |
5817 | 5808 | | |
5818 | 5809 | | |
5819 | | - | |
5820 | | - | |
5821 | | - | |
5822 | | - | |
| 5810 | + | |
5823 | 5811 | | |
5824 | 5812 | | |
5825 | 5813 | | |
| |||
6557 | 6545 | | |
6558 | 6546 | | |
6559 | 6547 | | |
6560 | | - | |
| 6548 | + | |
6561 | 6549 | | |
6562 | 6550 | | |
6563 | 6551 | | |
| |||
7393 | 7381 | | |
7394 | 7382 | | |
7395 | 7383 | | |
7396 | | - | |
7397 | | - | |
7398 | | - | |
| 7384 | + | |
7399 | 7385 | | |
7400 | 7386 | | |
7401 | | - | |
7402 | | - | |
7403 | | - | |
7404 | | - | |
| 7387 | + | |
| 7388 | + | |
| 7389 | + | |
7405 | 7390 | | |
7406 | 7391 | | |
7407 | 7392 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
114 | 118 | | |
115 | | - | |
116 | | - | |
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
| |||
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
140 | | - | |
| 142 | + | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
| |||
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
188 | 192 | | |
189 | 193 | | |
190 | 194 | | |
| |||
263 | 267 | | |
264 | 268 | | |
265 | 269 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
| 270 | + | |
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
598 | | - | |
| 598 | + | |
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
| |||
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
760 | 757 | | |
761 | 758 | | |
762 | 759 | | |
| |||
1058 | 1055 | | |
1059 | 1056 | | |
1060 | 1057 | | |
1061 | | - | |
1062 | | - | |
1063 | | - | |
| 1058 | + | |
1064 | 1059 | | |
1065 | 1060 | | |
1066 | 1061 | | |
| |||
1500 | 1495 | | |
1501 | 1496 | | |
1502 | 1497 | | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
1508 | 1501 | | |
1509 | | - | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
1513 | | - | |
| 1502 | + | |
1514 | 1503 | | |
1515 | 1504 | | |
1516 | 1505 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | | - | |
| 470 | + | |
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
810 | | - | |
| 810 | + | |
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
| |||
1338 | 1338 | | |
1339 | 1339 | | |
1340 | 1340 | | |
1341 | | - | |
1342 | | - | |
1343 | | - | |
| 1341 | + | |
1344 | 1342 | | |
1345 | 1343 | | |
1346 | 1344 | | |
| |||
1362 | 1360 | | |
1363 | 1361 | | |
1364 | 1362 | | |
1365 | | - | |
| 1363 | + | |
1366 | 1364 | | |
1367 | 1365 | | |
1368 | 1366 | | |
| |||
1462 | 1460 | | |
1463 | 1461 | | |
1464 | 1462 | | |
1465 | | - | |
1466 | | - | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
1467 | 1466 | | |
1468 | 1467 | | |
1469 | 1468 | | |
| |||
1669 | 1668 | | |
1670 | 1669 | | |
1671 | 1670 | | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
| 1671 | + | |
| 1672 | + | |
1675 | 1673 | | |
1676 | 1674 | | |
1677 | 1675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| |||
0 commit comments