Include expanded EnforcedStyle options when --no-auto-gen-enforced-style is given#12388
Conversation
83e7056 to
9613eba
Compare
| rejected_keys << /^EnforcedStyle\w*/ unless auto_gen_enforced_style? | ||
| cfg.reject { |key| include_or_match?(rejected_keys, key) } |
There was a problem hiding this comment.
Is there a logic by which the following would work, instead of creating the new include_or_match method?
| rejected_keys << /^EnforcedStyle\w*/ unless auto_gen_enforced_style? | |
| cfg.reject { |key| include_or_match?(rejected_keys, key) } | |
| rejected_keys << 'EnforcedStyle' unless auto_gen_enforced_style? | |
| cfg.reject do |key| | |
| rejected_keys.any? { |rejected_key| key.start_with?(rejected_key) } | |
| end |
There was a problem hiding this comment.
Yes, this would work too! However then it only works for prefixed strings of course. I tried to anticipate for possible use cases where a key would not necessarily just start with the rejected key.
There was a problem hiding this comment.
Even if the current logic is left as is, /^EnforcedStyle\w*/ appears like it should be /\AEnforcedStyle\w*/.
There was a problem hiding this comment.
Yes, but any regexp could be used. :)
Edit: Ah, sorry, understood you wrong. You're right, \A should be added! What is your opinion on using regexes?
|
I'm fine with the proposed change. Thanks! |
It seems to me that when the
--no-auto-gen-enforced-styleis given, not onlyEnforcedStyleshould be rejected, but also all 'expanded'EnforcedStyleoptions as well, like for exampleEnforcedStyleForEmptyBraces. In order to achieve this I used a Regex when checking which keys should be rejected.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}.mdif the new code introduces user-observable changes. See changelog entry format for details.