{"action":"created","comment":{"url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/comments/42133629","id":42133629,"diff_hunk":"@@ -1,69 +1,28 @@\n+require 'cc/engine/analyzers/node'\n+\n module CC\n   module Engine\n     module Analyzers\n       module Python\n-        class Node\n+        class Node < CC::Engine::Analyzers::Node\n           SCRUB_PROPERTIES = [\"_type\", \"attributes\"].freeze\n \n-          def initialize(node, file, default_line = 0)\n-            @node = node\n-            @file = file\n-\n-            set_default_line(default_line)\n-          end\n-\n-          def format\n-            if @node.is_a?(Hash)\n-              type = @node[\"_type\"].to_sym\n-\n-              if valid_properties\n-                create_sexp(type, *properties_to_sexps)\n-              else\n-                type\n-              end\n-            elsif @node.is_a?(Array)\n-              @node.map do |n|\n-                Node.new(n, @file, @line).format\n-              end\n-            end\n-          end\n-\n           private\n \n-          def properties_to_sexps\n-            valid_properties.map do |key, value|\n-              if value.is_a?(Array) || value.is_a?(Hash)\n-                create_sexp(key.to_sym, *Node.new(value, @file, @line).format)\n-              else\n-                create_sexp(key.to_sym, value)\n-              end\n-            end\n-          end\n+          def format_hash\n+            type = @node[\"_type\"].to_sym\n \n-          def create_sexp(*args)\n-            Sexp.new(*args).tap do |sexp|\n-              sexp.file = @file\n-              sexp.line = @line\n-            end\n-          end\n-\n-          def valid_properties\n-            @node.reject do |key, value|\n-              value_empty = [nil, {}, []].include?(value)\n-              SCRUB_PROPERTIES.include?(key) || value_empty\n-            end\n-          end\n-\n-          def set_default_line(default)\n-            if has_line_number?\n-              @line = @node[\"attributes\"][\"lineno\"]\n+            if valid_properties\n+              create_sexp(type, *properties_to_sexps)\n             else\n-              @line = default\n+              type\n             end\n           end\n \n-          def has_line_number?\n-            @node.is_a?(Hash) && @node[\"attributes\"] && @node[\"attributes\"][\"lineno\"]\n+          def line_number\n+            if @node.is_a?(Hash)\n+              @node.fetch(\"attributes\", {}).fetch(\"lineno\", nil)","path":"lib/cc/engine/analyzers/python/node.rb","position":77,"original_position":77,"commit_id":"312c2977c92760a4f2878705a0b6c1547d65c5b8","original_commit_id":"439c34df3ed5b509da3e09af3d2cfd57d6db2c6f","user":{"login":"BlakeWilliams","id":342554,"avatar_url":"https://avatars.githubusercontent.com/u/342554?v=3","gravatar_id":"","url":"https://api.github.com/users/BlakeWilliams","html_url":"https://github.com/BlakeWilliams","followers_url":"https://api.github.com/users/BlakeWilliams/followers","following_url":"https://api.github.com/users/BlakeWilliams/following{/other_user}","gists_url":"https://api.github.com/users/BlakeWilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/BlakeWilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlakeWilliams/subscriptions","organizations_url":"https://api.github.com/users/BlakeWilliams/orgs","repos_url":"https://api.github.com/users/BlakeWilliams/repos","events_url":"https://api.github.com/users/BlakeWilliams/events{/privacy}","received_events_url":"https://api.github.com/users/BlakeWilliams/received_events","type":"User","site_admin":false},"body":"Turns out it raises sine `lineno` doesn't exist in `{}`. I think I'll stick to what's currently there.","created_at":"2015-10-15T14:49:57Z","updated_at":"2015-10-15T14:49:57Z","html_url":"https://github.com/codeclimate/codeclimate-duplication/pull/8#discussion_r42133629","pull_request_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/comments/42133629"},"html":{"href":"https://github.com/codeclimate/codeclimate-duplication/pull/8#discussion_r42133629"},"pull_request":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/8","id":47788188,"html_url":"https://github.com/codeclimate/codeclimate-duplication/pull/8","diff_url":"https://github.com/codeclimate/codeclimate-duplication/pull/8.diff","patch_url":"https://github.com/codeclimate/codeclimate-duplication/pull/8.patch","issue_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues/8","number":8,"state":"open","locked":false,"title":"Migrate from esprima to babel","user":{"login":"BlakeWilliams","id":342554,"avatar_url":"https://avatars.githubusercontent.com/u/342554?v=3","gravatar_id":"","url":"https://api.github.com/users/BlakeWilliams","html_url":"https://github.com/BlakeWilliams","followers_url":"https://api.github.com/users/BlakeWilliams/followers","following_url":"https://api.github.com/users/BlakeWilliams/following{/other_user}","gists_url":"https://api.github.com/users/BlakeWilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/BlakeWilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlakeWilliams/subscriptions","organizations_url":"https://api.github.com/users/BlakeWilliams/orgs","repos_url":"https://api.github.com/users/BlakeWilliams/repos","events_url":"https://api.github.com/users/BlakeWilliams/events{/privacy}","received_events_url":"https://api.github.com/users/BlakeWilliams/received_events","type":"User","site_admin":false},"body":"This PR replaces the esprima ast with babel since babel seems to stay\nmore up to date and also gives us free JSX support.\n\nThis also let us extract `Node` from the Python analyzer into a common\nbase class. This works because all AST's *should* behave mostly the same\nonce turned into JSON with only minor differences here and there.","created_at":"2015-10-15T13:47:37Z","updated_at":"2015-10-15T14:49:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"62d16f02c8bf617b0962570bb7da4b4bb8550dd6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/8/commits","review_comments_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/8/comments","review_comment_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues/8/comments","statuses_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/statuses/312c2977c92760a4f2878705a0b6c1547d65c5b8","head":{"label":"codeclimate:bmw-babel","ref":"bmw-babel","sha":"312c2977c92760a4f2878705a0b6c1547d65c5b8","user":{"login":"codeclimate","id":789641,"avatar_url":"https://avatars.githubusercontent.com/u/789641?v=3","gravatar_id":"","url":"https://api.github.com/users/codeclimate","html_url":"https://github.com/codeclimate","followers_url":"https://api.github.com/users/codeclimate/followers","following_url":"https://api.github.com/users/codeclimate/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate/subscriptions","organizations_url":"https://api.github.com/users/codeclimate/orgs","repos_url":"https://api.github.com/users/codeclimate/repos","events_url":"https://api.github.com/users/codeclimate/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate/received_events","type":"Organization","site_admin":false},"repo":{"id":41421994,"name":"codeclimate-duplication","full_name":"codeclimate/codeclimate-duplication","owner":{"login":"codeclimate","id":789641,"avatar_url":"https://avatars.githubusercontent.com/u/789641?v=3","gravatar_id":"","url":"https://api.github.com/users/codeclimate","html_url":"https://github.com/codeclimate","followers_url":"https://api.github.com/users/codeclimate/followers","following_url":"https://api.github.com/users/codeclimate/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate/subscriptions","organizations_url":"https://api.github.com/users/codeclimate/orgs","repos_url":"https://api.github.com/users/codeclimate/repos","events_url":"https://api.github.com/users/codeclimate/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codeclimate/codeclimate-duplication","description":"Code Climate engine for code duplication analysis","fork":false,"url":"https://api.github.com/repos/codeclimate/codeclimate-duplication","forks_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/forks","keys_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/teams","hooks_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/hooks","issue_events_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues/events{/number}","events_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/events","assignees_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/assignees{/user}","branches_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/branches{/branch}","tags_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/tags","blobs_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/refs{/sha}","trees_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/statuses/{sha}","languages_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/languages","stargazers_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/stargazers","contributors_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/contributors","subscribers_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/subscribers","subscription_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/subscription","commits_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/commits{/sha}","git_commits_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/commits{/sha}","comments_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/comments{/number}","issue_comment_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues/comments{/number}","contents_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/contents/{+path}","compare_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/merges","archive_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/downloads","issues_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues{/number}","pulls_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls{/number}","milestones_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/milestones{/number}","notifications_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/labels{/name}","releases_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/releases{/id}","created_at":"2015-08-26T11:29:43Z","updated_at":"2015-10-13T20:35:37Z","pushed_at":"2015-10-15T14:44:55Z","git_url":"git://github.com/codeclimate/codeclimate-duplication.git","ssh_url":"git@github.com:codeclimate/codeclimate-duplication.git","clone_url":"https://github.com/codeclimate/codeclimate-duplication.git","svn_url":"https://github.com/codeclimate/codeclimate-duplication","homepage":"http://codeclimate.com","size":278,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"codeclimate:master","ref":"master","sha":"04536cf21fdba36b985cd63387d5e04bbc271a23","user":{"login":"codeclimate","id":789641,"avatar_url":"https://avatars.githubusercontent.com/u/789641?v=3","gravatar_id":"","url":"https://api.github.com/users/codeclimate","html_url":"https://github.com/codeclimate","followers_url":"https://api.github.com/users/codeclimate/followers","following_url":"https://api.github.com/users/codeclimate/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate/subscriptions","organizations_url":"https://api.github.com/users/codeclimate/orgs","repos_url":"https://api.github.com/users/codeclimate/repos","events_url":"https://api.github.com/users/codeclimate/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate/received_events","type":"Organization","site_admin":false},"repo":{"id":41421994,"name":"codeclimate-duplication","full_name":"codeclimate/codeclimate-duplication","owner":{"login":"codeclimate","id":789641,"avatar_url":"https://avatars.githubusercontent.com/u/789641?v=3","gravatar_id":"","url":"https://api.github.com/users/codeclimate","html_url":"https://github.com/codeclimate","followers_url":"https://api.github.com/users/codeclimate/followers","following_url":"https://api.github.com/users/codeclimate/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate/subscriptions","organizations_url":"https://api.github.com/users/codeclimate/orgs","repos_url":"https://api.github.com/users/codeclimate/repos","events_url":"https://api.github.com/users/codeclimate/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codeclimate/codeclimate-duplication","description":"Code Climate engine for code duplication analysis","fork":false,"url":"https://api.github.com/repos/codeclimate/codeclimate-duplication","forks_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/forks","keys_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/teams","hooks_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/hooks","issue_events_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues/events{/number}","events_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/events","assignees_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/assignees{/user}","branches_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/branches{/branch}","tags_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/tags","blobs_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/refs{/sha}","trees_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/statuses/{sha}","languages_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/languages","stargazers_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/stargazers","contributors_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/contributors","subscribers_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/subscribers","subscription_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/subscription","commits_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/commits{/sha}","git_commits_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/git/commits{/sha}","comments_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/comments{/number}","issue_comment_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues/comments{/number}","contents_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/contents/{+path}","compare_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/merges","archive_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/downloads","issues_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues{/number}","pulls_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls{/number}","milestones_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/milestones{/number}","notifications_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/labels{/name}","releases_url":"https://api.github.com/repos/codeclimate/codeclimate-duplication/releases{/id}","created_at":"2015-08-26T11:29:43Z","updated_at":"2015-10-13T20:35:37Z","pushed_at":"2015-10-15T14:44:55Z","git_url":"git://github.com/codeclimate/codeclimate-duplication.git","ssh_url":"git@github.com:codeclimate/codeclimate-duplication.git","clone_url":"https://github.com/codeclimate/codeclimate-duplication.git","svn_url":"https://github.com/codeclimate/codeclimate-duplication","homepage":"http://codeclimate.com","size":278,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/8"},"html":{"href":"https://github.com/codeclimate/codeclimate-duplication/pull/8"},"issue":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues/8"},"comments":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/codeclimate/codeclimate-duplication/statuses/312c2977c92760a4f2878705a0b6c1547d65c5b8"}}}}