mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-04 02:48:24 +01:00
23bc9f294c
Summary: It is more common for linters to exit with a non-zero status than it is for linters to return with a zero exit status, Really this function serves very little purposes, it simply determines whether or not to throw an exception if a non-zero status is returned by the external linter. Test Plan: `arc unit` Reviewers: chad, epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11322
66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Uses `gjslint` to detect errors and potential problems in JavaScript code.
|
|
*/
|
|
final class ArcanistClosureLinter extends ArcanistExternalLinter {
|
|
|
|
public function getInfoName() {
|
|
return 'Closure Linter';
|
|
}
|
|
|
|
public function getInfoURI() {
|
|
return 'https://developers.google.com/closure/utilities/';
|
|
}
|
|
|
|
public function getInfoDescription() {
|
|
return pht("Uses Google's Closure Linter to check JavaScript code.");
|
|
}
|
|
|
|
public function getLinterName() {
|
|
return 'GJSLINT';
|
|
}
|
|
|
|
public function getLinterConfigurationName() {
|
|
return 'gjslint';
|
|
}
|
|
|
|
public function getDefaultBinary() {
|
|
return 'gjslint';
|
|
}
|
|
|
|
public function getInstallInstructions() {
|
|
return pht(
|
|
'Install %s using `%s`.',
|
|
'gjslint',
|
|
'sudo easy_install http://closure-linter.googlecode.com/'.
|
|
'files/closure_linter-latest.tar.gz');
|
|
}
|
|
|
|
public function supportsReadDataFromStdin() {
|
|
return false;
|
|
}
|
|
|
|
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
|
$lines = phutil_split_lines($stdout, false);
|
|
$messages = array();
|
|
|
|
foreach ($lines as $line) {
|
|
$matches = null;
|
|
if (!preg_match('/^Line (\d+), E:(\d+): (.*)/', $line, $matches)) {
|
|
continue;
|
|
}
|
|
|
|
$message = id(new ArcanistLintMessage())
|
|
->setPath($path)
|
|
->setLine($matches[1])
|
|
->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR)
|
|
->setCode($this->getLinterName().$matches[2])
|
|
->setDescription($matches[3]);
|
|
$messages[] = $message;
|
|
}
|
|
|
|
return $messages;
|
|
}
|
|
|
|
}
|