-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Third option for Style/TernaryParentheses #3451
Comments
Makes sense to me. I'd accept such a style if someone implements it. |
This is a clear improvement from a similar suggestion made earlier, in that this one specifies, unambiguously, what "complex" means, but the suggested configuration name unfortunately doesn't give the user much indication of its specifics. 😀 |
@Drenmi by "complex" I was thinking the more basic definition of "compound": Not necessarily "complicated", though that is part of the semantic range, too. What about the word "compound"? So, |
I think whatever we come up with will be not specific enough, lest we make the name prohibitively long. 😅 I think let's just go with "complex", and include an explanation of the setting in |
I have the cop working for this and will commit somewhat soon. |
[Fix #3451] Add new `require_parentheses_when_complex` style to `Styl…
Currently (as of 0.42.0), rubocop gives 2 options for
Style/TernaryParentheses
and
Both of these are undesirable to our team...
Sometimes, parens are desired—the conditional is complex and the timing is not quite right to do a proper refactor. Parentheses greatly aid legibility and code comprehension and scannability. (Quick test: without looking, in Ruby's order of operations precedence, where does a ternary operator fall? How does it compare to
&&
? How about to=
? What about todefined?
?)Usually, parens are unnecessary. Which is why
require_no_parentheses
was chosen as the default, I'm sure.So, what I'd like to see is a third option:
Namely, I want to require parens when there is a non-unary operator as the first term in the ternary operator.
What do ya'll think?
The text was updated successfully, but these errors were encountered: