Pattern: Missing use of Comparable#clamp
Issue: -
Enforces the use of Comparable#clamp
instead of comparison by minimum and maximum.
This rule supports autocorrection for if/elsif/else
bad style only. Because ArgumentError
occurs if the minimum and maximum of clamp arguments are reversed.
# bad
[[x, low].max, high].min
# bad
if x < low
low
elsif high < x
high
else
x
end
# good
x.clamp(low, high)