diff --git a/src/lint/ArcanistLintMessage.php b/src/lint/ArcanistLintMessage.php index 6da5a0d8..89a8fd1e 100644 --- a/src/lint/ArcanistLintMessage.php +++ b/src/lint/ArcanistLintMessage.php @@ -39,6 +39,18 @@ final class ArcanistLintMessage { return $message; } + public function toDictionary() { + return array( + 'path' => $this->getPath(), + 'line' => $this->getLine(), + 'char' => $this->getChar(), + 'code' => $this->getCode(), + 'severity' => $this->getSeverity(), + 'name' => $this->getName(), + 'description' => $this->getDescription(), + ); + } + public function setPath($path) { $this->path = $path; return $this; diff --git a/src/lint/renderer/ArcanistLintJSONRenderer.php b/src/lint/renderer/ArcanistLintJSONRenderer.php index 1c038841..ce824224 100644 --- a/src/lint/renderer/ArcanistLintJSONRenderer.php +++ b/src/lint/renderer/ArcanistLintJSONRenderer.php @@ -17,19 +17,13 @@ final class ArcanistLintJSONRenderer implements ArcanistLintRenderer { $output = array($path => array()); foreach ($messages as $message) { - $output[$path][] = array( - 'code' => $message->getCode(), - 'name' => $message->getName(), - 'severity' => $message->getSeverity(), - 'line' => $message->getLine(), - 'char' => $message->getChar(), - 'context' => implode("\n", array_slice( - $data, - max(1, $message->getLine() - self::LINES_OF_CONTEXT), - self::LINES_OF_CONTEXT * 2 + 1 - )), - 'description' => $message->getDescription(), - ); + $dictionary = $message->toDictionary(); + $dictionary['context'] = implode("\n", array_slice( + $data, + max(1, $message->getLine() - self::LINES_OF_CONTEXT), + self::LINES_OF_CONTEXT * 2 + 1)); + unset($dictionary['path']); + $output[$path][] = $dictionary; } return json_encode($output)."\n"; diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 08163d3f..43c049e5 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -1264,15 +1264,7 @@ EOTEXT $this->unresolvedLint = array(); foreach ($lint_workflow->getUnresolvedMessages() as $message) { - $this->unresolvedLint[] = array( - 'path' => $message->getPath(), - 'line' => $message->getLine(), - 'char' => $message->getChar(), - 'code' => $message->getCode(), - 'severity' => $message->getSeverity(), - 'name' => $message->getName(), - 'description' => $message->getDescription(), - ); + $this->unresolvedLint[] = $message->toDictionary(); } $this->postponedLinters = $lint_workflow->getPostponedLinters();