2014-05-23 16:59:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ArcanistGoLintLinter extends ArcanistExternalLinter {
|
|
|
|
|
|
|
|
public function getInfoName() {
|
|
|
|
return 'Golint';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInfoURI() {
|
|
|
|
return 'https://github.com/golang/lint';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInfoDescription() {
|
|
|
|
return pht('Golint is a linter for Go source code.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinterName() {
|
|
|
|
return 'GOLINT';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinterConfigurationName() {
|
|
|
|
return 'golint';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefaultBinary() {
|
|
|
|
return 'golint';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInstallInstructions() {
|
2015-05-13 10:05:15 +02:00
|
|
|
return pht(
|
|
|
|
'Install Golint using `%s`.',
|
|
|
|
'go get github.com/golang/lint/golint');
|
2014-05-23 16:59:57 +02:00
|
|
|
}
|
|
|
|
|
2015-01-11 21:21:33 +01:00
|
|
|
public function shouldExpectCommandErrors() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-23 16:59:57 +02:00
|
|
|
protected function canCustomizeLintSeverities() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
|
|
|
$lines = phutil_split_lines($stdout, false);
|
|
|
|
|
|
|
|
$messages = array();
|
|
|
|
foreach ($lines as $line) {
|
|
|
|
$matches = explode(':', $line, 4);
|
|
|
|
|
|
|
|
if (count($matches) === 4) {
|
|
|
|
$message = new ArcanistLintMessage();
|
|
|
|
$message->setPath($path);
|
|
|
|
$message->setLine($matches[1]);
|
|
|
|
$message->setChar($matches[2]);
|
|
|
|
$message->setCode($this->getLinterName());
|
2015-10-02 17:58:15 +02:00
|
|
|
$message->setName($this->getLinterName());
|
2014-05-23 16:59:57 +02:00
|
|
|
$message->setDescription(ucfirst(trim($matches[3])));
|
|
|
|
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
|
|
|
|
|
|
|
|
$messages[] = $message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $messages;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|