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
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;
$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";
$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();