1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-23 22:10:54 +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;
}
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;

View file

@ -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";

View file

@ -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();