[FIx #10356] Add AllowConsecutiveConditionals option to Style/GuardClause#10503
[FIx #10356] Add AllowConsecutiveConditionals option to Style/GuardClause#10503bbatsov merged 1 commit intorubocop:masterfrom
AllowConsecutiveConditionals option to Style/GuardClause#10503Conversation
8cc5a6e to
deeb70c
Compare
|
I'm fine with the proposal in principle, but I don't like very much the name of this variable. Something like |
deeb70c to
b7e29c0
Compare
ExcludeSameLevelMultipleIf option to Style/GuardClauseAllowMultipleSameDepthConditionals option to Style/GuardClause
AllowMultipleSameDepthConditionals option to Style/GuardClauseAllowMultipleSameDepthConditionals option to Style/GuardClause
|
My naming of variables was certainly not good. I think |
|
Btw, there's one detail of this we need to clarify - do we want to apply it if there's any conditional at the same depth or only if the preceding expression is a conditional at the same depth. The implementation seems to imply the former, but at least to me it seems that that latter probably makes more sense. The OP (@johnnyshields) is welcome to share his thoughts as well. |
|
@bbatsov thanks for pinging me. I'm somewhat agnostic to either approach. I think I might favor it to be the "only if the preceding expression is a conditional at the same depth", but probably either is fine. |
b7e29c0 to
fa8f64d
Compare
|
@bbatsov @johnnyshields Thanks so much for the feedback! I updated this PR. Thank you so much! |
|
Good. Now that we've settled this I have a proposal how to simplify the config name further - "AllowConsecutiveConditionals". That's essentially the same as before, but a bit more specific and easier to parse mentally. |
|
@bbatsov yep perfect name its 100% clear. |
…le/GuardClause` This PR add `AllowConsecutiveConditionals` option to `Style/GuardClause` and the option is false by default. I'd prefer to keep both if statements if triggered offense at the same depth. This option works only if the preceding expression is a conditional at the same depth. Since the existing behavior isn't erroneous, this PR have made it optional and set default to false.
fa8f64d to
dd67ef4
Compare
|
@bbatsov Yeah perfect name! I updated this PR. Thank you so much! |
AllowMultipleSameDepthConditionals option to Style/GuardClauseAllowConsecutiveConditionals option to Style/GuardClause
AllowConsecutiveConditionals option to Style/GuardClauseAllowConsecutiveConditionals option to Style/GuardClause
|
Thanks for tackling this! 🙇♂️ |
Resolve #10356
This PR add
AllowConsecutiveConditionalsoption toStyle/GuardClauseand the option is false by default.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.