Pattern: Division with integer coerced to float
Issue: -
It is recommended to either always use fdiv
or coerce one side only. This rule also provides other options for code consistency.
# bad
a.to_f / b.to_f
# good
a.to_f / b
a / b.to_f
# bad
a / b.to_f
a.to_f / b.to_f
# good
a.to_f / b
# bad
a.to_f / b
a.to_f / b.to_f
# good
a / b.to_f
# bad
a / b.to_f
a.to_f / b
a.to_f / b.to_f
# good
a.fdiv(b)
Name | Default value | Configurable values |
---|---|---|
EnforcedStyle | single_coerce |
left_coerce , right_coerce , single_coerce , fdiv |