-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Do we need an MasgnNode ? #260
Comments
Sure, this could be a good addition, although it is tricky. Are you up to produce a PR?
On the right side it's a bit tricky, as it may be an expression, or may be The enumerator sounds interesting, but is trickiest, as there are multiple "unhappy" cases:
|
I had started working on nodes for |
#203 was merged and released so this can be closed now. |
Do we need a node to help with “multi-assignment”? I came across this code in the rubocop-thread_safety gem: https://github.com/rubocop/rubocop-thread_safety/blob/2662a8142f41a53bc3bc65eb2c670db18b3c581a/lib/rubocop/cop/thread_safety/mutable_class_instance_variable.rb#L99C13-L110
RuboCop’s
InternalAffairs/NodeDestructuring
cop tells me to “Use the methods provided with the node extensions instead of manually destructuring nodes” on themlhs, values = *node
line. But theRuboCop::AST::Node
class doesn’t really offer any specialised helper method for this type of node.So I thought it may be useful to add a
RuboCop::AST::MasgnNode
class with access to the left-hand-side list (also aRuboCop::AST::Node
instance) and the right-hand-sideRuboCop::AST::ArrayNode
of values? And perhaps the class could also have a method to iterate over each assignment pair, much like themlhs.to_a.zip(values.to_a).each
, though perhaps it should be lazy instead of eager.The text was updated successfully, but these errors were encountered: