{"action":"created","comment":{"url":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/comments/61385923","id":61385923,"diff_hunk":"@@ -0,0 +1,299 @@\n+/**\n+ * Copyright RIKSOF (Private) Limited 2016.\n+ *\n+ * Java Style Checker.\n+ */\n+\n+// Our logger for logging to file and console\n+var logger = require( __dirname + '/../services/Logger' );\n+\n+// Underscore library\n+var _ = require( 'underscore' );\n+\n+checker = function JavaCheckStyleChecker() {\n+  \n+  /**\n+   * Array of file paths.\n+   */\n+  this.checkedFiles = [];\n+};\n+\n+/**\n+ * Instance methods.\n+ */\n+checker.prototype = {\n+  \n+  SEVERITY_HIGH: 'ERROR',\n+  SEVERITY_MEDIUM: 2,\n+  SEVERITY_WARN: 'WARN',\n+  \n+  /**\n+   * Function is used to reset the checker for next pull review.\n+   *\n+   * @return {undefined}\n+   */\n+  reset: function JavaCheckStyleReset() {\n+    this.checkedFiles = [];\n+  },\n+  \n+  /**\n+   * Indicates to the caller if this checker is interested in given\n+   * file.\n+   *\n+   * @param {string} file   Relative path of file.\n+   * @returns {boolean}     If this checker validates given file.\n+   */\n+  doesValidate: function JavaCheckStyleDoesValidate( file ) {\n+    var validates = false;\n+    var included = ['.java'];\n+    \n+    included.forEach( function eachInclude( e ) {\n+      if ( file.substr( -e.length) === e ) {\n+        validates = true;\n+      }\n+    });\n+\n+    return validates;\n+  },\n+  \n+ /**\n+  * Process a new file to find issues in it. Those issues are reported to\n+  * the callback in an array.\n+  *\n+  * @param {string} path         Path of the file.\n+  * @param {string} source       Content of the source file.\n+  * @callback callback           Callback method to let everyone know\n+  *                              we are done.\n+  *\n+  * @return {undefined}\n+  */\n+  processFile: function JavaCheckStyleProcessFile( path, source, callback ) {\n+    var me = this;\n+    \n+    // Create a temporary file\n+    var tmp = require('tmp');\n+    var fs = require('fs');\n+    \n+    tmp.file({ postfix: '.java' }, function _tempFileCreated(err, tempPath, fd, cleanupCallback) {\n+      if (err) {\n+        logger.error(err);\n+      } else {\n+        \n+        // Write source to temporary file.\n+        fs.writeFile( tempPath, source, function _tempFileWritten(err) {\n+          var exec = require('child_process').exec;\n+          var cmd = 'java -jar libs/checkstyle-6.17-all.jar -c /google_checks.xml ' + tempPath;\n+\n+          // Execute the command.\n+          exec(cmd, function recvData(error, stdout, stderr) {\n+            var parseLine = /\\[([A-Z]*)\\] ([/a-zA-Z0-9~+._\\-]*):([0-9]*):([0-9]*): ([a-zA-Z0-9 .+*/&|{}'\";:_\\-\\[\\]]*) \\[([a-zA-Z]*)\\]/g;\n+      \n+            if (error) {\n+              logger.error( error );\n+            } else if (stderr) {\n+              logger.error( stderr );\n+            } else {\n+      \n+              // Get the output line by line.\n+              var index = stdout.indexOf( '\\n' );\n+        \n+              // Process all errors\n+              var errors = [];\n+        \n+              // While we have more lines to read.\n+              while (index > -1) {\n+                var line = stdout.substring(0, index);\n+                stdout = stdout.substring(index + 1);\n+                index = stdout.indexOf('\\n');\n+          \n+                // Parse the line using regular expressions.\n+                var result = parseLine.exec( line );\n+          \n+                if ( result ) {\n+                  var error = {\n+                    severity: result[1],\n+                    file: path,\n+                    line: parseInt(result[3]),\n+                    message: result[5],\n+                    rule: result[6]\n+                  }\n+            \n+                  errors.push( error );\n+                }\n+              }\n+            }\n+      \n+            // Clean up the file as its no longer needed.\n+            cleanupCallback();\n+            \n+            // Let the caller know about the errors.\n+            callback( errors );\n+          });\n+        });\n+      }\n+    });\n+  },\n+  \n+  /**\n+   * Process a new file both its current and proposed version.\n+   *\n+   * @param {string} from         Path of the base file.\n+   * @param {string} baseSource   Content of the base source file.\n+   * @param {string} to           Path of the head file.\n+   * @param {string} headSource   Content of the head source file.\n+   * @callback callback           Callback method to let everyone know\n+   *                              we are done.\n+   *\n+   * @return {undefined}\n+   */\n+  start: function JavaCheckStyleStart( from, baseSource, to, headSource, callback ) {\n+    var filesToCompare = 2;\n+    var me = this;\n+    var errors = {\n+      head: [],\n+      base: []\n+    };\n+    \n+    // Once everythins is done, finish off with this.\n+    var allDone = _.after( filesToCompare, function () {\n+      // Remember this report.\n+      var report = {\n+        file: to,\n+        errors: errors\n+      };\n+      \n+      me.checkedFiles.push( report );\n+      callback();\n+    }); \n+    \n+    // Review the base source code\n+    this.processFile( from, baseSource, function JavaCheckStyleBaseSourceErrors( errs ) {\n+      errors.base = errs;\n+      allDone();\n+    });\n+    \n+    // Review the head source code.\n+    this.processFile( to, headSource, function JavaCheckStyleHeadSourceErrors( errs ) {\n+      errors.head = errs;\n+      allDone();\n+    });\n+  },\n+  \n+  /**\n+   * Processes a step in the diff file.\n+   * \n+   * @param {Object} change       Line being read\n+   * @param {string} path         File path\n+   * @param {number} position     Position in file\n+   * @callback callback           Once processing is done.\n+   *\n+   * @return {undefined}\n+   */\n+  step: function JavaCheckStyleStep( change, path, position, callback ) {","path":"reviewers/JavaCheckStyleChecker.js","position":192,"original_position":192,"commit_id":"573f3115fe921ed987883adfce719f617b0ef14b","original_commit_id":"573f3115fe921ed987883adfce719f617b0ef14b","user":{"login":"mkhurramali","id":1565155,"avatar_url":"https://avatars.githubusercontent.com/u/1565155?v=3","gravatar_id":"","url":"https://api.github.com/users/mkhurramali","html_url":"https://github.com/mkhurramali","followers_url":"https://api.github.com/users/mkhurramali/followers","following_url":"https://api.github.com/users/mkhurramali/following{/other_user}","gists_url":"https://api.github.com/users/mkhurramali/gists{/gist_id}","starred_url":"https://api.github.com/users/mkhurramali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkhurramali/subscriptions","organizations_url":"https://api.github.com/users/mkhurramali/orgs","repos_url":"https://api.github.com/users/mkhurramali/repos","events_url":"https://api.github.com/users/mkhurramali/events{/privacy}","received_events_url":"https://api.github.com/users/mkhurramali/received_events","type":"User","site_admin":false},"body":"Function 'JavaCheckStyleStep' has a complexity of 6.\n```javascript\n  step: function JavaCheckStyleStep( change, path, position, callback ) {\n```","created_at":"2016-04-28T07:50:26Z","updated_at":"2016-04-28T07:50:26Z","html_url":"https://github.com/RIKSOF/node-review-ninja/pull/5#discussion_r61385923","pull_request_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/comments/61385923"},"html":{"href":"https://github.com/RIKSOF/node-review-ninja/pull/5#discussion_r61385923"},"pull_request":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/5","id":68177396,"html_url":"https://github.com/RIKSOF/node-review-ninja/pull/5","diff_url":"https://github.com/RIKSOF/node-review-ninja/pull/5.diff","patch_url":"https://github.com/RIKSOF/node-review-ninja/pull/5.patch","issue_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues/5","number":5,"state":"open","locked":false,"title":"Feature/java lint","user":{"login":"mkhurramali","id":1565155,"avatar_url":"https://avatars.githubusercontent.com/u/1565155?v=3","gravatar_id":"","url":"https://api.github.com/users/mkhurramali","html_url":"https://github.com/mkhurramali","followers_url":"https://api.github.com/users/mkhurramali/followers","following_url":"https://api.github.com/users/mkhurramali/following{/other_user}","gists_url":"https://api.github.com/users/mkhurramali/gists{/gist_id}","starred_url":"https://api.github.com/users/mkhurramali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkhurramali/subscriptions","organizations_url":"https://api.github.com/users/mkhurramali/orgs","repos_url":"https://api.github.com/users/mkhurramali/repos","events_url":"https://api.github.com/users/mkhurramali/events{/privacy}","received_events_url":"https://api.github.com/users/mkhurramali/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-28T07:47:55Z","updated_at":"2016-04-28T07:50:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"373d4a5eceff935ce53384d2e1e95ae4c4ed3d11","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/5/commits","review_comments_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/5/comments","review_comment_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues/5/comments","statuses_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/statuses/573f3115fe921ed987883adfce719f617b0ef14b","head":{"label":"RIKSOF:feature/java-lint","ref":"feature/java-lint","sha":"573f3115fe921ed987883adfce719f617b0ef14b","user":{"login":"RIKSOF","id":1582310,"avatar_url":"https://avatars.githubusercontent.com/u/1582310?v=3","gravatar_id":"","url":"https://api.github.com/users/RIKSOF","html_url":"https://github.com/RIKSOF","followers_url":"https://api.github.com/users/RIKSOF/followers","following_url":"https://api.github.com/users/RIKSOF/following{/other_user}","gists_url":"https://api.github.com/users/RIKSOF/gists{/gist_id}","starred_url":"https://api.github.com/users/RIKSOF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIKSOF/subscriptions","organizations_url":"https://api.github.com/users/RIKSOF/orgs","repos_url":"https://api.github.com/users/RIKSOF/repos","events_url":"https://api.github.com/users/RIKSOF/events{/privacy}","received_events_url":"https://api.github.com/users/RIKSOF/received_events","type":"Organization","site_admin":false},"repo":{"id":56207570,"name":"node-review-ninja","full_name":"RIKSOF/node-review-ninja","owner":{"login":"RIKSOF","id":1582310,"avatar_url":"https://avatars.githubusercontent.com/u/1582310?v=3","gravatar_id":"","url":"https://api.github.com/users/RIKSOF","html_url":"https://github.com/RIKSOF","followers_url":"https://api.github.com/users/RIKSOF/followers","following_url":"https://api.github.com/users/RIKSOF/following{/other_user}","gists_url":"https://api.github.com/users/RIKSOF/gists{/gist_id}","starred_url":"https://api.github.com/users/RIKSOF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIKSOF/subscriptions","organizations_url":"https://api.github.com/users/RIKSOF/orgs","repos_url":"https://api.github.com/users/RIKSOF/repos","events_url":"https://api.github.com/users/RIKSOF/events{/privacy}","received_events_url":"https://api.github.com/users/RIKSOF/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RIKSOF/node-review-ninja","description":"Review pull requests. Integrates with GitHub, Slack and Trello.","fork":false,"url":"https://api.github.com/repos/RIKSOF/node-review-ninja","forks_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/forks","keys_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/teams","hooks_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/hooks","issue_events_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues/events{/number}","events_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/events","assignees_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/assignees{/user}","branches_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/branches{/branch}","tags_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/tags","blobs_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/refs{/sha}","trees_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/statuses/{sha}","languages_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/languages","stargazers_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/stargazers","contributors_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/contributors","subscribers_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/subscribers","subscription_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/subscription","commits_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/commits{/sha}","git_commits_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/commits{/sha}","comments_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/comments{/number}","issue_comment_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues/comments{/number}","contents_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/contents/{+path}","compare_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/merges","archive_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/downloads","issues_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues{/number}","pulls_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls{/number}","milestones_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/milestones{/number}","notifications_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/labels{/name}","releases_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/releases{/id}","deployments_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/deployments","created_at":"2016-04-14T04:38:02Z","updated_at":"2016-04-14T05:11:51Z","pushed_at":"2016-04-28T07:47:55Z","git_url":"git://github.com/RIKSOF/node-review-ninja.git","ssh_url":"git@github.com:RIKSOF/node-review-ninja.git","clone_url":"https://github.com/RIKSOF/node-review-ninja.git","svn_url":"https://github.com/RIKSOF/node-review-ninja","homepage":null,"size":4573,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"RIKSOF:master","ref":"master","sha":"f86caf1ce1797ed1141626a73605ce262dddbede","user":{"login":"RIKSOF","id":1582310,"avatar_url":"https://avatars.githubusercontent.com/u/1582310?v=3","gravatar_id":"","url":"https://api.github.com/users/RIKSOF","html_url":"https://github.com/RIKSOF","followers_url":"https://api.github.com/users/RIKSOF/followers","following_url":"https://api.github.com/users/RIKSOF/following{/other_user}","gists_url":"https://api.github.com/users/RIKSOF/gists{/gist_id}","starred_url":"https://api.github.com/users/RIKSOF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIKSOF/subscriptions","organizations_url":"https://api.github.com/users/RIKSOF/orgs","repos_url":"https://api.github.com/users/RIKSOF/repos","events_url":"https://api.github.com/users/RIKSOF/events{/privacy}","received_events_url":"https://api.github.com/users/RIKSOF/received_events","type":"Organization","site_admin":false},"repo":{"id":56207570,"name":"node-review-ninja","full_name":"RIKSOF/node-review-ninja","owner":{"login":"RIKSOF","id":1582310,"avatar_url":"https://avatars.githubusercontent.com/u/1582310?v=3","gravatar_id":"","url":"https://api.github.com/users/RIKSOF","html_url":"https://github.com/RIKSOF","followers_url":"https://api.github.com/users/RIKSOF/followers","following_url":"https://api.github.com/users/RIKSOF/following{/other_user}","gists_url":"https://api.github.com/users/RIKSOF/gists{/gist_id}","starred_url":"https://api.github.com/users/RIKSOF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIKSOF/subscriptions","organizations_url":"https://api.github.com/users/RIKSOF/orgs","repos_url":"https://api.github.com/users/RIKSOF/repos","events_url":"https://api.github.com/users/RIKSOF/events{/privacy}","received_events_url":"https://api.github.com/users/RIKSOF/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RIKSOF/node-review-ninja","description":"Review pull requests. Integrates with GitHub, Slack and Trello.","fork":false,"url":"https://api.github.com/repos/RIKSOF/node-review-ninja","forks_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/forks","keys_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/teams","hooks_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/hooks","issue_events_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues/events{/number}","events_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/events","assignees_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/assignees{/user}","branches_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/branches{/branch}","tags_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/tags","blobs_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/refs{/sha}","trees_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/statuses/{sha}","languages_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/languages","stargazers_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/stargazers","contributors_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/contributors","subscribers_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/subscribers","subscription_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/subscription","commits_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/commits{/sha}","git_commits_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/git/commits{/sha}","comments_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/comments{/number}","issue_comment_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues/comments{/number}","contents_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/contents/{+path}","compare_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/merges","archive_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/downloads","issues_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues{/number}","pulls_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls{/number}","milestones_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/milestones{/number}","notifications_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/labels{/name}","releases_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/releases{/id}","deployments_url":"https://api.github.com/repos/RIKSOF/node-review-ninja/deployments","created_at":"2016-04-14T04:38:02Z","updated_at":"2016-04-14T05:11:51Z","pushed_at":"2016-04-28T07:47:55Z","git_url":"git://github.com/RIKSOF/node-review-ninja.git","ssh_url":"git@github.com:RIKSOF/node-review-ninja.git","clone_url":"https://github.com/RIKSOF/node-review-ninja.git","svn_url":"https://github.com/RIKSOF/node-review-ninja","homepage":null,"size":4573,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/5"},"html":{"href":"https://github.com/RIKSOF/node-review-ninja/pull/5"},"issue":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues/5"},"comments":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/RIKSOF/node-review-ninja/statuses/573f3115fe921ed987883adfce719f617b0ef14b"}}}}