-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Support filter
in Rails/CompactBlank
#1359
Support filter
in Rails/CompactBlank
#1359
Conversation
8622e08
to
12894ef
Compare
if %i[reject select filter].include?(node.method_name) | ||
'compact_blank' | ||
else | ||
'compact_blank!' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this a constant?
if %i[reject select filter].include?(node.method_name) | |
'compact_blank' | |
else | |
'compact_blank!' | |
end | |
DESTRUCTIVE_METHODS.include?(node.method_name) ? 'compact_blank!' : 'compact_blank' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback. I've fixed it!
@@ -44,7 +46,7 @@ class CompactBlank < Base | |||
extend TargetRailsVersion | |||
|
|||
MSG = 'Use `%<preferred_method>s` instead.' | |||
RESTRICT_ON_SEND = %i[reject delete_if select keep_if].freeze | |||
RESTRICT_ON_SEND = %i[reject delete_if select filter keep_if].freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RESTRICT_ON_SEND = %i[reject delete_if select filter keep_if].freeze | |
RESTRICT_ON_SEND = %i[reject delete_if select filter keep_if].freeze | |
DESTRUCTIVE_METHODS = %i[delete_if keep_if].freeze |
12894ef
to
9980211
Compare
Thanks! |
This PR modifies
Rails/CompactBlank
to supportfilter
.Since
filter
is an alias forselect
in both Array and Hash, I think it can be handled in the same way asselect
.Before submitting the PR make sure the following are checked:
[ ] Commit message starts with[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.[ ] If this is a new cop, consider making a corresponding update to the Rails Style Guide.