You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lint/FloatComparison discourages comparing by absolute values. I know why but zero seems like something that should be made an exception for.
ifvalue.to_f != 0.0# Lint/FloatComparison: Avoid (in)equality comparisons of floats as they are unreliable10 / value.to_fend
If I switch to EnforcedStyle: predicate for Style/NumericPredicate I can write the following without offence:
unlessvalue.to_f.zero?# All good!10 / value.to_fend
value is user-provided and I want to prevent NaN from being returned, falling back to some other logic in that case. Alternatively, how would I write this without triggering an offense?
Expected behavior
Rubocop should either allow value.to_f != 0.0 or disallow value.to_f.zero?
I have the following rubocop config:
Lint/FloatComparison
discourages comparing by absolute values. I know why but zero seems like something that should be made an exception for.If I switch to
EnforcedStyle: predicate
forStyle/NumericPredicate
I can write the following without offence:value
is user-provided and I want to preventNaN
from being returned, falling back to some other logic in that case. Alternatively, how would I write this without triggering an offense?Expected behavior
Rubocop should either allow
value.to_f != 0.0
or disallowvalue.to_f.zero?
RuboCop version
The text was updated successfully, but these errors were encountered: