{"action":"created","comment":{"url":"https://api.github.com/repos/codeclimate/codeclimate/pulls/comments/39196262","id":39196262,"diff_hunk":"@@ -0,0 +1,156 @@\n+module CC\n+  module Analyzer\n+    class IncludePathsBuilder\n+      def initialize(cc_exclude_paths)\n+        @cc_exclude_paths = cc_exclude_paths\n+      end\n+\n+      def build\n+        root = Directory.new('.', ignored_files)\n+        paths = root.included_paths\n+        paths.each do |path|\n+          raise_on_unreadable_files(path)\n+        end\n+        paths\n+      end\n+\n+      protected\n+\n+      def ignored_files\n+        Tempfile.open(\".cc_gitignore\") do |tmp|\n+          tmp.write(File.read(\".gitignore\")) if File.exist?(\".gitignore\")\n+          tmp << @cc_exclude_paths.join(\"\\n\")\n+          tmp.close\n+          tracked_and_ignored = `git ls-files -zi -X #{tmp.path}`.split(\"\\0\")\n+          untracked_and_ignored = `git ls-files -zio -X #{tmp.path}`.split(\"\\0\")\n+          tracked_and_ignored + untracked_and_ignored\n+        end\n+      end\n+\n+      def included_files\n+        includable_files - ignored_files\n+      end\n+\n+      def includable_files\n+        tracked_in_git = `git ls-files -z`.split(\"\\0\")\n+        untracked_in_git = `git ls-files -zo`.split(\"\\0\")\n+        tracked_in_git + untracked_in_git\n+      end\n+\n+      def raise_on_unreadable_files(path)\n+        if File.directory?(path)\n+          raise_on_unreadable_files_in_directory(path)\n+        elsif !FileUtils.readable_by_all?(path)\n+          raise(CC::Analyzer::UnreadableFileError, \"Can't read #{path}\")","path":"lib/cc/analyzer/include_paths_builder.rb","position":44,"original_position":44,"commit_id":"15757f942e4a6df7f36138aebc1588b459238eaf","original_commit_id":"15757f942e4a6df7f36138aebc1588b459238eaf","user":{"login":"pbrisbin","id":50812,"avatar_url":"https://avatars.githubusercontent.com/u/50812?v=3","gravatar_id":"","url":"https://api.github.com/users/pbrisbin","html_url":"https://github.com/pbrisbin","followers_url":"https://api.github.com/users/pbrisbin/followers","following_url":"https://api.github.com/users/pbrisbin/following{/other_user}","gists_url":"https://api.github.com/users/pbrisbin/gists{/gist_id}","starred_url":"https://api.github.com/users/pbrisbin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbrisbin/subscriptions","organizations_url":"https://api.github.com/users/pbrisbin/orgs","repos_url":"https://api.github.com/users/pbrisbin/repos","events_url":"https://api.github.com/users/pbrisbin/events{/privacy}","received_events_url":"https://api.github.com/users/pbrisbin/received_events","type":"User","site_admin":false},"body":":lipstick: no parens on `raise`","created_at":"2015-09-10T18:32:52Z","updated_at":"2015-09-10T18:32:52Z","html_url":"https://github.com/codeclimate/codeclimate/pull/107#discussion_r39196262","pull_request_url":"https://api.github.com/repos/codeclimate/codeclimate/pulls/107","_links":{"self":{"href":"https://api.github.com/repos/codeclimate/codeclimate/pulls/comments/39196262"},"html":{"href":"https://github.com/codeclimate/codeclimate/pull/107#discussion_r39196262"},"pull_request":{"href":"https://api.github.com/repos/codeclimate/codeclimate/pulls/107"}}},"pull_request":{"url":"https://api.github.com/repos/codeclimate/codeclimate/pulls/107","id":44569187,"html_url":"https://github.com/codeclimate/codeclimate/pull/107","diff_url":"https://github.com/codeclimate/codeclimate/pull/107.diff","patch_url":"https://github.com/codeclimate/codeclimate/pull/107.patch","issue_url":"https://api.github.com/repos/codeclimate/codeclimate/issues/107","number":107,"state":"open","locked":false,"title":"Emit include_paths for use by engines.","user":{"login":"fhwang","id":10196,"avatar_url":"https://avatars.githubusercontent.com/u/10196?v=3","gravatar_id":"","url":"https://api.github.com/users/fhwang","html_url":"https://github.com/fhwang","followers_url":"https://api.github.com/users/fhwang/followers","following_url":"https://api.github.com/users/fhwang/following{/other_user}","gists_url":"https://api.github.com/users/fhwang/gists{/gist_id}","starred_url":"https://api.github.com/users/fhwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhwang/subscriptions","organizations_url":"https://api.github.com/users/fhwang/orgs","repos_url":"https://api.github.com/users/fhwang/repos","events_url":"https://api.github.com/users/fhwang/events{/privacy}","received_events_url":"https://api.github.com/users/fhwang/received_events","type":"User","site_admin":false},"body":"The path reduction goes top-down recursively, plucking unreadable files etc. FYI it takes less than a second on the Discourse repo.","created_at":"2015-09-09T16:06:39Z","updated_at":"2015-09-10T18:32:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38a548fee5e9c4f7329ec7c6bb8e3cb8c7998617","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codeclimate/codeclimate/pulls/107/commits","review_comments_url":"https://api.github.com/repos/codeclimate/codeclimate/pulls/107/comments","review_comment_url":"https://api.github.com/repos/codeclimate/codeclimate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codeclimate/codeclimate/issues/107/comments","statuses_url":"https://api.github.com/repos/codeclimate/codeclimate/statuses/15757f942e4a6df7f36138aebc1588b459238eaf","head":{"label":"codeclimate:include-paths","ref":"include-paths","sha":"15757f942e4a6df7f36138aebc1588b459238eaf","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":37724576,"name":"codeclimate","full_name":"codeclimate/codeclimate","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","description":"Code Climate CLI","fork":false,"url":"https://api.github.com/repos/codeclimate/codeclimate","forks_url":"https://api.github.com/repos/codeclimate/codeclimate/forks","keys_url":"https://api.github.com/repos/codeclimate/codeclimate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codeclimate/codeclimate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codeclimate/codeclimate/teams","hooks_url":"https://api.github.com/repos/codeclimate/codeclimate/hooks","issue_events_url":"https://api.github.com/repos/codeclimate/codeclimate/issues/events{/number}","events_url":"https://api.github.com/repos/codeclimate/codeclimate/events","assignees_url":"https://api.github.com/repos/codeclimate/codeclimate/assignees{/user}","branches_url":"https://api.github.com/repos/codeclimate/codeclimate/branches{/branch}","tags_url":"https://api.github.com/repos/codeclimate/codeclimate/tags","blobs_url":"https://api.github.com/repos/codeclimate/codeclimate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codeclimate/codeclimate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codeclimate/codeclimate/git/refs{/sha}","trees_url":"https://api.github.com/repos/codeclimate/codeclimate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codeclimate/codeclimate/statuses/{sha}","languages_url":"https://api.github.com/repos/codeclimate/codeclimate/languages","stargazers_url":"https://api.github.com/repos/codeclimate/codeclimate/stargazers","contributors_url":"https://api.github.com/repos/codeclimate/codeclimate/contributors","subscribers_url":"https://api.github.com/repos/codeclimate/codeclimate/subscribers","subscription_url":"https://api.github.com/repos/codeclimate/codeclimate/subscription","commits_url":"https://api.github.com/repos/codeclimate/codeclimate/commits{/sha}","git_commits_url":"https://api.github.com/repos/codeclimate/codeclimate/git/commits{/sha}","comments_url":"https://api.github.com/repos/codeclimate/codeclimate/comments{/number}","issue_comment_url":"https://api.github.com/repos/codeclimate/codeclimate/issues/comments{/number}","contents_url":"https://api.github.com/repos/codeclimate/codeclimate/contents/{+path}","compare_url":"https://api.github.com/repos/codeclimate/codeclimate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codeclimate/codeclimate/merges","archive_url":"https://api.github.com/repos/codeclimate/codeclimate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codeclimate/codeclimate/downloads","issues_url":"https://api.github.com/repos/codeclimate/codeclimate/issues{/number}","pulls_url":"https://api.github.com/repos/codeclimate/codeclimate/pulls{/number}","milestones_url":"https://api.github.com/repos/codeclimate/codeclimate/milestones{/number}","notifications_url":"https://api.github.com/repos/codeclimate/codeclimate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codeclimate/codeclimate/labels{/name}","releases_url":"https://api.github.com/repos/codeclimate/codeclimate/releases{/id}","created_at":"2015-06-19T13:54:41Z","updated_at":"2015-09-10T14:58:11Z","pushed_at":"2015-09-10T17:25:46Z","git_url":"git://github.com/codeclimate/codeclimate.git","ssh_url":"git@github.com:codeclimate/codeclimate.git","clone_url":"https://github.com/codeclimate/codeclimate.git","svn_url":"https://github.com/codeclimate/codeclimate","homepage":null,"size":1258,"stargazers_count":464,"watchers_count":464,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":12,"forks":34,"open_issues":12,"watchers":464,"default_branch":"master"}},"base":{"label":"codeclimate:master","ref":"master","sha":"fcd8609ff92dd9405f3b710f0105d90ec54b1ac0","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":37724576,"name":"codeclimate","full_name":"codeclimate/codeclimate","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","description":"Code Climate CLI","fork":false,"url":"https://api.github.com/repos/codeclimate/codeclimate","forks_url":"https://api.github.com/repos/codeclimate/codeclimate/forks","keys_url":"https://api.github.com/repos/codeclimate/codeclimate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codeclimate/codeclimate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codeclimate/codeclimate/teams","hooks_url":"https://api.github.com/repos/codeclimate/codeclimate/hooks","issue_events_url":"https://api.github.com/repos/codeclimate/codeclimate/issues/events{/number}","events_url":"https://api.github.com/repos/codeclimate/codeclimate/events","assignees_url":"https://api.github.com/repos/codeclimate/codeclimate/assignees{/user}","branches_url":"https://api.github.com/repos/codeclimate/codeclimate/branches{/branch}","tags_url":"https://api.github.com/repos/codeclimate/codeclimate/tags","blobs_url":"https://api.github.com/repos/codeclimate/codeclimate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codeclimate/codeclimate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codeclimate/codeclimate/git/refs{/sha}","trees_url":"https://api.github.com/repos/codeclimate/codeclimate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codeclimate/codeclimate/statuses/{sha}","languages_url":"https://api.github.com/repos/codeclimate/codeclimate/languages","stargazers_url":"https://api.github.com/repos/codeclimate/codeclimate/stargazers","contributors_url":"https://api.github.com/repos/codeclimate/codeclimate/contributors","subscribers_url":"https://api.github.com/repos/codeclimate/codeclimate/subscribers","subscription_url":"https://api.github.com/repos/codeclimate/codeclimate/subscription","commits_url":"https://api.github.com/repos/codeclimate/codeclimate/commits{/sha}","git_commits_url":"https://api.github.com/repos/codeclimate/codeclimate/git/commits{/sha}","comments_url":"https://api.github.com/repos/codeclimate/codeclimate/comments{/number}","issue_comment_url":"https://api.github.com/repos/codeclimate/codeclimate/issues/comments{/number}","contents_url":"https://api.github.com/repos/codeclimate/codeclimate/contents/{+path}","compare_url":"https://api.github.com/repos/codeclimate/codeclimate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codeclimate/codeclimate/merges","archive_url":"https://api.github.com/repos/codeclimate/codeclimate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codeclimate/codeclimate/downloads","issues_url":"https://api.github.com/repos/codeclimate/codeclimate/issues{/number}","pulls_url":"https://api.github.com/repos/codeclimate/codeclimate/pulls{/number}","milestones_url":"https://api.github.com/repos/codeclimate/codeclimate/milestones{/number}","notifications_url":"https://api.github.com/repos/codeclimate/codeclimate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codeclimate/codeclimate/labels{/name}","releases_url":"https://api.github.com/repos/codeclimate/codeclimate/releases{/id}","created_at":"2015-06-19T13:54:41Z","updated_at":"2015-09-10T14:58:11Z","pushed_at":"2015-09-10T17:25:46Z","git_url":"git://github.com/codeclimate/codeclimate.git","ssh_url":"git@github.com:codeclimate/codeclimate.git","clone_url":"https://github.com/codeclimate/codeclimate.git","svn_url":"https://github.com/codeclimate/codeclimate","homepage":null,"size":1258,"stargazers_count":464,"watchers_count":464,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":12,"forks":34,"open_issues":12,"watchers":464,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codeclimate/codeclimate/pulls/107"},"html":{"href":"https://github.com/codeclimate/codeclimate/pull/107"},"issue":{"href":"https://api.github.com/repos/codeclimate/codeclimate/issues/107"},"comments":{"href":"https://api.github.com/repos/codeclimate/codeclimate/issues/107/comments"},"review_comments":{"href":"https://api.github.com/repos/codeclimate/codeclimate/pulls/107/comments"},"review_comment":{"href":"https://api.github.com/repos/codeclimate/codeclimate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codeclimate/codeclimate/pulls/107/commits"},"statuses":{"href":"https://api.github.com/repos/codeclimate/codeclimate/statuses/15757f942e4a6df7f36138aebc1588b459238eaf"}}}}