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

Fix Violations of and Reenable Style/FloatDivision #58236

Merged
merged 2 commits into from
May 7, 2024

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented Apr 24, 2024

Checks for division with integers coerced to floats. It is recommended to either always use fdiv or coerce one side only. This cop also provides other options for code consistency.

Fix applied automatically with bundle exec rubocop --autocorrect-all --only Style/FloatDivision

This seems like a pretty safe one, with few violations.

Links

Testing story

Relying on existing tests to verify that this does not result in any change to functionality.

> Checks for division with integers coerced to floats. It is recommended to either always use `fdiv` or coerce one side only. This cop also provides other options for code consistency.

This seems like a pretty safe one, with few violations.

- https://docs.rubocop.org/rubocop/cops_style.html#stylefloatdivision
- https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/FloatDivision
@Hamms Hamms marked this pull request as ready for review April 25, 2024 23:24
@Hamms Hamms requested a review from a team April 25, 2024 23:25
Copy link
Contributor

@bethanyaconnor bethanyaconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on existing tests to verify that this does not result in any change to functionality.

Looking at where these changes are, I'm a bit doubtful of test coverage. That said, they're very low risk places to make changes (knock on wood...) and a low risk change at that, so I think this is fine!

@Hamms
Copy link
Contributor Author

Hamms commented May 7, 2024

Oh, good point. I saw that we had an admin_reports_controller_test.rb, but didn't go so far as actually looking at what's in it; that is indeed pretty sparse. Fortunately, I think you're right that this is pretty low risk, particularly because we cast the value to a float on an earlier line anyway

Thanks for checking!

@Hamms Hamms merged commit d00dff7 into staging May 7, 2024
2 checks passed
@Hamms Hamms deleted the fix-Style/FloatDivision branch May 7, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants