{"action":"created","comment":{"url":"https://api.github.com/repos/dart-lang/linter/pulls/comments/109919630","pull_request_review_id":31052575,"id":109919630,"diff_hunk":"@@ -0,0 +1,81 @@\n+// Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file\n+// for details. All rights reserved. Use of this source code is governed by a\n+// BSD-style license that can be found in the LICENSE file.\n+\n+library linter.src.rules.avoid_annotating_types_on_function_expressions;\n+\n+import 'package:analyzer/dart/ast/ast.dart';\n+import 'package:analyzer/dart/ast/visitor.dart';\n+import 'package:linter/src/analyzer.dart';\n+import 'package:linter/src/util/dart_type_utilities.dart';\n+\n+const _desc = r'Avoid annotating types on function expressions.';\n+\n+const _details = r'''\n+\n+**AVOID** annotating types on function expressions.\n+\n+**BAD:**\n+```\n+var names = people.map((Person person) => person.name);\n+```\n+\n+**GOOD:**\n+```\n+var names = people.map((person) => person.name);\n+```\n+\n+''';\n+\n+bool _doesNotHaveType(SimpleFormalParameter parameter) {\n+  return parameter?.type != null && parameter.type.name.name != 'dynamic';\n+}\n+\n+SimpleFormalParameter _getSimpleFormalParameter(FormalParameter node) {\n+  if (node is SimpleFormalParameter) {\n+    return node;\n+  }\n+  final simpleFormalParameters = DartTypeUtilities\n+      .traverseNodesInDFS(node)\n+      .where(_isSimpleFormalParameter);\n+  return simpleFormalParameters.isNotEmpty","path":"lib/src/rules/avoid_types_on_closure_parameters.dart","position":41,"original_position":41,"commit_id":"5061fd59cb19736890151376442abfdc9c672ab9","original_commit_id":"6205a8b31e02428ce6e16ebb0b5e97b217f5926d","user":{"login":"bwilkerson","id":5840555,"avatar_url":"https://avatars2.githubusercontent.com/u/5840555?v=3","gravatar_id":"","url":"https://api.github.com/users/bwilkerson","html_url":"https://github.com/bwilkerson","followers_url":"https://api.github.com/users/bwilkerson/followers","following_url":"https://api.github.com/users/bwilkerson/following{/other_user}","gists_url":"https://api.github.com/users/bwilkerson/gists{/gist_id}","starred_url":"https://api.github.com/users/bwilkerson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwilkerson/subscriptions","organizations_url":"https://api.github.com/users/bwilkerson/orgs","repos_url":"https://api.github.com/users/bwilkerson/repos","events_url":"https://api.github.com/users/bwilkerson/events{/privacy}","received_events_url":"https://api.github.com/users/bwilkerson/received_events","type":"User","site_admin":false},"body":"There isn't any reason to traverse the whole AST, and in fact it's wrong when you consider function typed formal parameters. This really needs to be something like:\r\n```\r\nif (node is DefaultFormalParameter) {\r\n  node = node.parameter;\r\n}\r\nif (node is SimpleFormalParameter) {\r\n  return node;\r\n}\r\nreturn null;\r\n```","created_at":"2017-04-05T13:47:45Z","updated_at":"2017-04-05T13:51:00Z","html_url":"https://github.com/dart-lang/linter/pull/545#discussion_r109919630","pull_request_url":"https://api.github.com/repos/dart-lang/linter/pulls/545","_links":{"self":{"href":"https://api.github.com/repos/dart-lang/linter/pulls/comments/109919630"},"html":{"href":"https://github.com/dart-lang/linter/pull/545#discussion_r109919630"},"pull_request":{"href":"https://api.github.com/repos/dart-lang/linter/pulls/545"}}},"pull_request":{"url":"https://api.github.com/repos/dart-lang/linter/pulls/545","id":113086992,"html_url":"https://github.com/dart-lang/linter/pull/545","diff_url":"https://github.com/dart-lang/linter/pull/545.diff","patch_url":"https://github.com/dart-lang/linter/pull/545.patch","issue_url":"https://api.github.com/repos/dart-lang/linter/issues/545","number":545,"state":"open","locked":false,"title":"New rule: avoid_types_on_closure_parameters","user":{"login":"JPaulsen","id":8152167,"avatar_url":"https://avatars0.githubusercontent.com/u/8152167?v=3","gravatar_id":"","url":"https://api.github.com/users/JPaulsen","html_url":"https://github.com/JPaulsen","followers_url":"https://api.github.com/users/JPaulsen/followers","following_url":"https://api.github.com/users/JPaulsen/following{/other_user}","gists_url":"https://api.github.com/users/JPaulsen/gists{/gist_id}","starred_url":"https://api.github.com/users/JPaulsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JPaulsen/subscriptions","organizations_url":"https://api.github.com/users/JPaulsen/orgs","repos_url":"https://api.github.com/users/JPaulsen/repos","events_url":"https://api.github.com/users/JPaulsen/events{/privacy}","received_events_url":"https://api.github.com/users/JPaulsen/received_events","type":"User","site_admin":false},"body":"Fixes https://github.com/dart-lang/linter/issues/543","created_at":"2017-03-28T23:12:51Z","updated_at":"2017-04-05T13:51:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d24d73acde253a32e4aa514fa4a5bfecc76c79b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dart-lang/linter/pulls/545/commits","review_comments_url":"https://api.github.com/repos/dart-lang/linter/pulls/545/comments","review_comment_url":"https://api.github.com/repos/dart-lang/linter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dart-lang/linter/issues/545/comments","statuses_url":"https://api.github.com/repos/dart-lang/linter/statuses/5061fd59cb19736890151376442abfdc9c672ab9","head":{"label":"JPaulsen:avoid_annotating_types_on_function_expressions","ref":"avoid_annotating_types_on_function_expressions","sha":"5061fd59cb19736890151376442abfdc9c672ab9","user":{"login":"JPaulsen","id":8152167,"avatar_url":"https://avatars0.githubusercontent.com/u/8152167?v=3","gravatar_id":"","url":"https://api.github.com/users/JPaulsen","html_url":"https://github.com/JPaulsen","followers_url":"https://api.github.com/users/JPaulsen/followers","following_url":"https://api.github.com/users/JPaulsen/following{/other_user}","gists_url":"https://api.github.com/users/JPaulsen/gists{/gist_id}","starred_url":"https://api.github.com/users/JPaulsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JPaulsen/subscriptions","organizations_url":"https://api.github.com/users/JPaulsen/orgs","repos_url":"https://api.github.com/users/JPaulsen/repos","events_url":"https://api.github.com/users/JPaulsen/events{/privacy}","received_events_url":"https://api.github.com/users/JPaulsen/received_events","type":"User","site_admin":false},"repo":{"id":82239528,"name":"linter","full_name":"JPaulsen/linter","owner":{"login":"JPaulsen","id":8152167,"avatar_url":"https://avatars0.githubusercontent.com/u/8152167?v=3","gravatar_id":"","url":"https://api.github.com/users/JPaulsen","html_url":"https://github.com/JPaulsen","followers_url":"https://api.github.com/users/JPaulsen/followers","following_url":"https://api.github.com/users/JPaulsen/following{/other_user}","gists_url":"https://api.github.com/users/JPaulsen/gists{/gist_id}","starred_url":"https://api.github.com/users/JPaulsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JPaulsen/subscriptions","organizations_url":"https://api.github.com/users/JPaulsen/orgs","repos_url":"https://api.github.com/users/JPaulsen/repos","events_url":"https://api.github.com/users/JPaulsen/events{/privacy}","received_events_url":"https://api.github.com/users/JPaulsen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JPaulsen/linter","description":"Style linter for Dart.","fork":true,"url":"https://api.github.com/repos/JPaulsen/linter","forks_url":"https://api.github.com/repos/JPaulsen/linter/forks","keys_url":"https://api.github.com/repos/JPaulsen/linter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JPaulsen/linter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JPaulsen/linter/teams","hooks_url":"https://api.github.com/repos/JPaulsen/linter/hooks","issue_events_url":"https://api.github.com/repos/JPaulsen/linter/issues/events{/number}","events_url":"https://api.github.com/repos/JPaulsen/linter/events","assignees_url":"https://api.github.com/repos/JPaulsen/linter/assignees{/user}","branches_url":"https://api.github.com/repos/JPaulsen/linter/branches{/branch}","tags_url":"https://api.github.com/repos/JPaulsen/linter/tags","blobs_url":"https://api.github.com/repos/JPaulsen/linter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JPaulsen/linter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JPaulsen/linter/git/refs{/sha}","trees_url":"https://api.github.com/repos/JPaulsen/linter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JPaulsen/linter/statuses/{sha}","languages_url":"https://api.github.com/repos/JPaulsen/linter/languages","stargazers_url":"https://api.github.com/repos/JPaulsen/linter/stargazers","contributors_url":"https://api.github.com/repos/JPaulsen/linter/contributors","subscribers_url":"https://api.github.com/repos/JPaulsen/linter/subscribers","subscription_url":"https://api.github.com/repos/JPaulsen/linter/subscription","commits_url":"https://api.github.com/repos/JPaulsen/linter/commits{/sha}","git_commits_url":"https://api.github.com/repos/JPaulsen/linter/git/commits{/sha}","comments_url":"https://api.github.com/repos/JPaulsen/linter/comments{/number}","issue_comment_url":"https://api.github.com/repos/JPaulsen/linter/issues/comments{/number}","contents_url":"https://api.github.com/repos/JPaulsen/linter/contents/{+path}","compare_url":"https://api.github.com/repos/JPaulsen/linter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JPaulsen/linter/merges","archive_url":"https://api.github.com/repos/JPaulsen/linter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JPaulsen/linter/downloads","issues_url":"https://api.github.com/repos/JPaulsen/linter/issues{/number}","pulls_url":"https://api.github.com/repos/JPaulsen/linter/pulls{/number}","milestones_url":"https://api.github.com/repos/JPaulsen/linter/milestones{/number}","notifications_url":"https://api.github.com/repos/JPaulsen/linter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JPaulsen/linter/labels{/name}","releases_url":"https://api.github.com/repos/JPaulsen/linter/releases{/id}","deployments_url":"https://api.github.com/repos/JPaulsen/linter/deployments","created_at":"2017-02-17T00:25:20Z","updated_at":"2017-02-17T00:25:22Z","pushed_at":"2017-04-03T23:02:38Z","git_url":"git://github.com/JPaulsen/linter.git","ssh_url":"git@github.com:JPaulsen/linter.git","clone_url":"https://github.com/JPaulsen/linter.git","svn_url":"https://github.com/JPaulsen/linter","homepage":"https://dart-lang.github.io/linter/","size":1052,"stargazers_count":0,"watchers_count":0,"language":"Dart","has_issues":false,"has_projects":true,"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":"dart-lang:master","ref":"master","sha":"7ed8a180bed8830ec18b33c8e34412820ae29121","user":{"login":"dart-lang","id":1609975,"avatar_url":"https://avatars3.githubusercontent.com/u/1609975?v=3","gravatar_id":"","url":"https://api.github.com/users/dart-lang","html_url":"https://github.com/dart-lang","followers_url":"https://api.github.com/users/dart-lang/followers","following_url":"https://api.github.com/users/dart-lang/following{/other_user}","gists_url":"https://api.github.com/users/dart-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/dart-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dart-lang/subscriptions","organizations_url":"https://api.github.com/users/dart-lang/orgs","repos_url":"https://api.github.com/users/dart-lang/repos","events_url":"https://api.github.com/users/dart-lang/events{/privacy}","received_events_url":"https://api.github.com/users/dart-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":29209166,"name":"linter","full_name":"dart-lang/linter","owner":{"login":"dart-lang","id":1609975,"avatar_url":"https://avatars3.githubusercontent.com/u/1609975?v=3","gravatar_id":"","url":"https://api.github.com/users/dart-lang","html_url":"https://github.com/dart-lang","followers_url":"https://api.github.com/users/dart-lang/followers","following_url":"https://api.github.com/users/dart-lang/following{/other_user}","gists_url":"https://api.github.com/users/dart-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/dart-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dart-lang/subscriptions","organizations_url":"https://api.github.com/users/dart-lang/orgs","repos_url":"https://api.github.com/users/dart-lang/repos","events_url":"https://api.github.com/users/dart-lang/events{/privacy}","received_events_url":"https://api.github.com/users/dart-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dart-lang/linter","description":"Style linter for Dart.","fork":false,"url":"https://api.github.com/repos/dart-lang/linter","forks_url":"https://api.github.com/repos/dart-lang/linter/forks","keys_url":"https://api.github.com/repos/dart-lang/linter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dart-lang/linter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dart-lang/linter/teams","hooks_url":"https://api.github.com/repos/dart-lang/linter/hooks","issue_events_url":"https://api.github.com/repos/dart-lang/linter/issues/events{/number}","events_url":"https://api.github.com/repos/dart-lang/linter/events","assignees_url":"https://api.github.com/repos/dart-lang/linter/assignees{/user}","branches_url":"https://api.github.com/repos/dart-lang/linter/branches{/branch}","tags_url":"https://api.github.com/repos/dart-lang/linter/tags","blobs_url":"https://api.github.com/repos/dart-lang/linter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dart-lang/linter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dart-lang/linter/git/refs{/sha}","trees_url":"https://api.github.com/repos/dart-lang/linter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dart-lang/linter/statuses/{sha}","languages_url":"https://api.github.com/repos/dart-lang/linter/languages","stargazers_url":"https://api.github.com/repos/dart-lang/linter/stargazers","contributors_url":"https://api.github.com/repos/dart-lang/linter/contributors","subscribers_url":"https://api.github.com/repos/dart-lang/linter/subscribers","subscription_url":"https://api.github.com/repos/dart-lang/linter/subscription","commits_url":"https://api.github.com/repos/dart-lang/linter/commits{/sha}","git_commits_url":"https://api.github.com/repos/dart-lang/linter/git/commits{/sha}","comments_url":"https://api.github.com/repos/dart-lang/linter/comments{/number}","issue_comment_url":"https://api.github.com/repos/dart-lang/linter/issues/comments{/number}","contents_url":"https://api.github.com/repos/dart-lang/linter/contents/{+path}","compare_url":"https://api.github.com/repos/dart-lang/linter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dart-lang/linter/merges","archive_url":"https://api.github.com/repos/dart-lang/linter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dart-lang/linter/downloads","issues_url":"https://api.github.com/repos/dart-lang/linter/issues{/number}","pulls_url":"https://api.github.com/repos/dart-lang/linter/pulls{/number}","milestones_url":"https://api.github.com/repos/dart-lang/linter/milestones{/number}","notifications_url":"https://api.github.com/repos/dart-lang/linter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dart-lang/linter/labels{/name}","releases_url":"https://api.github.com/repos/dart-lang/linter/releases{/id}","deployments_url":"https://api.github.com/repos/dart-lang/linter/deployments","created_at":"2015-01-13T20:21:11Z","updated_at":"2017-02-24T23:49:49Z","pushed_at":"2017-04-04T20:10:01Z","git_url":"git://github.com/dart-lang/linter.git","ssh_url":"git@github.com:dart-lang/linter.git","clone_url":"https://github.com/dart-lang/linter.git","svn_url":"https://github.com/dart-lang/linter","homepage":"https://dart-lang.github.io/linter/","size":1013,"stargazers_count":33,"watchers_count":33,"language":"Dart","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":24,"mirror_url":null,"open_issues_count":148,"forks":24,"open_issues":148,"watchers":33,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dart-lang/linter/pulls/545"},"html":{"href":"https://github.com/dart-lang/linter/pull/545"},"issue":{"href":"https://api.github.com/repos/dart-lang/linter/issues/545"},"comments":{"href":"https://api.github.com/repos/dart-lang/linter/issues/545/comments"},"review_comments":{"href":"https://api.github.com/repos/dart-lang/linter/pulls/545/comments"},"review_comment":{"href":"https://api.github.com/repos/dart-lang/linter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dart-lang/linter/pulls/545/commits"},"statuses":{"href":"https://api.github.com/repos/dart-lang/linter/statuses/5061fd59cb19736890151376442abfdc9c672ab9"}}}}
{"actor":{"display_login":"bwilkerson"}}