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

Update a style guide for "Float Division" #767

Merged
merged 1 commit into from
Jun 22, 2019

Conversation

koic
Copy link
Member

@koic koic commented Jun 22, 2019

This PR updates a style guide for "Float Division".
The original issue for which this style was proposed.
#628

It is an update based on the following argument.
rubocop/rubocop#7153 (comment)

The following is a quote from the argument about the reason for this change.

I wanted to show the following option to make a bad case only when both have to_f.

# bad
a.to_f / b.to_f

# good
a.to_f / b
a / b.to_f
a.fdiv(b)

Whether to_f is used on the left or right depends on the nature of a
or b parameter. On the other hand, it is redundant that to_f is used
in both. At that time, I think it is better to let users choose whether
to remove the left side to_f or the right side to_f. This is the
reason I recommend this option to default.

This PR updates a style guide for "Float Division".

The original issue for which this style was proposed.
rubocop#628

It is an update based on the following argument.
rubocop/rubocop#7153 (comment)

The following is a quote from the argument about the reason for this change.

> I wanted to show the following option to make a bad case only when both have `to_f`.
>
> ```ruby
> # bad
> a.to_f / b.to_f
>
> # good
> a.to_f / b
> a / b.to_f
> a.fdiv(b)
> ```
>
> Whether `to_f` is used on the left or right depends on the nature of `a`
> or `b` parameter. On the other hand, it is redundant that `to_f` is used
> in both. At that time, I think it is better to let users choose whether
> to remove the left side `to_f` or the right side `to_f`. This is the
> reason I recommend this option to default.
@bbatsov bbatsov merged commit 978f56f into rubocop:master Jun 22, 2019
@bbatsov
Copy link
Collaborator

bbatsov commented Jun 22, 2019

👍

@koic koic deleted the update_style_guide_for_float_division branch June 22, 2019 21:14
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.

2 participants