]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add canRun to linters.
authorDavid Cramer <dcramer@gmail.com>
Wed, 18 Jan 2012 00:30:59 +0000 (16:30 -0800)
committerDavid Cramer <dcramer@gmail.com>
Wed, 18 Jan 2012 01:15:21 +0000 (17:15 -0800)
Summary:
This allows engines to check the canRun method on linters,
which should determine if a linter is configured and can
be run in the current environment.

Test Plan:
Implement a linter with canRun as false, and ensure
it doesnt run.

Ensure all existing linters still run by default.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran
Differential Revision: https://secure.phabricator.com/D1445

src/__phutil_library_map__.php
src/lint/engine/base/ArcanistLintEngine.php
src/lint/linter/base/ArcanistLinter.php

index 9e24b9c59be7f61c5acd4682feaf024e6ea14bc4..2279b6cf763c550cdc39687c56e4c998a5ebbc5e 100644 (file)
@@ -99,7 +99,7 @@ phutil_register_library_map(array(
     'ArcanistXHPASTLinter' => 'lint/linter/xhpast',
     'ArcanistXHPASTLinterTestCase' => 'lint/linter/xhpast/__tests__',
     'BranchInfo' => 'branch',
-    'ComprehensiveEngine' => 'lint/engine/comprehensive',
+    'ComprehensiveLintEngine' => 'lint/engine/comprehensive',
     'ExampleLintEngine' => 'lint/engine/example',
     'PhutilLintEngine' => 'lint/engine/phutil',
     'PhutilModuleRequirements' => 'parser/phutilmodule',
@@ -166,7 +166,7 @@ phutil_register_library_map(array(
     'ArcanistUserAbortException' => 'ArcanistUsageException',
     'ArcanistXHPASTLinter' => 'ArcanistLinter',
     'ArcanistXHPASTLinterTestCase' => 'ArcanistLinterTestCase',
-    'ComprehensiveEngine' => 'ArcanistLintEngine',
+    'ComprehensiveLintEngine' => 'ArcanistLintEngine',
     'ExampleLintEngine' => 'ArcanistLintEngine',
     'PhutilLintEngine' => 'ArcanistLintEngine',
     'PhutilUnitTestEngine' => 'ArcanistBaseUnitTestEngine',
index c8518b8f1dffe3b12bb58cbe0b239305b386057f..72d441f6686f29b87ecb6bd13d82e51eed4f1c52 100644 (file)
@@ -183,6 +183,9 @@ abstract class ArcanistLintEngine {
 
     foreach ($linters as $linter) {
       $linter->setEngine($this);
+      if (!$linter->canRun()) {
+        continue;
+      }
       $paths = $linter->getPaths();
 
       foreach ($paths as $key => $path) {
index aa2cdb48d3434ef41a7fe36290fe792b293c9577..de9db19b3f1fc18fa5e61c7e2fc88037dca3bc19 100644 (file)
@@ -186,6 +186,10 @@ abstract class ArcanistLinter {
     $this->activePath = $path;
   }
 
+  public function canRun() {
+    return true;
+  }
+
   abstract public function willLintPaths(array $paths);
   abstract public function lintPath($path);
   abstract public function getLinterName();