]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Update `puppet-lint` linter
authorJoshua Spence <josh@joshuaspence.com>
Fri, 29 Aug 2014 14:37:01 +0000 (00:37 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Fri, 29 Aug 2014 14:37:01 +0000 (00:37 +1000)
Summary: Update the `puppet-lint` linter to support the latest version (v1.0.1). This version allows a custom configuration file to be passed via `--config`, which brings this linter into line with other linters.

Test Plan: Update test cases to pass.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10384

src/lint/linter/ArcanistPuppetLintLinter.php
src/lint/linter/__tests__/puppet-lint/arrow_alignment.lint-test

index 5fc207055419d23523ceabba88eacefa15bd10f6..230ce540790343f3fb2ccfc6ccb9f2b8fccf4d26 100644 (file)
@@ -5,12 +5,14 @@
  */
 final class ArcanistPuppetLintLinter extends ArcanistExternalLinter {
 
+  private $config;
+
   public function getInfoURI() {
     return 'http://puppet-lint.com/';
   }
 
   public function getInfoName() {
-    return pht('puppet-lint');
+    return 'puppet-lint';
   }
 
   public function getInfoDescription() {
@@ -64,6 +66,37 @@ final class ArcanistPuppetLintLinter extends ArcanistExternalLinter {
       '%{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);
 
index 017d6e2670635f2abafb8a9ac2859a2e4e8a8880..78a5bf9ba982b2d5bfe801eaa0939e978455db45 100644 (file)
@@ -3,4 +3,4 @@ exec { 'test':
   refreshonly => true,
 }
 ~~~~~~~~~~
-warning:3:15
+warning:2:13