1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 23:02:41 +01:00

Move conversion to dictionary inside lint message

Summary: Maybe I will need it on other places.

Test Plan:
  $ arc lint --output json # on file with lint error

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3898
This commit is contained in:
vrana 2012-11-05 20:23:38 -08:00
parent d53dcbe952
commit a83cb43d08
3 changed files with 20 additions and 22 deletions

View file

@ -39,6 +39,18 @@ final class ArcanistLintMessage {
return $message; 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) { public function setPath($path) {
$this->path = $path; $this->path = $path;
return $this; return $this;

View file

@ -17,19 +17,13 @@ final class ArcanistLintJSONRenderer implements ArcanistLintRenderer {
$output = array($path => array()); $output = array($path => array());
foreach ($messages as $message) { foreach ($messages as $message) {
$output[$path][] = array( $dictionary = $message->toDictionary();
'code' => $message->getCode(), $dictionary['context'] = implode("\n", array_slice(
'name' => $message->getName(), $data,
'severity' => $message->getSeverity(), max(1, $message->getLine() - self::LINES_OF_CONTEXT),
'line' => $message->getLine(), self::LINES_OF_CONTEXT * 2 + 1));
'char' => $message->getChar(), unset($dictionary['path']);
'context' => implode("\n", array_slice( $output[$path][] = $dictionary;
$data,
max(1, $message->getLine() - self::LINES_OF_CONTEXT),
self::LINES_OF_CONTEXT * 2 + 1
)),
'description' => $message->getDescription(),
);
} }
return json_encode($output)."\n"; return json_encode($output)."\n";

View file

@ -1264,15 +1264,7 @@ EOTEXT
$this->unresolvedLint = array(); $this->unresolvedLint = array();
foreach ($lint_workflow->getUnresolvedMessages() as $message) { foreach ($lint_workflow->getUnresolvedMessages() as $message) {
$this->unresolvedLint[] = array( $this->unresolvedLint[] = $message->toDictionary();
'path' => $message->getPath(),
'line' => $message->getLine(),
'char' => $message->getChar(),
'code' => $message->getCode(),
'severity' => $message->getSeverity(),
'name' => $message->getName(),
'description' => $message->getDescription(),
);
} }
$this->postponedLinters = $lint_workflow->getPostponedLinters(); $this->postponedLinters = $lint_workflow->getPostponedLinters();