]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow linters that extend `ArcanistExternalLinter` to customize the file parameter
authorJuan Pablo Civile <elementohb@gmail.com>
Sun, 11 May 2014 23:25:38 +0000 (16:25 -0700)
committerepriestley <git@epriestley.com>
Sun, 11 May 2014 23:27:23 +0000 (16:27 -0700)
Summary: Not all linters run on a `command file` fashion. In particular, the maven checkstyle plugin runs like `command --flag=file`.

Test Plan: Run a linter that extends `ArcanistExternalLinter`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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

src/lint/linter/ArcanistExternalLinter.php

index fe05f0c5ac3db38aa7bca67e09abc46557ec995e..70612d5ad7df6edacbbfc8b8b1bc8576f78f6781 100644 (file)
@@ -381,6 +381,19 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
     }
   }
 
+
+  /**
+   * Prepare the path to be added to the command string.
+   *
+   * This method is expected to return an already escaped string.
+   *
+   * @param string Path to the file being linted
+   * @return string The command-ready file argument
+   */
+  protected function getPathArgumentForLinterFuture($path) {
+    return csprintf('%s', $path);
+  }
+
   protected function buildFutures(array $paths) {
     $executable = $this->getExecutableCommand();
 
@@ -397,7 +410,8 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
       } else {
         // TODO: In commit hook mode, we need to do more handling here.
         $disk_path = $this->getEngine()->getFilePathOnDisk($path);
-        $future = new ExecFuture('%C %s', $bin, $disk_path);
+        $path_argument = $this->getPathArgumentForLinterFuture($disk_path);
+        $future = new ExecFuture('%C %C', $bin, $path_argument);
       }
 
       $futures[$path] = $future;