-
Notifications
You must be signed in to change notification settings - Fork 433
Avoid integer→float division artifacts and enforce SpotBugs ICAST_IDIV_CAST_TO_DOUBLE #4406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shai-almog
merged 3 commits into
master
from
codex/fix-spotbugs-integral-division-warnings
Jan 13, 2026
Merged
Avoid integer→float division artifacts and enforce SpotBugs ICAST_IDIV_CAST_TO_DOUBLE #4406
shai-almog
merged 3 commits into
master
from
codex/fix-spotbugs-integral-division-warnings
Jan 13, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collaborator
Author
…V_CAST_TO_DOUBLE ### Motivation - Address SpotBugs findings where an integral division result was cast to `double`/`float`, which can produce incorrect values. - Keep rendering, geometry, and animation math semantically unchanged while using explicit floating-point operations to avoid integer truncation. - Ensure the CI quality gate treats these SpotBugs findings as build failures by adding the rule to the forbidden list. ### Description - Use explicit floating-point division/casts in chart and rendering code: `ChartComponent` (`zoomX`/`zoomY`), `RadarChart` (`centerX`/`centerY`), and `XYChart` (`mTranslate`). - Fix UI/graphics math to use floats where appropriate: `CodenameOneImplementation.fillRectRadialGradient`, `CommonProgressAnimations.CircleProgress.stepSize`, `FlipTransition` (camera/translate math), `PerspectiveCamera` (camera math), `RoundRectBorder` (stroke offset), and `DefaultLookAndFeel` (state icon Y position). - Fix numeric coefficient calculation in `Geometry.BezierCurve` by ensuring factorial division produces a `double`, and correct `StyleParser.getMMValue` to return a `float` with proper rounding/scale. - Enforce SpotBugs rule `ICAST_IDIV_CAST_TO_DOUBLE` as a forbidden rule in `.github/scripts/generate-quality-report.py` so such findings fail the build. ### Testing - No automated test suite was executed as part of this change. - Static inspection and local code browsing were used to verify the numeric fixes compile and the SpotBugs rule was added to the quality-report script.
…CAST_TO_DOUBLE ### Motivation - Prevent incorrect numeric results caused by integer division being cast to `float`/`double` in rendering and chart math. - Silence SpotBugs `ICAST_IDIV_CAST_TO_DOUBLE` findings by fixing actual occurrences rather than masking them. - Preserve the intended rendering/geometry semantics while ensuring explicit floating-point arithmetic where required. - Improve precision in pinch-zoom, layout centering, camera transforms, and UI metrics. ### Description - Replace integer division with explicit floating-point operations in chart and layout code such as `ChartComponent.pointerDragged`, `XYChart` center/translate, and `RadarChart` center calculations to avoid truncation. - Adjust UI/graphics math in `DefaultLookAndFeel`, `RoundRectBorder`, `CodenameOneImplementation.fillRectRadialGradient`, `FlipTransition`, and `PerspectiveCamera` to use `0.5f`/`... * 0.5f` or explicit casts where appropriate. - Fix numeric coefficient calculation by casting factorial division to `double` in `Geometry` and correct `StyleParser.getMMValue` to return a properly computed `float`; also refine `CommonProgressAnimations.CircleProgress` timing calculation. - Add `ICAST_IDIV_CAST_TO_DOUBLE` to the forbidden SpotBugs rules in `.github/scripts/generate-quality-report.py` so such findings will fail the quality gate. ### Testing - No unit or integration test suite was executed as part of this change. - Static SpotBugs analysis was the motivating CI check and the edits target the previously reported `ICAST_IDIV_CAST_TO_DOUBLE` violations. - The repository previously failed the SpotBugs quality gate due to these violations and the changes remove the identified integer→float division instances. - CI re-run of the full pipeline was not performed within this patch set.
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 30 screenshots: 30 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.







Motivation
double/float, which can produce incorrect values.Description
ChartComponent(zoomX/zoomY),RadarChart(centerX/centerY), andXYChart(mTranslate).CodenameOneImplementation.fillRectRadialGradient,CommonProgressAnimations.CircleProgress.stepSize,FlipTransition(camera/translate math),PerspectiveCamera(camera math),RoundRectBorder(stroke offset), andDefaultLookAndFeel(state icon Y position).Geometry.BezierCurveby ensuring factorial division produces adouble, and correctStyleParser.getMMValueto return afloatwith proper rounding/scale.ICAST_IDIV_CAST_TO_DOUBLEas a forbidden rule in.github/scripts/generate-quality-report.pyso such findings fail the build.Testing
Codex Task