4
* Uses gJSLint to detect errors and potential problems in JavaScript code.
6
final class ArcanistClosureLinter extends ArcanistExternalLinter {
8
public function getInfoName() {
9
return 'Closure Linter';
12
public function getInfoURI() {
13
return 'https://developers.google.com/closure/utilities/';
16
public function getInfoDescription() {
17
return pht("Uses Google's Closure Linter to check Javascript code.");
20
public function getLinterName() {
21
return 'Closure Linter';
24
public function getLinterConfigurationName() {
28
public function getDefaultBinary() {
32
public function getInstallInstructions() {
34
'Install gJSLint using `sudo easy_install http://closure-linter'.
35
'.googlecode.com/files/closure_linter-latest.tar.gz`');
38
public function shouldExpectCommandErrors() {
42
public function supportsReadDataFromStdin() {
46
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
47
// Each line looks like this:
48
// Line 46, E:0110: Line too long (87 characters).
49
$regex = '/^Line (\d+), (E:\d+): (.*)/';
50
$severity_code = ArcanistLintSeverity::SEVERITY_ERROR;
52
$lines = phutil_split_lines($stdout, false);
55
foreach ($lines as $line) {
58
if (!preg_match($regex, $line, $matches)) {
61
foreach ($matches as $key => $match) {
62
$matches[$key] = trim($match);
65
$message = new ArcanistLintMessage();
66
$message->setPath($path);
67
$message->setLine($matches[1]);
68
$message->setName($matches[2]);
69
$message->setCode($this->getLinterName());
70
$message->setDescription($matches[3]);
71
$message->setSeverity($severity_code);
73
$messages[] = $message;