{"action":"created","comment":{"url":"https://api.github.com/repos/fluxsauce/site_audit/pulls/comments/36432559","id":36432559,"diff_hunk":"@@ -0,0 +1,171 @@\n+<?php\n+/**\n+ * @file\n+ * Contains \\SiteAudit\\Check\\Codebase\\PhpCodeSniffer.\n+ */\n+\n+use Symfony\\Component\\Process\\Process;\n+/**\n+ * Class SiteAuditCheckCodebasePhpCodeSniffer.\n+ */\n+class SiteAuditCheckCodebasePhpCodeSniffer extends SiteAuditCheckAbstract {\n+  /**\n+   * Implements \\SiteAudit\\Check\\Abstract\\getLabel().\n+   */\n+  public function getLabel() {\n+    return dt('PHP Code Sniffer Violations');\n+  }\n+\n+  /**\n+   * Implements \\SiteAudit\\Check\\Abstract\\getDescription().\n+   */\n+  public function getDescription() {\n+    return dt('Run phpcs on custom code.');\n+  }\n+\n+  /**\n+   * Implements \\SiteAudit\\Check\\Abstract\\getResultFail().\n+   */\n+  public function getResultFail() {}\n+\n+  /**\n+   * Implements \\SiteAudit\\Check\\Abstract\\getResultInfo().\n+   */\n+  public function getResultInfo() {\n+    if (isset($this->registry['phpcs_path'])) {\n+      return dt('Cannot find phpcs in path. Make sure that phpcs is present in the PATH or run composer install inside the site_audit directory to install all the dependencies');\n+    }\n+    if (isset($this->registry['custom_code'])) {\n+      return dt('No custom code path specified');\n+    }\n+    return dt('Cannot find coding standards inside ' . $this->registry['phpcs_standard']);\n+  }\n+\n+\n+  /**\n+   * Implements \\SiteAudit\\Check\\Abstract\\getResultPass().\n+   */\n+  public function getResultPass() {\n+    return dt('No PHP code_sniffer violations.');\n+  }\n+\n+\n+  /**\n+   * Implements \\SiteAudit\\Check\\Abstract\\getResultWarn().\n+   */\n+  public function getResultWarn() {\n+    $ret_val = '';\n+    if (drush_get_option('html') == TRUE) {\n+      $ret_val .= '<table class=\"table table-condensed\">';\n+      $ret_val .= '<thead><tr><th>' . dt('Line, Column') . '</th><th>' . dt('Severity') . '</th><th>' . dt('Action') . '</th></tr></thead>';\n+      foreach ($this->registry['phpcs_out'] as $filename => $violations) {\n+        $num_violations = count($violations);\n+        $ret_val .= \"<tr align='center'><td colspan='3'><a href='file:///$filename'>File: $filename</a> Violations: $num_violations</td></tr>\";\n+        foreach ($violations as $violation) {\n+          $line = $violation['line'];\n+          $column = $violation['column'];\n+          $severity = $violation['severity'];\n+          $message = $violation['message'];\n+          $ret_val .= \"<tr><td>$line, $column</td><td>$severity</td><td>$message</td></tr>\";\n+        }\n+      }\n+      $ret_val .= '</table>';\n+    }\n+    else {\n+      $rows = 0;\n+      foreach ($this->registry['phpcs_out'] as $filename => $violations) {\n+        if ($rows++ > 0) {\n+          $ret_val .= PHP_EOL;\n+          if (!drush_get_option('json')) {\n+            $ret_val .= str_repeat(' ', 4);\n+          }\n+        }\n+        $ret_val .= dt('Filename: @filename, Violations: @total', array(\n+          '@filename' => $filename,\n+          '@total' => count($violations),\n+        ));\n+        foreach ($violations as $violation) {\n+          $ret_val .= PHP_EOL;\n+          if (!drush_get_option('json')) {\n+            $ret_val .= str_repeat(' ', 6);\n+          }\n+          $line = $violation['line'];","path":"Check/Codebase/PhpCodeSniffer.php","position":92,"original_position":92,"commit_id":"c73966626975317208eaab7862f866b44824b04d","original_commit_id":"d39c05fa723fb66613eb3db4d946bd3ad698cc02","user":{"login":"fluxsauce","id":976391,"avatar_url":"https://avatars.githubusercontent.com/u/976391?v=3","gravatar_id":"","url":"https://api.github.com/users/fluxsauce","html_url":"https://github.com/fluxsauce","followers_url":"https://api.github.com/users/fluxsauce/followers","following_url":"https://api.github.com/users/fluxsauce/following{/other_user}","gists_url":"https://api.github.com/users/fluxsauce/gists{/gist_id}","starred_url":"https://api.github.com/users/fluxsauce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fluxsauce/subscriptions","organizations_url":"https://api.github.com/users/fluxsauce/orgs","repos_url":"https://api.github.com/users/fluxsauce/repos","events_url":"https://api.github.com/users/fluxsauce/events{/privacy}","received_events_url":"https://api.github.com/users/fluxsauce/received_events","type":"User","site_admin":false},"body":"Avoid single-use variables.","created_at":"2015-08-06T16:06:13Z","updated_at":"2015-08-06T16:06:13Z","html_url":"https://github.com/fluxsauce/site_audit/pull/50#discussion_r36432559","pull_request_url":"https://api.github.com/repos/fluxsauce/site_audit/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/fluxsauce/site_audit/pulls/comments/36432559"},"html":{"href":"https://github.com/fluxsauce/site_audit/pull/50#discussion_r36432559"},"pull_request":{"href":"https://api.github.com/repos/fluxsauce/site_audit/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/fluxsauce/site_audit/pulls/50","id":41415908,"html_url":"https://github.com/fluxsauce/site_audit/pull/50","diff_url":"https://github.com/fluxsauce/site_audit/pull/50.diff","patch_url":"https://github.com/fluxsauce/site_audit/pull/50.patch","issue_url":"https://api.github.com/repos/fluxsauce/site_audit/issues/50","number":50,"state":"open","locked":false,"title":"Codebase report","user":{"login":"shivanshuag","id":1760403,"avatar_url":"https://avatars.githubusercontent.com/u/1760403?v=3","gravatar_id":"","url":"https://api.github.com/users/shivanshuag","html_url":"https://github.com/shivanshuag","followers_url":"https://api.github.com/users/shivanshuag/followers","following_url":"https://api.github.com/users/shivanshuag/following{/other_user}","gists_url":"https://api.github.com/users/shivanshuag/gists{/gist_id}","starred_url":"https://api.github.com/users/shivanshuag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shivanshuag/subscriptions","organizations_url":"https://api.github.com/users/shivanshuag/orgs","repos_url":"https://api.github.com/users/shivanshuag/repos","events_url":"https://api.github.com/users/shivanshuag/events{/privacy}","received_events_url":"https://api.github.com/users/shivanshuag/received_events","type":"User","site_admin":false},"body":"Issue #45 \r\nSteps to test\r\n  * Run composer install to install all the dependencies\r\n  * Run `drush acb --custom_code=[custom code paths separated by comma]`","created_at":"2015-08-02T10:46:24Z","updated_at":"2015-08-06T16:06:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"860ed5c58cbdfb576b0ed14db6daaa7cc27b2cd2","assignee":{"login":"fluxsauce","id":976391,"avatar_url":"https://avatars.githubusercontent.com/u/976391?v=3","gravatar_id":"","url":"https://api.github.com/users/fluxsauce","html_url":"https://github.com/fluxsauce","followers_url":"https://api.github.com/users/fluxsauce/followers","following_url":"https://api.github.com/users/fluxsauce/following{/other_user}","gists_url":"https://api.github.com/users/fluxsauce/gists{/gist_id}","starred_url":"https://api.github.com/users/fluxsauce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fluxsauce/subscriptions","organizations_url":"https://api.github.com/users/fluxsauce/orgs","repos_url":"https://api.github.com/users/fluxsauce/repos","events_url":"https://api.github.com/users/fluxsauce/events{/privacy}","received_events_url":"https://api.github.com/users/fluxsauce/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/fluxsauce/site_audit/milestones/10","html_url":"https://github.com/fluxsauce/site_audit/milestones/GSoC%202015%20-%20Static%20Code%20Analysis","labels_url":"https://api.github.com/repos/fluxsauce/site_audit/milestones/10/labels","id":1086831,"number":10,"title":"GSoC 2015 - Static Code Analysis","description":"","creator":{"login":"fluxsauce","id":976391,"avatar_url":"https://avatars.githubusercontent.com/u/976391?v=3","gravatar_id":"","url":"https://api.github.com/users/fluxsauce","html_url":"https://github.com/fluxsauce","followers_url":"https://api.github.com/users/fluxsauce/followers","following_url":"https://api.github.com/users/fluxsauce/following{/other_user}","gists_url":"https://api.github.com/users/fluxsauce/gists{/gist_id}","starred_url":"https://api.github.com/users/fluxsauce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fluxsauce/subscriptions","organizations_url":"https://api.github.com/users/fluxsauce/orgs","repos_url":"https://api.github.com/users/fluxsauce/repos","events_url":"https://api.github.com/users/fluxsauce/events{/privacy}","received_events_url":"https://api.github.com/users/fluxsauce/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":0,"state":"open","created_at":"2015-04-28T05:34:15Z","updated_at":"2015-08-03T07:20:30Z","due_on":"2015-08-01T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/fluxsauce/site_audit/pulls/50/commits","review_comments_url":"https://api.github.com/repos/fluxsauce/site_audit/pulls/50/comments","review_comment_url":"https://api.github.com/repos/fluxsauce/site_audit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fluxsauce/site_audit/issues/50/comments","statuses_url":"https://api.github.com/repos/fluxsauce/site_audit/statuses/c73966626975317208eaab7862f866b44824b04d","head":{"label":"fluxsauce:codebase-report","ref":"codebase-report","sha":"c73966626975317208eaab7862f866b44824b04d","user":{"login":"fluxsauce","id":976391,"avatar_url":"https://avatars.githubusercontent.com/u/976391?v=3","gravatar_id":"","url":"https://api.github.com/users/fluxsauce","html_url":"https://github.com/fluxsauce","followers_url":"https://api.github.com/users/fluxsauce/followers","following_url":"https://api.github.com/users/fluxsauce/following{/other_user}","gists_url":"https://api.github.com/users/fluxsauce/gists{/gist_id}","starred_url":"https://api.github.com/users/fluxsauce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fluxsauce/subscriptions","organizations_url":"https://api.github.com/users/fluxsauce/orgs","repos_url":"https://api.github.com/users/fluxsauce/repos","events_url":"https://api.github.com/users/fluxsauce/events{/privacy}","received_events_url":"https://api.github.com/users/fluxsauce/received_events","type":"User","site_admin":false},"repo":{"id":18687735,"name":"site_audit","full_name":"fluxsauce/site_audit","owner":{"login":"fluxsauce","id":976391,"avatar_url":"https://avatars.githubusercontent.com/u/976391?v=3","gravatar_id":"","url":"https://api.github.com/users/fluxsauce","html_url":"https://github.com/fluxsauce","followers_url":"https://api.github.com/users/fluxsauce/followers","following_url":"https://api.github.com/users/fluxsauce/following{/other_user}","gists_url":"https://api.github.com/users/fluxsauce/gists{/gist_id}","starred_url":"https://api.github.com/users/fluxsauce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fluxsauce/subscriptions","organizations_url":"https://api.github.com/users/fluxsauce/orgs","repos_url":"https://api.github.com/users/fluxsauce/repos","events_url":"https://api.github.com/users/fluxsauce/events{/privacy}","received_events_url":"https://api.github.com/users/fluxsauce/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fluxsauce/site_audit","description":"Collection of commands that analyze Drupal sites for best practices, performance and more.","fork":false,"url":"https://api.github.com/repos/fluxsauce/site_audit","forks_url":"https://api.github.com/repos/fluxsauce/site_audit/forks","keys_url":"https://api.github.com/repos/fluxsauce/site_audit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fluxsauce/site_audit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fluxsauce/site_audit/teams","hooks_url":"https://api.github.com/repos/fluxsauce/site_audit/hooks","issue_events_url":"https://api.github.com/repos/fluxsauce/site_audit/issues/events{/number}","events_url":"https://api.github.com/repos/fluxsauce/site_audit/events","assignees_url":"https://api.github.com/repos/fluxsauce/site_audit/assignees{/user}","branches_url":"https://api.github.com/repos/fluxsauce/site_audit/branches{/branch}","tags_url":"https://api.github.com/repos/fluxsauce/site_audit/tags","blobs_url":"https://api.github.com/repos/fluxsauce/site_audit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fluxsauce/site_audit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fluxsauce/site_audit/git/refs{/sha}","trees_url":"https://api.github.com/repos/fluxsauce/site_audit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fluxsauce/site_audit/statuses/{sha}","languages_url":"https://api.github.com/repos/fluxsauce/site_audit/languages","stargazers_url":"https://api.github.com/repos/fluxsauce/site_audit/stargazers","contributors_url":"https://api.github.com/repos/fluxsauce/site_audit/contributors","subscribers_url":"https://api.github.com/repos/fluxsauce/site_audit/subscribers","subscription_url":"https://api.github.com/repos/fluxsauce/site_audit/subscription","commits_url":"https://api.github.com/repos/fluxsauce/site_audit/commits{/sha}","git_commits_url":"https://api.github.com/repos/fluxsauce/site_audit/git/commits{/sha}","comments_url":"https://api.github.com/repos/fluxsauce/site_audit/comments{/number}","issue_comment_url":"https://api.github.com/repos/fluxsauce/site_audit/issues/comments{/number}","contents_url":"https://api.github.com/repos/fluxsauce/site_audit/contents/{+path}","compare_url":"https://api.github.com/repos/fluxsauce/site_audit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fluxsauce/site_audit/merges","archive_url":"https://api.github.com/repos/fluxsauce/site_audit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fluxsauce/site_audit/downloads","issues_url":"https://api.github.com/repos/fluxsauce/site_audit/issues{/number}","pulls_url":"https://api.github.com/repos/fluxsauce/site_audit/pulls{/number}","milestones_url":"https://api.github.com/repos/fluxsauce/site_audit/milestones{/number}","notifications_url":"https://api.github.com/repos/fluxsauce/site_audit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fluxsauce/site_audit/labels{/name}","releases_url":"https://api.github.com/repos/fluxsauce/site_audit/releases{/id}","created_at":"2014-04-11T20:27:53Z","updated_at":"2015-07-16T12:10:13Z","pushed_at":"2015-08-06T10:14:06Z","git_url":"git://github.com/fluxsauce/site_audit.git","ssh_url":"git@github.com:fluxsauce/site_audit.git","clone_url":"https://github.com/fluxsauce/site_audit.git","svn_url":"https://github.com/fluxsauce/site_audit","homepage":"https://www.drupal.org/project/site_audit","size":1425,"stargazers_count":5,"watchers_count":5,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":14,"forks":6,"open_issues":14,"watchers":5,"default_branch":"8.x-2.x"}},"base":{"label":"fluxsauce:8.x-2.x","ref":"8.x-2.x","sha":"e5ba76c645558f8e5d79fe8d9ca6a55b360706e3","user":{"login":"fluxsauce","id":976391,"avatar_url":"https://avatars.githubusercontent.com/u/976391?v=3","gravatar_id":"","url":"https://api.github.com/users/fluxsauce","html_url":"https://github.com/fluxsauce","followers_url":"https://api.github.com/users/fluxsauce/followers","following_url":"https://api.github.com/users/fluxsauce/following{/other_user}","gists_url":"https://api.github.com/users/fluxsauce/gists{/gist_id}","starred_url":"https://api.github.com/users/fluxsauce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fluxsauce/subscriptions","organizations_url":"https://api.github.com/users/fluxsauce/orgs","repos_url":"https://api.github.com/users/fluxsauce/repos","events_url":"https://api.github.com/users/fluxsauce/events{/privacy}","received_events_url":"https://api.github.com/users/fluxsauce/received_events","type":"User","site_admin":false},"repo":{"id":18687735,"name":"site_audit","full_name":"fluxsauce/site_audit","owner":{"login":"fluxsauce","id":976391,"avatar_url":"https://avatars.githubusercontent.com/u/976391?v=3","gravatar_id":"","url":"https://api.github.com/users/fluxsauce","html_url":"https://github.com/fluxsauce","followers_url":"https://api.github.com/users/fluxsauce/followers","following_url":"https://api.github.com/users/fluxsauce/following{/other_user}","gists_url":"https://api.github.com/users/fluxsauce/gists{/gist_id}","starred_url":"https://api.github.com/users/fluxsauce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fluxsauce/subscriptions","organizations_url":"https://api.github.com/users/fluxsauce/orgs","repos_url":"https://api.github.com/users/fluxsauce/repos","events_url":"https://api.github.com/users/fluxsauce/events{/privacy}","received_events_url":"https://api.github.com/users/fluxsauce/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fluxsauce/site_audit","description":"Collection of commands that analyze Drupal sites for best practices, performance and more.","fork":false,"url":"https://api.github.com/repos/fluxsauce/site_audit","forks_url":"https://api.github.com/repos/fluxsauce/site_audit/forks","keys_url":"https://api.github.com/repos/fluxsauce/site_audit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fluxsauce/site_audit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fluxsauce/site_audit/teams","hooks_url":"https://api.github.com/repos/fluxsauce/site_audit/hooks","issue_events_url":"https://api.github.com/repos/fluxsauce/site_audit/issues/events{/number}","events_url":"https://api.github.com/repos/fluxsauce/site_audit/events","assignees_url":"https://api.github.com/repos/fluxsauce/site_audit/assignees{/user}","branches_url":"https://api.github.com/repos/fluxsauce/site_audit/branches{/branch}","tags_url":"https://api.github.com/repos/fluxsauce/site_audit/tags","blobs_url":"https://api.github.com/repos/fluxsauce/site_audit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fluxsauce/site_audit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fluxsauce/site_audit/git/refs{/sha}","trees_url":"https://api.github.com/repos/fluxsauce/site_audit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fluxsauce/site_audit/statuses/{sha}","languages_url":"https://api.github.com/repos/fluxsauce/site_audit/languages","stargazers_url":"https://api.github.com/repos/fluxsauce/site_audit/stargazers","contributors_url":"https://api.github.com/repos/fluxsauce/site_audit/contributors","subscribers_url":"https://api.github.com/repos/fluxsauce/site_audit/subscribers","subscription_url":"https://api.github.com/repos/fluxsauce/site_audit/subscription","commits_url":"https://api.github.com/repos/fluxsauce/site_audit/commits{/sha}","git_commits_url":"https://api.github.com/repos/fluxsauce/site_audit/git/commits{/sha}","comments_url":"https://api.github.com/repos/fluxsauce/site_audit/comments{/number}","issue_comment_url":"https://api.github.com/repos/fluxsauce/site_audit/issues/comments{/number}","contents_url":"https://api.github.com/repos/fluxsauce/site_audit/contents/{+path}","compare_url":"https://api.github.com/repos/fluxsauce/site_audit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fluxsauce/site_audit/merges","archive_url":"https://api.github.com/repos/fluxsauce/site_audit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fluxsauce/site_audit/downloads","issues_url":"https://api.github.com/repos/fluxsauce/site_audit/issues{/number}","pulls_url":"https://api.github.com/repos/fluxsauce/site_audit/pulls{/number}","milestones_url":"https://api.github.com/repos/fluxsauce/site_audit/milestones{/number}","notifications_url":"https://api.github.com/repos/fluxsauce/site_audit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fluxsauce/site_audit/labels{/name}","releases_url":"https://api.github.com/repos/fluxsauce/site_audit/releases{/id}","created_at":"2014-04-11T20:27:53Z","updated_at":"2015-07-16T12:10:13Z","pushed_at":"2015-08-06T10:14:06Z","git_url":"git://github.com/fluxsauce/site_audit.git","ssh_url":"git@github.com:fluxsauce/site_audit.git","clone_url":"https://github.com/fluxsauce/site_audit.git","svn_url":"https://github.com/fluxsauce/site_audit","homepage":"https://www.drupal.org/project/site_audit","size":1425,"stargazers_count":5,"watchers_count":5,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":14,"forks":6,"open_issues":14,"watchers":5,"default_branch":"8.x-2.x"}},"_links":{"self":{"href":"https://api.github.com/repos/fluxsauce/site_audit/pulls/50"},"html":{"href":"https://github.com/fluxsauce/site_audit/pull/50"},"issue":{"href":"https://api.github.com/repos/fluxsauce/site_audit/issues/50"},"comments":{"href":"https://api.github.com/repos/fluxsauce/site_audit/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/fluxsauce/site_audit/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/fluxsauce/site_audit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fluxsauce/site_audit/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/fluxsauce/site_audit/statuses/c73966626975317208eaab7862f866b44824b04d"}}}}