{"action":"created","comment":{"url":"https://api.github.com/repos/bbatsov/rubocop/pulls/comments/104326799","pull_request_review_id":25158707,"id":104326799,"diff_hunk":"@@ -0,0 +1,58 @@\n+# frozen_string_literal: true\n+\n+module RuboCop\n+  module Cop\n+    module Lint\n+      # This cop checks for ambiguous block association with method\n+      # when param passed without parentheses.\n+      #\n+      # @example\n+      #\n+      #   # bad\n+      #\n+      #   # It's ambiguous because there is no parentheses around `a` param\n+      #   some_method a { |val| puts val }\n+      #\n+      # @example\n+      #\n+      #   # good\n+      #\n+      #   # With parentheses, there's no ambiguity.\n+      #   some_method(a) { |val| puts val }\n+      class AmbiguousBlockAssociation < Cop\n+        MSG = 'Parenthesize the param `%s` to make sure that block will be '\\\n+              'associated with `%s` method call.'.freeze\n+\n+        def on_send(node)\n+          return if node.parenthesized? || node.assignment? || node.method?(:[])\n+\n+          return unless method_with_block?(node.first_argument)\n+          first_child = node.first_argument.children.first\n+          return unless method_as_param?(first_child)\n+\n+          add_offense(\n+            node, :expression, format_error(first_child, node.method_name)\n+          )\n+        end\n+\n+        private\n+\n+        def method_with_block?(args)\n+          return false unless args\n+\n+          args.block_type?\n+        end\n+\n+        def method_as_param?(node)\n+          return false unless node.is_a?(RuboCop::AST::Node)\n+\n+          node.send_type? && !node.arguments?\n+        end\n+\n+        def format_error(param, method_name)","path":"lib/rubocop/cop/lint/ambiguous_block_association.rb","position":52,"original_position":52,"commit_id":"6d959d74dde347298208ce159762a5238b296b0e","original_commit_id":"6d959d74dde347298208ce159762a5238b296b0e","user":{"login":"bbatsov","id":103882,"avatar_url":"https://avatars3.githubusercontent.com/u/103882?v=3","gravatar_id":"","url":"https://api.github.com/users/bbatsov","html_url":"https://github.com/bbatsov","followers_url":"https://api.github.com/users/bbatsov/followers","following_url":"https://api.github.com/users/bbatsov/following{/other_user}","gists_url":"https://api.github.com/users/bbatsov/gists{/gist_id}","starred_url":"https://api.github.com/users/bbatsov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbatsov/subscriptions","organizations_url":"https://api.github.com/users/bbatsov/orgs","repos_url":"https://api.github.com/users/bbatsov/repos","events_url":"https://api.github.com/users/bbatsov/events{/privacy}","received_events_url":"https://api.github.com/users/bbatsov/received_events","type":"User","site_admin":false},"body":"param might not be the best name here","created_at":"2017-03-05T22:37:42Z","updated_at":"2017-03-05T22:37:42Z","html_url":"https://github.com/bbatsov/rubocop/pull/4090#discussion_r104326799","pull_request_url":"https://api.github.com/repos/bbatsov/rubocop/pulls/4090","_links":{"self":{"href":"https://api.github.com/repos/bbatsov/rubocop/pulls/comments/104326799"},"html":{"href":"https://github.com/bbatsov/rubocop/pull/4090#discussion_r104326799"},"pull_request":{"href":"https://api.github.com/repos/bbatsov/rubocop/pulls/4090"}}},"pull_request":{"url":"https://api.github.com/repos/bbatsov/rubocop/pulls/4090","id":109086231,"html_url":"https://github.com/bbatsov/rubocop/pull/4090","diff_url":"https://github.com/bbatsov/rubocop/pull/4090.diff","patch_url":"https://github.com/bbatsov/rubocop/pull/4090.patch","issue_url":"https://api.github.com/repos/bbatsov/rubocop/issues/4090","number":4090,"state":"open","locked":false,"title":"[FIX #3931] Implement a cop checking for ambiguous block association …","user":{"login":"smakagon","id":71746,"avatar_url":"https://avatars2.githubusercontent.com/u/71746?v=3","gravatar_id":"","url":"https://api.github.com/users/smakagon","html_url":"https://github.com/smakagon","followers_url":"https://api.github.com/users/smakagon/followers","following_url":"https://api.github.com/users/smakagon/following{/other_user}","gists_url":"https://api.github.com/users/smakagon/gists{/gist_id}","starred_url":"https://api.github.com/users/smakagon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smakagon/subscriptions","organizations_url":"https://api.github.com/users/smakagon/orgs","repos_url":"https://api.github.com/users/smakagon/repos","events_url":"https://api.github.com/users/smakagon/events{/privacy}","received_events_url":"https://api.github.com/users/smakagon/received_events","type":"User","site_admin":false},"body":"…with a method\r\n\r\nThis cop checks for ambiguous block association with method when param passed without parentheses.\r\n\r\nExample:\r\nIt's ambiguous because there is no parentheses around `a` param:\r\n`some_method a { |val| puts val }`\r\n\r\nWith parentheses, there's no ambiguity:\r\n`some_method(a) { |val| puts val }`\r\n\r\nCop will add warning message:\r\nParenthesize the param to make sure that block will be associated with method call.","created_at":"2017-03-04T01:24:51Z","updated_at":"2017-03-05T22:37:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"288c47acb98a042e27a9cee370e8b05bf92219f1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bbatsov/rubocop/pulls/4090/commits","review_comments_url":"https://api.github.com/repos/bbatsov/rubocop/pulls/4090/comments","review_comment_url":"https://api.github.com/repos/bbatsov/rubocop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bbatsov/rubocop/issues/4090/comments","statuses_url":"https://api.github.com/repos/bbatsov/rubocop/statuses/6d959d74dde347298208ce159762a5238b296b0e","head":{"label":"smakagon:ambiguous_block_association","ref":"ambiguous_block_association","sha":"6d959d74dde347298208ce159762a5238b296b0e","user":{"login":"smakagon","id":71746,"avatar_url":"https://avatars2.githubusercontent.com/u/71746?v=3","gravatar_id":"","url":"https://api.github.com/users/smakagon","html_url":"https://github.com/smakagon","followers_url":"https://api.github.com/users/smakagon/followers","following_url":"https://api.github.com/users/smakagon/following{/other_user}","gists_url":"https://api.github.com/users/smakagon/gists{/gist_id}","starred_url":"https://api.github.com/users/smakagon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smakagon/subscriptions","organizations_url":"https://api.github.com/users/smakagon/orgs","repos_url":"https://api.github.com/users/smakagon/repos","events_url":"https://api.github.com/users/smakagon/events{/privacy}","received_events_url":"https://api.github.com/users/smakagon/received_events","type":"User","site_admin":false},"repo":{"id":82936344,"name":"rubocop","full_name":"smakagon/rubocop","owner":{"login":"smakagon","id":71746,"avatar_url":"https://avatars2.githubusercontent.com/u/71746?v=3","gravatar_id":"","url":"https://api.github.com/users/smakagon","html_url":"https://github.com/smakagon","followers_url":"https://api.github.com/users/smakagon/followers","following_url":"https://api.github.com/users/smakagon/following{/other_user}","gists_url":"https://api.github.com/users/smakagon/gists{/gist_id}","starred_url":"https://api.github.com/users/smakagon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smakagon/subscriptions","organizations_url":"https://api.github.com/users/smakagon/orgs","repos_url":"https://api.github.com/users/smakagon/repos","events_url":"https://api.github.com/users/smakagon/events{/privacy}","received_events_url":"https://api.github.com/users/smakagon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smakagon/rubocop","description":"A Ruby static code analyzer, based on the community Ruby style guide.","fork":true,"url":"https://api.github.com/repos/smakagon/rubocop","forks_url":"https://api.github.com/repos/smakagon/rubocop/forks","keys_url":"https://api.github.com/repos/smakagon/rubocop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smakagon/rubocop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smakagon/rubocop/teams","hooks_url":"https://api.github.com/repos/smakagon/rubocop/hooks","issue_events_url":"https://api.github.com/repos/smakagon/rubocop/issues/events{/number}","events_url":"https://api.github.com/repos/smakagon/rubocop/events","assignees_url":"https://api.github.com/repos/smakagon/rubocop/assignees{/user}","branches_url":"https://api.github.com/repos/smakagon/rubocop/branches{/branch}","tags_url":"https://api.github.com/repos/smakagon/rubocop/tags","blobs_url":"https://api.github.com/repos/smakagon/rubocop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smakagon/rubocop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smakagon/rubocop/git/refs{/sha}","trees_url":"https://api.github.com/repos/smakagon/rubocop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smakagon/rubocop/statuses/{sha}","languages_url":"https://api.github.com/repos/smakagon/rubocop/languages","stargazers_url":"https://api.github.com/repos/smakagon/rubocop/stargazers","contributors_url":"https://api.github.com/repos/smakagon/rubocop/contributors","subscribers_url":"https://api.github.com/repos/smakagon/rubocop/subscribers","subscription_url":"https://api.github.com/repos/smakagon/rubocop/subscription","commits_url":"https://api.github.com/repos/smakagon/rubocop/commits{/sha}","git_commits_url":"https://api.github.com/repos/smakagon/rubocop/git/commits{/sha}","comments_url":"https://api.github.com/repos/smakagon/rubocop/comments{/number}","issue_comment_url":"https://api.github.com/repos/smakagon/rubocop/issues/comments{/number}","contents_url":"https://api.github.com/repos/smakagon/rubocop/contents/{+path}","compare_url":"https://api.github.com/repos/smakagon/rubocop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smakagon/rubocop/merges","archive_url":"https://api.github.com/repos/smakagon/rubocop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smakagon/rubocop/downloads","issues_url":"https://api.github.com/repos/smakagon/rubocop/issues{/number}","pulls_url":"https://api.github.com/repos/smakagon/rubocop/pulls{/number}","milestones_url":"https://api.github.com/repos/smakagon/rubocop/milestones{/number}","notifications_url":"https://api.github.com/repos/smakagon/rubocop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smakagon/rubocop/labels{/name}","releases_url":"https://api.github.com/repos/smakagon/rubocop/releases{/id}","deployments_url":"https://api.github.com/repos/smakagon/rubocop/deployments","created_at":"2017-02-23T14:41:01Z","updated_at":"2017-02-23T14:41:05Z","pushed_at":"2017-03-05T14:06:14Z","git_url":"git://github.com/smakagon/rubocop.git","ssh_url":"git@github.com:smakagon/rubocop.git","clone_url":"https://github.com/smakagon/rubocop.git","svn_url":"https://github.com/smakagon/rubocop","homepage":"http://rubocop.readthedocs.io","size":15408,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"bbatsov:master","ref":"master","sha":"fb78b21ce408dfddaeb3f3d20182a4481845ce11","user":{"login":"bbatsov","id":103882,"avatar_url":"https://avatars3.githubusercontent.com/u/103882?v=3","gravatar_id":"","url":"https://api.github.com/users/bbatsov","html_url":"https://github.com/bbatsov","followers_url":"https://api.github.com/users/bbatsov/followers","following_url":"https://api.github.com/users/bbatsov/following{/other_user}","gists_url":"https://api.github.com/users/bbatsov/gists{/gist_id}","starred_url":"https://api.github.com/users/bbatsov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbatsov/subscriptions","organizations_url":"https://api.github.com/users/bbatsov/orgs","repos_url":"https://api.github.com/users/bbatsov/repos","events_url":"https://api.github.com/users/bbatsov/events{/privacy}","received_events_url":"https://api.github.com/users/bbatsov/received_events","type":"User","site_admin":false},"repo":{"id":4095287,"name":"rubocop","full_name":"bbatsov/rubocop","owner":{"login":"bbatsov","id":103882,"avatar_url":"https://avatars3.githubusercontent.com/u/103882?v=3","gravatar_id":"","url":"https://api.github.com/users/bbatsov","html_url":"https://github.com/bbatsov","followers_url":"https://api.github.com/users/bbatsov/followers","following_url":"https://api.github.com/users/bbatsov/following{/other_user}","gists_url":"https://api.github.com/users/bbatsov/gists{/gist_id}","starred_url":"https://api.github.com/users/bbatsov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbatsov/subscriptions","organizations_url":"https://api.github.com/users/bbatsov/orgs","repos_url":"https://api.github.com/users/bbatsov/repos","events_url":"https://api.github.com/users/bbatsov/events{/privacy}","received_events_url":"https://api.github.com/users/bbatsov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bbatsov/rubocop","description":"A Ruby static code analyzer, based on the community Ruby style guide.","fork":false,"url":"https://api.github.com/repos/bbatsov/rubocop","forks_url":"https://api.github.com/repos/bbatsov/rubocop/forks","keys_url":"https://api.github.com/repos/bbatsov/rubocop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bbatsov/rubocop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bbatsov/rubocop/teams","hooks_url":"https://api.github.com/repos/bbatsov/rubocop/hooks","issue_events_url":"https://api.github.com/repos/bbatsov/rubocop/issues/events{/number}","events_url":"https://api.github.com/repos/bbatsov/rubocop/events","assignees_url":"https://api.github.com/repos/bbatsov/rubocop/assignees{/user}","branches_url":"https://api.github.com/repos/bbatsov/rubocop/branches{/branch}","tags_url":"https://api.github.com/repos/bbatsov/rubocop/tags","blobs_url":"https://api.github.com/repos/bbatsov/rubocop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bbatsov/rubocop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bbatsov/rubocop/git/refs{/sha}","trees_url":"https://api.github.com/repos/bbatsov/rubocop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bbatsov/rubocop/statuses/{sha}","languages_url":"https://api.github.com/repos/bbatsov/rubocop/languages","stargazers_url":"https://api.github.com/repos/bbatsov/rubocop/stargazers","contributors_url":"https://api.github.com/repos/bbatsov/rubocop/contributors","subscribers_url":"https://api.github.com/repos/bbatsov/rubocop/subscribers","subscription_url":"https://api.github.com/repos/bbatsov/rubocop/subscription","commits_url":"https://api.github.com/repos/bbatsov/rubocop/commits{/sha}","git_commits_url":"https://api.github.com/repos/bbatsov/rubocop/git/commits{/sha}","comments_url":"https://api.github.com/repos/bbatsov/rubocop/comments{/number}","issue_comment_url":"https://api.github.com/repos/bbatsov/rubocop/issues/comments{/number}","contents_url":"https://api.github.com/repos/bbatsov/rubocop/contents/{+path}","compare_url":"https://api.github.com/repos/bbatsov/rubocop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bbatsov/rubocop/merges","archive_url":"https://api.github.com/repos/bbatsov/rubocop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bbatsov/rubocop/downloads","issues_url":"https://api.github.com/repos/bbatsov/rubocop/issues{/number}","pulls_url":"https://api.github.com/repos/bbatsov/rubocop/pulls{/number}","milestones_url":"https://api.github.com/repos/bbatsov/rubocop/milestones{/number}","notifications_url":"https://api.github.com/repos/bbatsov/rubocop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bbatsov/rubocop/labels{/name}","releases_url":"https://api.github.com/repos/bbatsov/rubocop/releases{/id}","deployments_url":"https://api.github.com/repos/bbatsov/rubocop/deployments","created_at":"2012-04-21T10:09:58Z","updated_at":"2017-03-05T17:41:32Z","pushed_at":"2017-03-05T16:44:21Z","git_url":"git://github.com/bbatsov/rubocop.git","ssh_url":"git@github.com:bbatsov/rubocop.git","clone_url":"https://github.com/bbatsov/rubocop.git","svn_url":"https://github.com/bbatsov/rubocop","homepage":"http://rubocop.readthedocs.io","size":15411,"stargazers_count":7376,"watchers_count":7376,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1219,"mirror_url":null,"open_issues_count":174,"forks":1219,"open_issues":174,"watchers":7376,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bbatsov/rubocop/pulls/4090"},"html":{"href":"https://github.com/bbatsov/rubocop/pull/4090"},"issue":{"href":"https://api.github.com/repos/bbatsov/rubocop/issues/4090"},"comments":{"href":"https://api.github.com/repos/bbatsov/rubocop/issues/4090/comments"},"review_comments":{"href":"https://api.github.com/repos/bbatsov/rubocop/pulls/4090/comments"},"review_comment":{"href":"https://api.github.com/repos/bbatsov/rubocop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bbatsov/rubocop/pulls/4090/commits"},"statuses":{"href":"https://api.github.com/repos/bbatsov/rubocop/statuses/6d959d74dde347298208ce159762a5238b296b0e"}}}}
{"actor":{"display_login":"bbatsov"}}