-
-
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
Guard clauses on multi-line statements #3570
Comments
Agreed. |
How many lines are "so far away"? I think, >1. Or should it be configurable? |
+1 for "more than one." I think multiline is the most unambiguous and least arbitrary condition. |
I'm 👍 for that change and startet with proposing that advise to the styleguide. As I'm new to rubocop, I am not sure yet how to implement this best in rubocop. We'll see if I can manage to follow up with a PR. |
There is a PR now (#3636). I'd be happy for some reviews :) |
…ti-line-statements [Fix #3570] avoid if-modifiers on multi-line statements
In doing a code review, I came across something like the following:
I was rather surprised that RuboCop didn't flag that. Guard clauses are great, but if the guard clause is so far away from the beginning of the statement, it gets too confusing. This seems like a cop worth adding. (And I suppose there should be a corresponding change to the Ruby style guide.)
The text was updated successfully, but these errors were encountered: