2014-05-15 09:18:24 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2015-01-05 07:43:55 +11:00
|
|
|
* Uses `gjslint` to detect errors and potential problems in JavaScript code.
|
2014-05-15 09:18:24 -07:00
|
|
|
*/
|
|
|
|
final class ArcanistClosureLinter extends ArcanistExternalLinter {
|
|
|
|
|
|
|
|
public function getInfoName() {
|
|
|
|
return 'Closure Linter';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInfoURI() {
|
|
|
|
return 'https://developers.google.com/closure/utilities/';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInfoDescription() {
|
2015-01-05 07:43:55 +11:00
|
|
|
return pht("Uses Google's Closure Linter to check JavaScript code.");
|
2014-05-15 09:18:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinterName() {
|
2015-01-05 07:43:55 +11:00
|
|
|
return 'GJSLINT';
|
2014-05-15 09:18:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinterConfigurationName() {
|
|
|
|
return 'gjslint';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefaultBinary() {
|
|
|
|
return 'gjslint';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInstallInstructions() {
|
2014-06-20 18:26:44 +10:00
|
|
|
return pht(
|
2015-01-05 07:43:55 +11:00
|
|
|
'Install %s using `%s`.',
|
|
|
|
'gjslint',
|
|
|
|
'sudo easy_install http://closure-linter.googlecode.com/'.
|
|
|
|
'files/closure_linter-latest.tar.gz');
|
2014-05-15 09:18:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
2014-06-20 18:26:44 +10:00
|
|
|
$lines = phutil_split_lines($stdout, false);
|
2014-05-15 09:18:24 -07:00
|
|
|
$messages = array();
|
2015-01-05 07:43:55 +11:00
|
|
|
|
2014-05-15 09:18:24 -07:00
|
|
|
foreach ($lines as $line) {
|
|
|
|
$matches = null;
|
2015-01-05 07:43:55 +11:00
|
|
|
if (!preg_match('/^Line (\d+), E:(\d+): (.*)/', $line, $matches)) {
|
2014-05-15 09:18:24 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-01-05 07:43:55 +11:00
|
|
|
$message = id(new ArcanistLintMessage())
|
|
|
|
->setPath($path)
|
|
|
|
->setLine($matches[1])
|
|
|
|
->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR)
|
|
|
|
->setCode($this->getLinterName().$matches[2])
|
|
|
|
->setDescription($matches[3]);
|
2014-05-15 09:18:24 -07:00
|
|
|
$messages[] = $message;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $messages;
|
|
|
|
}
|
2014-06-20 18:26:44 +10:00
|
|
|
|
2014-05-15 09:18:24 -07:00
|
|
|
}
|