diff --git a/src/lint/linter/ArcanistPuppetLintLinter.php b/src/lint/linter/ArcanistPuppetLintLinter.php index 5fc20705..230ce540 100644 --- a/src/lint/linter/ArcanistPuppetLintLinter.php +++ b/src/lint/linter/ArcanistPuppetLintLinter.php @@ -1,107 +1,140 @@ getExecutableCommand()); $matches = array(); $regex = '/^Puppet-lint (?P\d+\.\d+\.\d+)$/'; if (preg_match($regex, $stdout, $matches)) { return $matches['version']; } else { return false; } } public function getInstallInstructions() { return pht('Install puppet-lint using `gem install puppet-lint`.'); } public function shouldExpectCommandErrors() { return true; } public function supportsReadDataFromStdin() { return false; } protected function getMandatoryFlags() { return array(sprintf('--log-format=%s', implode('|', array( '%{linenumber}', '%{column}', '%{kind}', '%{check}', '%{message}')))); } + public function getLinterConfigurationOptions() { + $options = array( + 'puppet-lint.config' => array( + 'type' => 'optional string', + 'help' => pht('Pass in a custom configuration file path.'), + ), + ); + + return $options + parent::getLinterConfigurationOptions(); + } + + public function setLinterConfigurationValue($key, $value) { + switch ($key) { + case 'puppet-lint.config': + $this->config = $value; + return; + } + + return parent::setLinterConfigurationValue($key, $value); + } + + protected function getDefaultFlags() { + $options = array(); + + if ($this->config) { + $options[] = '--config='.$this->config; + } + + return $options; + } + protected function parseLinterOutput($path, $err, $stdout, $stderr) { $lines = phutil_split_lines($stdout, false); $messages = array(); foreach ($lines as $line) { $matches = explode('|', $line, 5); if (count($matches) === 5) { $message = new ArcanistLintMessage(); $message->setPath($path); $message->setLine($matches[0]); $message->setChar($matches[1]); $message->setName(ucwords(str_replace('_', ' ', $matches[3]))); $message->setDescription(ucfirst($matches[4])); 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; } } if ($err && !$messages) { return false; } return $messages; } } diff --git a/src/lint/linter/__tests__/puppet-lint/arrow_alignment.lint-test b/src/lint/linter/__tests__/puppet-lint/arrow_alignment.lint-test index 017d6e26..78a5bf9b 100644 --- a/src/lint/linter/__tests__/puppet-lint/arrow_alignment.lint-test +++ b/src/lint/linter/__tests__/puppet-lint/arrow_alignment.lint-test @@ -1,6 +1,6 @@ exec { 'test': subscribe => File['/etc/test'], refreshonly => true, } ~~~~~~~~~~ -warning:3:15 +warning:2:13