-
-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cop idea: Rails/WhereBetween #689
Comments
Looks good to me. I don't remember the version clearly, but there would have been minimum Rails versions that supported begginless and endless ranges respectively. Anyway it would be better to be shown in the Rails Style Guide first :-) |
It seems to be supported since Rails 4.0.0. |
FYI, Rails 6.0 or later is required for endless range in Ruby 2.6 syntax and beginless range in Ruby 2.7 syntax:
So, non-abbreviation range syntax is fine, but these abbreviation syntax will need to be noted. |
For anyone interested, implemented a PR to address this. |
Problem
Describe the solution you'd like
Add a cop that would suggest using ranges instead:
Describe alternatives you've considered
Nothing specifically. Personally, I often choose to use ranges even when the constraint is just on one side of the range:
Additional context
This is used in the wild, see e.g.
could be safely simplified to:
The text was updated successfully, but these errors were encountered: