-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #11436] Add new consistent_either
SupportedShorthandSyntax
to Style/HashSyntax
#12904
Conversation
This commit adds a new `consistent_either` to `EnforcedShorthandSyntax`. Related to feature request: rubocop#11436 This allows to use both explicit and shorthand syntax, similarly to existing `either` option, but with the difference that it enforces consistency within a single hash. This PR extends existing `consistent` option, and skips the `no_mixed_shorthand_syntax_check` offences when all values in the hash are ommitable.
consistent_either
SupportedShorthandSyntax to Style/HashSyntaxconsistent_either
SupportedShorthandSyntax
to Style/HashSyntax
consistent_either
SupportedShorthandSyntax
to Style/HashSyntax
consistent_either
SupportedShorthandSyntax
to Style/HashSyntax
@@ -172,6 +173,11 @@ def hash_with_values_that_cant_be_omitted?(hash_value_type_breakdown) | |||
hash_value_type_breakdown[:value_needed]&.any? | |||
end | |||
|
|||
def ignore_explicit_ommitable_hash_shorthand_syntax?(hash_value_type_breakdown) |
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.
There's no word "ommittable" - I think you meant to use "omissible". :-) See https://www.merriam-webster.com/dictionary/omissible
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.
Thanks, TIL, updated f91da7d
The suggested change seems reasonable to me. Apart from my remark about the use of the non-existing word "ommitable" here and there I'd also suggest changing the name to @rubocop/rubocop-core Feel free to chime on the name here. |
…consistent This will indicate that it works like `either` option which contains a consistency within a single hash definition. Suggested in rubocop#12904 (comment) PR comment
I like the suggested name updated in scope of 9ce04cf |
Related to feature request: #11436
Based on: #10776
WHAT
This commit adds a new
consistent_either
option toEnforcedShorthandSyntax
inStyle/HashSyntax
.This allows to use both explicit and shorthand syntax, similarly to existing
either
option, but with the difference that it enforces consistency within a single hash.This PR extends existing
consistent
option, and skips theno_mixed_shorthand_syntax_check
offences when all values in the hash are ommitable.bundle exec rake default - output
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.