Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistPuppetLintLinter.php
| Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | protected function parseLinterOutput($path, $err, $stdout, $stderr) { | ||||
| foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
| $matches = explode('|', $line, 5); | $matches = explode('|', $line, 5); | ||||
| if (count($matches) < 5) { | if (count($matches) < 5) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $message_code = $this->getLinterName().'-'. | |||||
| strtoupper($matches[2]).'-'. | |||||
| preg_replace('/[^[:alnum:]]/', '_', $matches[3]); | |||||
| $message = id(new ArcanistLintMessage()) | $message = id(new ArcanistLintMessage()) | ||||
| ->setPath($path) | ->setPath($path) | ||||
| ->setLine($matches[0]) | ->setLine($matches[0]) | ||||
| ->setChar($matches[1]) | ->setChar($matches[1]) | ||||
| ->setCode($this->getLinterName()) | ->setCode($message_code) | ||||
| ->setName(ucwords(str_replace('_', ' ', $matches[3]))) | ->setName(ucwords(str_replace('_', ' ', $matches[3]))) | ||||
| ->setDescription(ucfirst($matches[4])); | ->setDescription(ucfirst($matches[4])); | ||||
| $message->setSeverity($this->getLintMessageSeverity($message->getCode())); | |||||
| switch ($matches[2]) { | |||||
| case 'warning': | |||||
| $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING); | |||||
| break; | |||||
| case 'error': | |||||
| $message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR); | |||||
| break; | |||||
| default: | |||||
| $message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE); | |||||
| break; | |||||
| } | |||||
| $messages[] = $message; | $messages[] = $message; | ||||
| } | } | ||||
| return $messages; | return $messages; | ||||
| } | } | ||||
joshuaspence: I think that it would be simpler to use `getLintMessageSeverity($matches[2])` here and provide… | |||||
| protected function getDefaultMessageSeverity($code) { | |||||
| $linter_name = $this->getLinterName(); | |||||
| if (preg_match("/^$linter_name-ERROR/", $code)) { | |||||
| return ArcanistLintSeverity::SEVERITY_ERROR; | |||||
| } else if (preg_match("/^$linter_name-WARNING/", $code)) { | |||||
| return ArcanistLintSeverity::SEVERITY_WARNING; | |||||
| } else { | |||||
| return ArcanistLintSeverity::SEVERITY_ADVICE; | |||||
| } | |||||
| } | |||||
| } | } | ||||
Not Done Inline ActionsSorry, I don't understand your suggestion; doesn't my patch work towards this direction? It's been a while, apologies if I'm missing something. zmousm: Sorry, I don't understand your suggestion; doesn't my patch work towards this direction?
It's… | |||||
I think that it would be simpler to use getLintMessageSeverity($matches[2]) here and provide an implementation of the getDefaultMessageSeverity method.