4
* Calls `hlint` and parses its results.
6
final class ArcanistHLintLinter extends ArcanistExternalLinter {
8
public function getInfoName() {
12
public function getInfoURI() {
13
return 'https://github.com/ndmitchell/hlint';
16
public function getInfoDescription() {
17
return pht('HLint is a linter for Haskell code.');
20
public function getLinterName() {
24
public function getLinterConfigurationName() {
28
public function getDefaultBinary() {
32
public function getInstallInstructions() {
33
return pht('Install hlint with `cabal install hlint`.');
36
public function supportsReadDataFromStdin() {
40
public function getReadDataFromStdinFilename() {
44
public function shouldExpectCommandErrors() {
48
public function getMandatoryFlags() {
49
return array('--json');
52
public function getVersion() {
53
list($stdout, $stderr) = execx(
54
'%C --version', $this->getExecutableCommand());
57
if (preg_match('@HLint v(.*),@', $stdout, $matches)) {
64
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
66
$json = phutil_json_decode($stdout);
68
foreach ($json as $fix) {
73
$message = new ArcanistLintMessage();
74
$message->setCode($this->getLinterName());
75
$message->setPath($path);
76
$message->setLine($fix['startLine']);
77
$message->setChar($fix['startColumn']);
78
$message->setName($fix['hint']);
79
$message->setOriginalText($fix['from']);
80
$message->setReplacementText($fix['to']);
82
/* Some improvements may slightly change semantics, so attach
83
all necessary notes too. */
85
foreach ($fix['note'] as $note) {
86
$notes .= ' **NOTE**: '.trim($note, '"').'.';
89
$message->setDescription(
91
'In module `%s`, declaration `%s`.%s',
92
$fix['module'], $fix['decl'], $notes));
94
switch ($fix['severity']) {
96
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
99
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
102
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
106
$messages[] = $message;