-
-
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
Ban and/or on conditionals only #1232
Comments
This was how this cop originally worked (as the first draft of the style guide promoted such style), but the problem is that not every use of some_result = some_bool or some_other_bool
x = some_value or some_other_value While those cases might not pop very often they are quite real. That said, if @yujinakayama and @jonas054 are open to making the cop configurable I'll support this. |
I quite like constructs like do_something or return so I'd love to see a change in this cop. A configuration option is the way to go. |
To elaborate on this, there are a number of cases where using boolean operators for flow control display some unusual behavior: Return:
Raise:
To me this seems like an unfortunate quirk of the Ruby language, but I think that this behavior actually degrades the readability rather than improves it. It might be good to have a catchall I have slightly longer comment on this at puppetlabs/puppet#2900 (comment). |
Btw, you could also write |
I'm having trouble parsing this, but it sounds very interesting. Could you elaborate? |
Obviously such code cannot be auto-corrected. I think we actually register offenses in such scenarios, but don't autocorrect them. Maybe there should be an option not to register offenses at all. |
[Fix #1232] make the behavior of AndOr cop configurable
I was wondering if there would be interest for a restricted AndOr cop that checked for and/or keyword use only within conditionals. This leaves the keyword operators free to be used as control flow operators. I am aware of the style guide opinion, but having a choice between complete ban and a partial ban would be nice. I have a prototype here which I can submit if the idea is worthwhile.
The text was updated successfully, but these errors were encountered: