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
New cop to replace conditional assignment with or-assignment #10325
Comments
Seems like a good idea to me. I think we have a couple of similar cops already. |
Can I give it a try? Maybe we can call it something like Style/OrAssignment? |
@marcospedro97 Yes, please, go ahead 👍 |
I've found a cop with this name already, and it's behaviour is too different from the one we're talking about, thinking about naming it Style/SingleLineOrAssginment, there's also another with the name conditional assignment, also too diferent |
… the case that variable assignments in each branch
…se that variable assignments in each branch
I've written the following code
But then realized that this should be really written as
and wondering why rubocop hasn't suggested such change.
Quick search on the rails codebase via regexp revealed this:
https://github.com/rails/rails/blob/296ef7a17221e81881e38b51aa2b014d7a28bac5/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb#L75-L79
So I suggest implementing a new cop (not sure about its name).
This should also check for cases like
etc.
The text was updated successfully, but these errors were encountered: