{"action":"created","comment":{"url":"https://api.github.com/repos/mbj/mutant/pulls/comments/37141269","id":37141269,"diff_hunk":"@@ -13,11 +13,39 @@ class Define < self\n         # @api private\n         def dispatch\n           emit_arguments_mutations\n+          emit_optarg_mutations\n           emit_body(N_RAISE)\n           emit_body(nil)\n           emit_body_mutations if body\n         end\n \n+        # Emit mutation with optional arguments as assignments in method\n+        #\n+        # @return [undefined]\n+        #\n+        # @api private\n+        def emit_optarg_mutations\n+          optargs, args = arguments.children.partition do |child|\n+            child.type.equal?(:optarg)\n+          end\n+\n+          return if optargs.empty?\n+\n+          lvasgns = optargs.map do |optarg|\n+            s(:lvasgn, *optarg.children)\n+          end\n+\n+          body_children = [*lvasgns, body].compact\n+\n+          new_body = if body_children.one?\n+            body_children.first\n+          else\n+            s(:begin, *body_children)\n+          end","path":"lib/mutant/mutator/node/define.rb","position":32,"original_position":32,"commit_id":"cb707dfa5bbef208f89c7875eae825d8903d6d93","original_commit_id":"cb707dfa5bbef208f89c7875eae825d8903d6d93","user":{"login":"backus","id":2085622,"avatar_url":"https://avatars.githubusercontent.com/u/2085622?v=3","gravatar_id":"","url":"https://api.github.com/users/backus","html_url":"https://github.com/backus","followers_url":"https://api.github.com/users/backus/followers","following_url":"https://api.github.com/users/backus/following{/other_user}","gists_url":"https://api.github.com/users/backus/gists{/gist_id}","starred_url":"https://api.github.com/users/backus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backus/subscriptions","organizations_url":"https://api.github.com/users/backus/orgs","repos_url":"https://api.github.com/users/backus/repos","events_url":"https://api.github.com/users/backus/events{/privacy}","received_events_url":"https://api.github.com/users/backus/received_events","type":"User","site_admin":false},"body":"I add this conditional to handle for if there is one or multiple nodes in the body.  If there is only one then we don't want to wrap it with `s(:begin, ...)` because it looks like unparser then finds the output to be different in the `Mutant::Meta::Example`.  ","created_at":"2015-08-16T02:33:45Z","updated_at":"2015-08-16T02:33:45Z","html_url":"https://github.com/mbj/mutant/pull/419#discussion_r37141269","pull_request_url":"https://api.github.com/repos/mbj/mutant/pulls/419","_links":{"self":{"href":"https://api.github.com/repos/mbj/mutant/pulls/comments/37141269"},"html":{"href":"https://github.com/mbj/mutant/pull/419#discussion_r37141269"},"pull_request":{"href":"https://api.github.com/repos/mbj/mutant/pulls/419"}}},"pull_request":{"url":"https://api.github.com/repos/mbj/mutant/pulls/419","id":42529447,"html_url":"https://github.com/mbj/mutant/pull/419","diff_url":"https://github.com/mbj/mutant/pull/419.diff","patch_url":"https://github.com/mbj/mutant/pull/419.patch","issue_url":"https://api.github.com/repos/mbj/mutant/issues/419","number":419,"state":"open","locked":false,"title":"[WIP] Add mutation to replace `def foo(arg = default)` with `def foo; arg = default`.","user":{"login":"backus","id":2085622,"avatar_url":"https://avatars.githubusercontent.com/u/2085622?v=3","gravatar_id":"","url":"https://api.github.com/users/backus","html_url":"https://github.com/backus","followers_url":"https://api.github.com/users/backus/followers","following_url":"https://api.github.com/users/backus/following{/other_user}","gists_url":"https://api.github.com/users/backus/gists{/gist_id}","starred_url":"https://api.github.com/users/backus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backus/subscriptions","organizations_url":"https://api.github.com/users/backus/orgs","repos_url":"https://api.github.com/users/backus/repos","events_url":"https://api.github.com/users/backus/events{/privacy}","received_events_url":"https://api.github.com/users/backus/received_events","type":"User","site_admin":false},"body":"WIP for #310.  I know this is ugly now. I wasn't sure though if there is a generic way that similar mutations handle this, so I figured I would ask before I invested time into a specific solution.  I'll add a few comments for things that seem strange.","created_at":"2015-08-16T02:30:37Z","updated_at":"2015-08-16T02:33:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"169f3b636f7892ead4d9cce9a6fb6bdd0c8674b1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mbj/mutant/pulls/419/commits","review_comments_url":"https://api.github.com/repos/mbj/mutant/pulls/419/comments","review_comment_url":"https://api.github.com/repos/mbj/mutant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mbj/mutant/issues/419/comments","statuses_url":"https://api.github.com/repos/mbj/mutant/statuses/cb707dfa5bbef208f89c7875eae825d8903d6d93","head":{"label":"backus:enhancement/default-args-mutation","ref":"enhancement/default-args-mutation","sha":"cb707dfa5bbef208f89c7875eae825d8903d6d93","user":{"login":"backus","id":2085622,"avatar_url":"https://avatars.githubusercontent.com/u/2085622?v=3","gravatar_id":"","url":"https://api.github.com/users/backus","html_url":"https://github.com/backus","followers_url":"https://api.github.com/users/backus/followers","following_url":"https://api.github.com/users/backus/following{/other_user}","gists_url":"https://api.github.com/users/backus/gists{/gist_id}","starred_url":"https://api.github.com/users/backus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backus/subscriptions","organizations_url":"https://api.github.com/users/backus/orgs","repos_url":"https://api.github.com/users/backus/repos","events_url":"https://api.github.com/users/backus/events{/privacy}","received_events_url":"https://api.github.com/users/backus/received_events","type":"User","site_admin":false},"repo":{"id":40461113,"name":"mutant","full_name":"backus/mutant","owner":{"login":"backus","id":2085622,"avatar_url":"https://avatars.githubusercontent.com/u/2085622?v=3","gravatar_id":"","url":"https://api.github.com/users/backus","html_url":"https://github.com/backus","followers_url":"https://api.github.com/users/backus/followers","following_url":"https://api.github.com/users/backus/following{/other_user}","gists_url":"https://api.github.com/users/backus/gists{/gist_id}","starred_url":"https://api.github.com/users/backus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backus/subscriptions","organizations_url":"https://api.github.com/users/backus/orgs","repos_url":"https://api.github.com/users/backus/repos","events_url":"https://api.github.com/users/backus/events{/privacy}","received_events_url":"https://api.github.com/users/backus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/backus/mutant","description":"Mutation testing for Ruby","fork":true,"url":"https://api.github.com/repos/backus/mutant","forks_url":"https://api.github.com/repos/backus/mutant/forks","keys_url":"https://api.github.com/repos/backus/mutant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/backus/mutant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/backus/mutant/teams","hooks_url":"https://api.github.com/repos/backus/mutant/hooks","issue_events_url":"https://api.github.com/repos/backus/mutant/issues/events{/number}","events_url":"https://api.github.com/repos/backus/mutant/events","assignees_url":"https://api.github.com/repos/backus/mutant/assignees{/user}","branches_url":"https://api.github.com/repos/backus/mutant/branches{/branch}","tags_url":"https://api.github.com/repos/backus/mutant/tags","blobs_url":"https://api.github.com/repos/backus/mutant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/backus/mutant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/backus/mutant/git/refs{/sha}","trees_url":"https://api.github.com/repos/backus/mutant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/backus/mutant/statuses/{sha}","languages_url":"https://api.github.com/repos/backus/mutant/languages","stargazers_url":"https://api.github.com/repos/backus/mutant/stargazers","contributors_url":"https://api.github.com/repos/backus/mutant/contributors","subscribers_url":"https://api.github.com/repos/backus/mutant/subscribers","subscription_url":"https://api.github.com/repos/backus/mutant/subscription","commits_url":"https://api.github.com/repos/backus/mutant/commits{/sha}","git_commits_url":"https://api.github.com/repos/backus/mutant/git/commits{/sha}","comments_url":"https://api.github.com/repos/backus/mutant/comments{/number}","issue_comment_url":"https://api.github.com/repos/backus/mutant/issues/comments{/number}","contents_url":"https://api.github.com/repos/backus/mutant/contents/{+path}","compare_url":"https://api.github.com/repos/backus/mutant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/backus/mutant/merges","archive_url":"https://api.github.com/repos/backus/mutant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/backus/mutant/downloads","issues_url":"https://api.github.com/repos/backus/mutant/issues{/number}","pulls_url":"https://api.github.com/repos/backus/mutant/pulls{/number}","milestones_url":"https://api.github.com/repos/backus/mutant/milestones{/number}","notifications_url":"https://api.github.com/repos/backus/mutant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/backus/mutant/labels{/name}","releases_url":"https://api.github.com/repos/backus/mutant/releases{/id}","created_at":"2015-08-10T03:23:49Z","updated_at":"2015-08-10T03:23:50Z","pushed_at":"2015-08-16T02:26:35Z","git_url":"git://github.com/backus/mutant.git","ssh_url":"git@github.com:backus/mutant.git","clone_url":"https://github.com/backus/mutant.git","svn_url":"https://github.com/backus/mutant","homepage":"","size":3247,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mbj:master","ref":"master","sha":"0f2e4117f259d468689f0da2bc66653a48da3ee5","user":{"login":"mbj","id":117966,"avatar_url":"https://avatars.githubusercontent.com/u/117966?v=3","gravatar_id":"","url":"https://api.github.com/users/mbj","html_url":"https://github.com/mbj","followers_url":"https://api.github.com/users/mbj/followers","following_url":"https://api.github.com/users/mbj/following{/other_user}","gists_url":"https://api.github.com/users/mbj/gists{/gist_id}","starred_url":"https://api.github.com/users/mbj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbj/subscriptions","organizations_url":"https://api.github.com/users/mbj/orgs","repos_url":"https://api.github.com/users/mbj/repos","events_url":"https://api.github.com/users/mbj/events{/privacy}","received_events_url":"https://api.github.com/users/mbj/received_events","type":"User","site_admin":false},"repo":{"id":5152718,"name":"mutant","full_name":"mbj/mutant","owner":{"login":"mbj","id":117966,"avatar_url":"https://avatars.githubusercontent.com/u/117966?v=3","gravatar_id":"","url":"https://api.github.com/users/mbj","html_url":"https://github.com/mbj","followers_url":"https://api.github.com/users/mbj/followers","following_url":"https://api.github.com/users/mbj/following{/other_user}","gists_url":"https://api.github.com/users/mbj/gists{/gist_id}","starred_url":"https://api.github.com/users/mbj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbj/subscriptions","organizations_url":"https://api.github.com/users/mbj/orgs","repos_url":"https://api.github.com/users/mbj/repos","events_url":"https://api.github.com/users/mbj/events{/privacy}","received_events_url":"https://api.github.com/users/mbj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mbj/mutant","description":"Mutation testing for Ruby","fork":false,"url":"https://api.github.com/repos/mbj/mutant","forks_url":"https://api.github.com/repos/mbj/mutant/forks","keys_url":"https://api.github.com/repos/mbj/mutant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mbj/mutant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mbj/mutant/teams","hooks_url":"https://api.github.com/repos/mbj/mutant/hooks","issue_events_url":"https://api.github.com/repos/mbj/mutant/issues/events{/number}","events_url":"https://api.github.com/repos/mbj/mutant/events","assignees_url":"https://api.github.com/repos/mbj/mutant/assignees{/user}","branches_url":"https://api.github.com/repos/mbj/mutant/branches{/branch}","tags_url":"https://api.github.com/repos/mbj/mutant/tags","blobs_url":"https://api.github.com/repos/mbj/mutant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mbj/mutant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mbj/mutant/git/refs{/sha}","trees_url":"https://api.github.com/repos/mbj/mutant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mbj/mutant/statuses/{sha}","languages_url":"https://api.github.com/repos/mbj/mutant/languages","stargazers_url":"https://api.github.com/repos/mbj/mutant/stargazers","contributors_url":"https://api.github.com/repos/mbj/mutant/contributors","subscribers_url":"https://api.github.com/repos/mbj/mutant/subscribers","subscription_url":"https://api.github.com/repos/mbj/mutant/subscription","commits_url":"https://api.github.com/repos/mbj/mutant/commits{/sha}","git_commits_url":"https://api.github.com/repos/mbj/mutant/git/commits{/sha}","comments_url":"https://api.github.com/repos/mbj/mutant/comments{/number}","issue_comment_url":"https://api.github.com/repos/mbj/mutant/issues/comments{/number}","contents_url":"https://api.github.com/repos/mbj/mutant/contents/{+path}","compare_url":"https://api.github.com/repos/mbj/mutant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mbj/mutant/merges","archive_url":"https://api.github.com/repos/mbj/mutant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mbj/mutant/downloads","issues_url":"https://api.github.com/repos/mbj/mutant/issues{/number}","pulls_url":"https://api.github.com/repos/mbj/mutant/pulls{/number}","milestones_url":"https://api.github.com/repos/mbj/mutant/milestones{/number}","notifications_url":"https://api.github.com/repos/mbj/mutant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mbj/mutant/labels{/name}","releases_url":"https://api.github.com/repos/mbj/mutant/releases{/id}","created_at":"2012-07-23T14:18:46Z","updated_at":"2015-08-14T12:16:41Z","pushed_at":"2015-08-16T02:30:37Z","git_url":"git://github.com/mbj/mutant.git","ssh_url":"git@github.com:mbj/mutant.git","clone_url":"https://github.com/mbj/mutant.git","svn_url":"https://github.com/mbj/mutant","homepage":"","size":8312,"stargazers_count":782,"watchers_count":782,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":56,"mirror_url":null,"open_issues_count":84,"forks":56,"open_issues":84,"watchers":782,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mbj/mutant/pulls/419"},"html":{"href":"https://github.com/mbj/mutant/pull/419"},"issue":{"href":"https://api.github.com/repos/mbj/mutant/issues/419"},"comments":{"href":"https://api.github.com/repos/mbj/mutant/issues/419/comments"},"review_comments":{"href":"https://api.github.com/repos/mbj/mutant/pulls/419/comments"},"review_comment":{"href":"https://api.github.com/repos/mbj/mutant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mbj/mutant/pulls/419/commits"},"statuses":{"href":"https://api.github.com/repos/mbj/mutant/statuses/cb707dfa5bbef208f89c7875eae825d8903d6d93"}}}}