Skip to content
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

bug: address potential int and double issue from SpotBugs #5650

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

firefly2442
Copy link
Contributor

Integral value cast to double and then passed to Math.ceil This code converts an integral value (e.g., int or long) to a double precision floating point number and then passing the result to the Math.ceil() function, which rounds a double to the next higher integer value. This operation should always be a no-op, since converting an integer to a double should give a number with no fractional part. It is likely that the operation that generated the value to be passed to Math.ceil was intended to be performed using double precision floating point arithmetic.

Bug kind and pattern: ICAST - ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL

Found via SpotBugs

Integral value cast to double and then passed to Math.ceil
This code converts an integral value (e.g., int or long) to a double precision floating point number and then passing the result to the Math.ceil() function, which rounds a double to the next higher integer value. This operation should always be a no-op, since converting an integer to a double should give a number with no fractional part. It is likely that the operation that generated the value to be passed to Math.ceil was intended to be performed using double precision floating point arithmetic.

Bug kind and pattern: ICAST - ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL
@codecov-commenter
Copy link

codecov-commenter commented Jan 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.03%. Comparing base (8dbf74b) to head (da0a89b).
Report is 17 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #5650   +/-   ##
=========================================
  Coverage     10.02%   10.03%           
- Complexity     6069     6072    +3     
=========================================
  Files          1074     1074           
  Lines        141609   141599   -10     
  Branches      20646    20645    -1     
=========================================
+ Hits          14203    14208    +5     
+ Misses       126032   126018   -14     
+ Partials       1374     1373    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HammerGS HammerGS merged commit 24fcff2 into MegaMek:master Jan 5, 2025
4 checks passed
@firefly2442 firefly2442 deleted the spotbugs-int-float branch January 5, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants