I was reading about this gem via the readme, and thought the syntax under the MagicNumbers/NoDefault section looked incorrect. I checked it using version 3.2.2, and I do indeed get errors.
def over_widget_limit?(20)
# ...
end
# SyntaxError: unexpected integer literal, expecting ')'
# def over_widget_limit?(20)
# ^~
def over_widget_limit?(FREE_SUBSCRIPTION_WIDGET_MAX)
# ...
end
# (eval):2: formal argument cannot be a constant
# ...t?(FREE_SUBSCRIPTION_WIDGET_MAX)
# ... ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm not sure what the correct usage should be, but I assume either method calls?
# BAD
over_widget_limit?(20)
# GOOD
over_widget_limit?(FREE_SUBSCRIPTION_WIDGET_MAX)
...or method definitions with a default?
# BAD
def over_widget_limit?(max = 20)
# ...
end
# GOOD
def over_widget_limit?(max = FREE_SUBSCRIPTION_WIDGET_MAX)
# ...
end
I was reading about this gem via the readme, and thought the syntax under the MagicNumbers/NoDefault section looked incorrect. I checked it using version 3.2.2, and I do indeed get errors.
I'm not sure what the correct usage should be, but I assume either method calls?
...or method definitions with a default?