-
-
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
Cop for avoidable multiple assignment #1136
Comments
I get your point. The only case in which multiple assignment should be allowed would be mismatching number of variables on the left side and the right side of the assignment, right? |
More or less. The only other scenario I can think of is
|
That seems problematic. I wouldn't want the offense to go way if purposefully break the code like this: @a, @b, @c, @d, @e = a, b, c, e |
I'll think about this. Perhaps it only makes sense to do multiple assignment when destructuring a single argument (or you swap values as mentioned earlier). |
I agree that destructuring one object into many, and swapping two values are valid use cases. I can't think of any others. |
The following code does not generate any offenses:
but I'd like RuboCop to be able to tell me to put each of those assignments on a separate line.
I realise that some people may prefer to have multiple assignments in a single line. I used to be one of those people. Nowadays, I'm of the philosophy that each line of code should do only one thing. It makes it easier for me to read, and makes the git diff of deleting a variable easier to read. But differences in coding style is what disabling a cop is for.
The text was updated successfully, but these errors were encountered: