mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Use the raw
formatter for coffeelint
Summary: Using `--reporter=raw` exposes raw JSON output rather than a limited XML output. This allows us to pull more context from the `coffeelint` output. Test Plan: `arc unit` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11320
This commit is contained in:
parent
23bc9f294c
commit
b780ef0868
1 changed files with 17 additions and 16 deletions
|
@ -57,7 +57,7 @@ final class ArcanistCoffeeLintLinter extends ArcanistExternalLinter {
|
||||||
|
|
||||||
protected function getMandatoryFlags() {
|
protected function getMandatoryFlags() {
|
||||||
$options = array(
|
$options = array(
|
||||||
'--reporter=checkstyle',
|
'--reporter=raw',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->config) {
|
if ($this->config) {
|
||||||
|
@ -89,32 +89,29 @@ final class ArcanistCoffeeLintLinter extends ArcanistExternalLinter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
||||||
$report_dom = new DOMDocument();
|
$messages = array();
|
||||||
$ok = @$report_dom->loadXML($stdout);
|
$output = phutil_json_decode($stdout);
|
||||||
|
|
||||||
if (!$ok) {
|
// We are only linting a single file.
|
||||||
|
if (count($output) != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = $report_dom->getElementsByTagName('file');
|
foreach ($output as $reports) {
|
||||||
$messages = array();
|
foreach ($reports as $report) {
|
||||||
|
|
||||||
foreach ($files as $file) {
|
|
||||||
foreach ($file->getElementsByTagName('error') as $error) {
|
|
||||||
// Column number is not provided in the output.
|
// Column number is not provided in the output.
|
||||||
// See https://github.com/clutchski/coffeelint/issues/87
|
// See https://github.com/clutchski/coffeelint/issues/87
|
||||||
|
|
||||||
$message = id(new ArcanistLintMessage())
|
$message = id(new ArcanistLintMessage())
|
||||||
->setPath($path)
|
->setPath($path)
|
||||||
->setLine($error->getAttribute('line'))
|
->setLine($report['lineNumber'])
|
||||||
->setCode($this->getLinterName())
|
->setCode($this->getLinterName())
|
||||||
->setDescription(preg_replace(
|
->setName(ucwords(str_replace('_', ' ', $report['name'])))
|
||||||
'/; context: .*$/',
|
->setDescription($report['message'])
|
||||||
'.',
|
->setOriginalText(idx($report, 'line'));
|
||||||
$error->getAttribute('message')));
|
|
||||||
|
|
||||||
switch ($error->getAttribute('severity')) {
|
switch ($report['level']) {
|
||||||
case 'warning':
|
case 'warn':
|
||||||
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
|
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -131,6 +128,10 @@ final class ArcanistCoffeeLintLinter extends ArcanistExternalLinter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($err && !$messages) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue