{"action":"created","issue":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/2383","labels_url":"https://api.github.com/repos/bbatsov/rubocop/issues/2383/labels{/name}","comments_url":"https://api.github.com/repos/bbatsov/rubocop/issues/2383/comments","events_url":"https://api.github.com/repos/bbatsov/rubocop/issues/2383/events","html_url":"https://github.com/bbatsov/rubocop/pull/2383","id":114455721,"number":2383,"title":"[Fix #2344] When correcting parallel assignment, reorder lines to avoid breaking code","user":{"login":"alexdowad","id":1067359,"avatar_url":"https://avatars.githubusercontent.com/u/1067359?v=3","gravatar_id":"","url":"https://api.github.com/users/alexdowad","html_url":"https://github.com/alexdowad","followers_url":"https://api.github.com/users/alexdowad/followers","following_url":"https://api.github.com/users/alexdowad/following{/other_user}","gists_url":"https://api.github.com/users/alexdowad/gists{/gist_id}","starred_url":"https://api.github.com/users/alexdowad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexdowad/subscriptions","organizations_url":"https://api.github.com/users/alexdowad/orgs","repos_url":"https://api.github.com/users/alexdowad/repos","events_url":"https://api.github.com/users/alexdowad/events{/privacy}","received_events_url":"https://api.github.com/users/alexdowad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-01T07:35:42Z","updated_at":"2015-11-02T13:44:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bbatsov/rubocop/pulls/2383","html_url":"https://github.com/bbatsov/rubocop/pull/2383","diff_url":"https://github.com/bbatsov/rubocop/pull/2383.diff","patch_url":"https://github.com/bbatsov/rubocop/pull/2383.patch"},"body":"This is a first draft of a fix for #2344.\r\n\r\nThe part which I'm not happy with yet is:\r\n\r\n```ruby\r\n            find_symbol = lambda do |node, symbol|\r\n              node.children.any? { |obj| obj.equal?(symbol) } ||\r\n              node.each_child_node.any? { |child| find_symbol[child, symbol] }\r\n            end\r\n```\r\n\r\nTo determine whether an expression has a dependency on a certain variable, I'm just searching the AST to see if a symbol with the variable's name occurs anywhere. I would like this to be more robust.\r\n\r\nIn the `variable_force` code, I can see you already have logic for searching ASTs and building a table of where each variable is used. This is exactly what I need. But it seems hard to reuse that code -- there's no entry point where I can just call something like `node.references_variable?(var)`.\r\n\r\nDo I have to make `Style/ParallelAssignment` part of the \"variable force\" to use that existing code?"},"comment":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/comments/153020508","html_url":"https://github.com/bbatsov/rubocop/pull/2383#issuecomment-153020508","issue_url":"https://api.github.com/repos/bbatsov/rubocop/issues/2383","id":153020508,"user":{"login":"jonas054","id":336720,"avatar_url":"https://avatars.githubusercontent.com/u/336720?v=3","gravatar_id":"","url":"https://api.github.com/users/jonas054","html_url":"https://github.com/jonas054","followers_url":"https://api.github.com/users/jonas054/followers","following_url":"https://api.github.com/users/jonas054/following{/other_user}","gists_url":"https://api.github.com/users/jonas054/gists{/gist_id}","starred_url":"https://api.github.com/users/jonas054/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonas054/subscriptions","organizations_url":"https://api.github.com/users/jonas054/orgs","repos_url":"https://api.github.com/users/jonas054/repos","events_url":"https://api.github.com/users/jonas054/events{/privacy}","received_events_url":"https://api.github.com/users/jonas054/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T13:44:33Z","updated_at":"2015-11-02T13:44:33Z","body":":+1: Looks good!"}}