Skip to content

Files

Latest commit

 

History

History
61 lines (44 loc) · 925 Bytes

Style-FloatDivision.md

File metadata and controls

61 lines (44 loc) · 925 Bytes

Pattern: Division with integer coerced to float

Issue: -

Description

It is recommended to either always use fdiv or coerce one side only. This rule also provides other options for code consistency.

Examples

EnforcedStyle: single_coerce (default)

# bad
a.to_f / b.to_f

# good
a.to_f / b
a / b.to_f

EnforcedStyle: left_coerce

# bad
a / b.to_f
a.to_f / b.to_f

# good
a.to_f / b

EnforcedStyle: right_coerce

# bad
a.to_f / b
a.to_f / b.to_f

# good
a / b.to_f

EnforcedStyle: fdiv

# bad
a / b.to_f
a.to_f / b
a.to_f / b.to_f

# good
a.fdiv(b)

Configurable attributes

Name Default value Configurable values
EnforcedStyle single_coerce left_coerce, right_coerce, single_coerce, fdiv

Further Reading