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
[Fix #10698] Enhance Style/HashExcept
to support array inclusion checks
#10699
Conversation
7be33ad
to
d0b98d0
Compare
That's a tricky question. Normally I'd say "no", but ActiveSupport extensions are kind of special and most people use Rails. On the other hand they might have disabled some AS extension... I don't think there's a high chance for false positives, though, so perhaps you can add some check if |
Perhaps we need a configuration option whether rubocop cops to account for ActiveSupport methods, so people can just turn it on or off, and cops have common way to extend their own checks based on that. |
Keep in mind that outside of Rails you can require those in a very granular way, though. But I guess a single option will be fine for most people, as I assume it's rarely used outside of Rails. |
d0b98d0
to
192a219
Compare
config/default.yml
Outdated
@@ -3724,6 +3724,8 @@ Style/HashExcept: | |||
that can be replaced with `Hash#except` method. | |||
Enabled: pending | |||
VersionAdded: '1.7' | |||
VersionChanged: '<<next>>' | |||
ActiveSupportEnabled: false |
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.
I've added ActiveSupportEnabled
option to switch checking methods extended by ActiveSupport.
The option name might have better alternatives 🤔
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.
@nobuyo I like @Darhazer's idea to have some shared config option for this (perhaps a global config option?), so all the impacted cop can check for the same thing. The name of the option is fine, although if we want to be more specific I guess it should ActiveSupportExtensionsEnabled
or however they call them these days. I'm fine with the current name as well.
@rubocop/rubocop-core any thoughts on this?
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.
Sorry I was misunderstanding. I'll start over with a new way (create a new global option?).
cbc49b1
to
8a30439
Compare
8a30439
to
d15939a
Compare
d15939a
to
8a5f755
Compare
Looks good! We'll have to see which other cops can benefit from this setting and perhaps auto-set it to true in the presence of |
This comment was marked as spam.
This comment was marked as spam.
Follow up rubocop/rubocop#10699. `ActiveSupportExtensionsEnabled` option is supported since RuboCop 1.31.0. Please merge rubocop#729 first.
Fixes #10698.
I'm not sure if
in?
,exclude?
should be covered by RuboCop, since it is an extension by ActiveSupport.Before submitting the PR make sure the following are checked:
[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.