{"action":"created","comment":{"url":"https://api.github.com/repos/prehnRA/lintron/pulls/comments/42916383","id":42916383,"diff_hunk":"@@ -0,0 +1,88 @@\n+module Linters\n+  class SpecsRequired < Linters::Base\n+    def config\n+      HashWithIndifferentAccess.new({\n+        rb: {\n+          spec_file_ext: 'rb',\n+          app_path_pattern: %r{[^/]+/(?<path>[^\\Z]+)\\Z},\n+        },\n+        /\\A(js|es6|jsx)\\Z/ => {\n+          spec_file_ext: 'js',\n+          app_path_pattern: %r{app/assets/(?<path>[^\\Z]+)\\Z},\n+        },\n+      })\n+    end\n+\n+    def config_for_extname(extname)\n+      config.find do |pattern, config|\n+        pattern = Regexp.new(\"\\\\A#{pattern}\\\\Z\") unless pattern.class < Regexp\n+        pattern.match(extname)\n+      end[1]\n+    end\n+\n+    def run(pr)\n+      files_needing_specs(pr)\n+        .flat_map { |f| check_for_matching_spec(pr, f) }\n+        .compact\n+    end\n+\n+    def files_needing_specs(pr)\n+      pr.files\n+        .select { |f| requires_spec?(f.extname) }\n+        .reject { |f| is_spec?(f.path) }\n+    end\n+\n+    def is_spec?(filename)\n+      /\\A(spec|test)/.match(filename)\n+    end\n+\n+    def is_spec_for?(base, candidate)\n+      return false unless is_spec?(candidate.path)\n+       \"#{base.basename('.*')}_spec\" == candidate.basename('.*')\n+    end\n+\n+    def requires_spec?(extname)\n+      config_for_extname(extname).present?\n+    end\n+\n+    def check_for_matching_spec(pr, file)\n+      unless pr.files.any? { |candidate| is_spec_for?(file, candidate) }\n+        spec_missing_violation_for(pr, file)\n+      end\n+    end\n+\n+    def spec_missing_violation_for(pr, file)\n+      Violation.new(\n+        file: file,\n+        line: 1 ,\n+        message: <<-message.strip_heredoc\n+          Expected changes or additions to a test file called [#{expected_spec_filename(file)}](#{expected_spec_url(pr, file)})","path":"app/models/linters/specs_required.rb","position":59,"original_position":59,"commit_id":"ada8898e75fb690d4bc52e00eebcdc846f538bbe","original_commit_id":"ada8898e75fb690d4bc52e00eebcdc846f538bbe","user":{"login":"lintomat","id":12354882,"avatar_url":"https://avatars.githubusercontent.com/u/12354882?v=3","gravatar_id":"","url":"https://api.github.com/users/lintomat","html_url":"https://github.com/lintomat","followers_url":"https://api.github.com/users/lintomat/followers","following_url":"https://api.github.com/users/lintomat/following{/other_user}","gists_url":"https://api.github.com/users/lintomat/gists{/gist_id}","starred_url":"https://api.github.com/users/lintomat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lintomat/subscriptions","organizations_url":"https://api.github.com/users/lintomat/orgs","repos_url":"https://api.github.com/users/lintomat/repos","events_url":"https://api.github.com/users/lintomat/events{/privacy}","received_events_url":"https://api.github.com/users/lintomat/received_events","type":"User","site_admin":false},"body":"Line is too long. [127/80]","created_at":"2015-10-23T21:28:55Z","updated_at":"2015-10-23T21:28:55Z","html_url":"https://github.com/prehnRA/lintron/pull/39#discussion_r42916383","pull_request_url":"https://api.github.com/repos/prehnRA/lintron/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/prehnRA/lintron/pulls/comments/42916383"},"html":{"href":"https://github.com/prehnRA/lintron/pull/39#discussion_r42916383"},"pull_request":{"href":"https://api.github.com/repos/prehnRA/lintron/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/prehnRA/lintron/pulls/39","id":48632288,"html_url":"https://github.com/prehnRA/lintron/pull/39","diff_url":"https://github.com/prehnRA/lintron/pull/39.diff","patch_url":"https://github.com/prehnRA/lintron/pull/39.patch","issue_url":"https://api.github.com/repos/prehnRA/lintron/issues/39","number":39,"state":"open","locked":false,"title":"SpecsRequired Linter","user":{"login":"prehnRA","id":3952444,"avatar_url":"https://avatars.githubusercontent.com/u/3952444?v=3","gravatar_id":"","url":"https://api.github.com/users/prehnRA","html_url":"https://github.com/prehnRA","followers_url":"https://api.github.com/users/prehnRA/followers","following_url":"https://api.github.com/users/prehnRA/following{/other_user}","gists_url":"https://api.github.com/users/prehnRA/gists{/gist_id}","starred_url":"https://api.github.com/users/prehnRA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prehnRA/subscriptions","organizations_url":"https://api.github.com/users/prehnRA/orgs","repos_url":"https://api.github.com/users/prehnRA/repos","events_url":"https://api.github.com/users/prehnRA/events{/privacy}","received_events_url":"https://api.github.com/users/prehnRA/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-23T21:28:53Z","updated_at":"2015-10-23T21:28:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dff25e9d73ce9c8c9801aecd80a175080806af9d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prehnRA/lintron/pulls/39/commits","review_comments_url":"https://api.github.com/repos/prehnRA/lintron/pulls/39/comments","review_comment_url":"https://api.github.com/repos/prehnRA/lintron/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prehnRA/lintron/issues/39/comments","statuses_url":"https://api.github.com/repos/prehnRA/lintron/statuses/ada8898e75fb690d4bc52e00eebcdc846f538bbe","head":{"label":"prehnRA:f-spec-linter","ref":"f-spec-linter","sha":"ada8898e75fb690d4bc52e00eebcdc846f538bbe","user":{"login":"prehnRA","id":3952444,"avatar_url":"https://avatars.githubusercontent.com/u/3952444?v=3","gravatar_id":"","url":"https://api.github.com/users/prehnRA","html_url":"https://github.com/prehnRA","followers_url":"https://api.github.com/users/prehnRA/followers","following_url":"https://api.github.com/users/prehnRA/following{/other_user}","gists_url":"https://api.github.com/users/prehnRA/gists{/gist_id}","starred_url":"https://api.github.com/users/prehnRA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prehnRA/subscriptions","organizations_url":"https://api.github.com/users/prehnRA/orgs","repos_url":"https://api.github.com/users/prehnRA/repos","events_url":"https://api.github.com/users/prehnRA/events{/privacy}","received_events_url":"https://api.github.com/users/prehnRA/received_events","type":"User","site_admin":false},"repo":{"id":34999057,"name":"lintron","full_name":"prehnRA/lintron","owner":{"login":"prehnRA","id":3952444,"avatar_url":"https://avatars.githubusercontent.com/u/3952444?v=3","gravatar_id":"","url":"https://api.github.com/users/prehnRA","html_url":"https://github.com/prehnRA","followers_url":"https://api.github.com/users/prehnRA/followers","following_url":"https://api.github.com/users/prehnRA/following{/other_user}","gists_url":"https://api.github.com/users/prehnRA/gists{/gist_id}","starred_url":"https://api.github.com/users/prehnRA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prehnRA/subscriptions","organizations_url":"https://api.github.com/users/prehnRA/orgs","repos_url":"https://api.github.com/users/prehnRA/repos","events_url":"https://api.github.com/users/prehnRA/events{/privacy}","received_events_url":"https://api.github.com/users/prehnRA/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/prehnRA/lintron","description":"An experiment in automated linting of pull requests.","fork":false,"url":"https://api.github.com/repos/prehnRA/lintron","forks_url":"https://api.github.com/repos/prehnRA/lintron/forks","keys_url":"https://api.github.com/repos/prehnRA/lintron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prehnRA/lintron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prehnRA/lintron/teams","hooks_url":"https://api.github.com/repos/prehnRA/lintron/hooks","issue_events_url":"https://api.github.com/repos/prehnRA/lintron/issues/events{/number}","events_url":"https://api.github.com/repos/prehnRA/lintron/events","assignees_url":"https://api.github.com/repos/prehnRA/lintron/assignees{/user}","branches_url":"https://api.github.com/repos/prehnRA/lintron/branches{/branch}","tags_url":"https://api.github.com/repos/prehnRA/lintron/tags","blobs_url":"https://api.github.com/repos/prehnRA/lintron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prehnRA/lintron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prehnRA/lintron/git/refs{/sha}","trees_url":"https://api.github.com/repos/prehnRA/lintron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prehnRA/lintron/statuses/{sha}","languages_url":"https://api.github.com/repos/prehnRA/lintron/languages","stargazers_url":"https://api.github.com/repos/prehnRA/lintron/stargazers","contributors_url":"https://api.github.com/repos/prehnRA/lintron/contributors","subscribers_url":"https://api.github.com/repos/prehnRA/lintron/subscribers","subscription_url":"https://api.github.com/repos/prehnRA/lintron/subscription","commits_url":"https://api.github.com/repos/prehnRA/lintron/commits{/sha}","git_commits_url":"https://api.github.com/repos/prehnRA/lintron/git/commits{/sha}","comments_url":"https://api.github.com/repos/prehnRA/lintron/comments{/number}","issue_comment_url":"https://api.github.com/repos/prehnRA/lintron/issues/comments{/number}","contents_url":"https://api.github.com/repos/prehnRA/lintron/contents/{+path}","compare_url":"https://api.github.com/repos/prehnRA/lintron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prehnRA/lintron/merges","archive_url":"https://api.github.com/repos/prehnRA/lintron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prehnRA/lintron/downloads","issues_url":"https://api.github.com/repos/prehnRA/lintron/issues{/number}","pulls_url":"https://api.github.com/repos/prehnRA/lintron/pulls{/number}","milestones_url":"https://api.github.com/repos/prehnRA/lintron/milestones{/number}","notifications_url":"https://api.github.com/repos/prehnRA/lintron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prehnRA/lintron/labels{/name}","releases_url":"https://api.github.com/repos/prehnRA/lintron/releases{/id}","created_at":"2015-05-03T20:07:48Z","updated_at":"2015-05-08T20:40:27Z","pushed_at":"2015-10-23T21:28:53Z","git_url":"git://github.com/prehnRA/lintron.git","ssh_url":"git@github.com:prehnRA/lintron.git","clone_url":"https://github.com/prehnRA/lintron.git","svn_url":"https://github.com/prehnRA/lintron","homepage":null,"size":470,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":18,"forks":1,"open_issues":18,"watchers":0,"default_branch":"master"}},"base":{"label":"prehnRA:master","ref":"master","sha":"064dea2905e5f90e24e1a32bb9d619fd671541ca","user":{"login":"prehnRA","id":3952444,"avatar_url":"https://avatars.githubusercontent.com/u/3952444?v=3","gravatar_id":"","url":"https://api.github.com/users/prehnRA","html_url":"https://github.com/prehnRA","followers_url":"https://api.github.com/users/prehnRA/followers","following_url":"https://api.github.com/users/prehnRA/following{/other_user}","gists_url":"https://api.github.com/users/prehnRA/gists{/gist_id}","starred_url":"https://api.github.com/users/prehnRA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prehnRA/subscriptions","organizations_url":"https://api.github.com/users/prehnRA/orgs","repos_url":"https://api.github.com/users/prehnRA/repos","events_url":"https://api.github.com/users/prehnRA/events{/privacy}","received_events_url":"https://api.github.com/users/prehnRA/received_events","type":"User","site_admin":false},"repo":{"id":34999057,"name":"lintron","full_name":"prehnRA/lintron","owner":{"login":"prehnRA","id":3952444,"avatar_url":"https://avatars.githubusercontent.com/u/3952444?v=3","gravatar_id":"","url":"https://api.github.com/users/prehnRA","html_url":"https://github.com/prehnRA","followers_url":"https://api.github.com/users/prehnRA/followers","following_url":"https://api.github.com/users/prehnRA/following{/other_user}","gists_url":"https://api.github.com/users/prehnRA/gists{/gist_id}","starred_url":"https://api.github.com/users/prehnRA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prehnRA/subscriptions","organizations_url":"https://api.github.com/users/prehnRA/orgs","repos_url":"https://api.github.com/users/prehnRA/repos","events_url":"https://api.github.com/users/prehnRA/events{/privacy}","received_events_url":"https://api.github.com/users/prehnRA/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/prehnRA/lintron","description":"An experiment in automated linting of pull requests.","fork":false,"url":"https://api.github.com/repos/prehnRA/lintron","forks_url":"https://api.github.com/repos/prehnRA/lintron/forks","keys_url":"https://api.github.com/repos/prehnRA/lintron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prehnRA/lintron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prehnRA/lintron/teams","hooks_url":"https://api.github.com/repos/prehnRA/lintron/hooks","issue_events_url":"https://api.github.com/repos/prehnRA/lintron/issues/events{/number}","events_url":"https://api.github.com/repos/prehnRA/lintron/events","assignees_url":"https://api.github.com/repos/prehnRA/lintron/assignees{/user}","branches_url":"https://api.github.com/repos/prehnRA/lintron/branches{/branch}","tags_url":"https://api.github.com/repos/prehnRA/lintron/tags","blobs_url":"https://api.github.com/repos/prehnRA/lintron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prehnRA/lintron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prehnRA/lintron/git/refs{/sha}","trees_url":"https://api.github.com/repos/prehnRA/lintron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prehnRA/lintron/statuses/{sha}","languages_url":"https://api.github.com/repos/prehnRA/lintron/languages","stargazers_url":"https://api.github.com/repos/prehnRA/lintron/stargazers","contributors_url":"https://api.github.com/repos/prehnRA/lintron/contributors","subscribers_url":"https://api.github.com/repos/prehnRA/lintron/subscribers","subscription_url":"https://api.github.com/repos/prehnRA/lintron/subscription","commits_url":"https://api.github.com/repos/prehnRA/lintron/commits{/sha}","git_commits_url":"https://api.github.com/repos/prehnRA/lintron/git/commits{/sha}","comments_url":"https://api.github.com/repos/prehnRA/lintron/comments{/number}","issue_comment_url":"https://api.github.com/repos/prehnRA/lintron/issues/comments{/number}","contents_url":"https://api.github.com/repos/prehnRA/lintron/contents/{+path}","compare_url":"https://api.github.com/repos/prehnRA/lintron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prehnRA/lintron/merges","archive_url":"https://api.github.com/repos/prehnRA/lintron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prehnRA/lintron/downloads","issues_url":"https://api.github.com/repos/prehnRA/lintron/issues{/number}","pulls_url":"https://api.github.com/repos/prehnRA/lintron/pulls{/number}","milestones_url":"https://api.github.com/repos/prehnRA/lintron/milestones{/number}","notifications_url":"https://api.github.com/repos/prehnRA/lintron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prehnRA/lintron/labels{/name}","releases_url":"https://api.github.com/repos/prehnRA/lintron/releases{/id}","created_at":"2015-05-03T20:07:48Z","updated_at":"2015-05-08T20:40:27Z","pushed_at":"2015-10-23T21:28:53Z","git_url":"git://github.com/prehnRA/lintron.git","ssh_url":"git@github.com:prehnRA/lintron.git","clone_url":"https://github.com/prehnRA/lintron.git","svn_url":"https://github.com/prehnRA/lintron","homepage":null,"size":470,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":18,"forks":1,"open_issues":18,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prehnRA/lintron/pulls/39"},"html":{"href":"https://github.com/prehnRA/lintron/pull/39"},"issue":{"href":"https://api.github.com/repos/prehnRA/lintron/issues/39"},"comments":{"href":"https://api.github.com/repos/prehnRA/lintron/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/prehnRA/lintron/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/prehnRA/lintron/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prehnRA/lintron/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/prehnRA/lintron/statuses/ada8898e75fb690d4bc52e00eebcdc846f538bbe"}}}}