mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-02 09:58:23 +01:00
Add canRun to linters.
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
This commit is contained in:
parent
9be9554f2d
commit
2fa80bbd44
3 changed files with 9 additions and 2 deletions
|
@ -99,7 +99,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistXHPASTLinter' => 'lint/linter/xhpast',
|
'ArcanistXHPASTLinter' => 'lint/linter/xhpast',
|
||||||
'ArcanistXHPASTLinterTestCase' => 'lint/linter/xhpast/__tests__',
|
'ArcanistXHPASTLinterTestCase' => 'lint/linter/xhpast/__tests__',
|
||||||
'BranchInfo' => 'branch',
|
'BranchInfo' => 'branch',
|
||||||
'ComprehensiveEngine' => 'lint/engine/comprehensive',
|
'ComprehensiveLintEngine' => 'lint/engine/comprehensive',
|
||||||
'ExampleLintEngine' => 'lint/engine/example',
|
'ExampleLintEngine' => 'lint/engine/example',
|
||||||
'PhutilLintEngine' => 'lint/engine/phutil',
|
'PhutilLintEngine' => 'lint/engine/phutil',
|
||||||
'PhutilModuleRequirements' => 'parser/phutilmodule',
|
'PhutilModuleRequirements' => 'parser/phutilmodule',
|
||||||
|
@ -166,7 +166,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistUserAbortException' => 'ArcanistUsageException',
|
'ArcanistUserAbortException' => 'ArcanistUsageException',
|
||||||
'ArcanistXHPASTLinter' => 'ArcanistLinter',
|
'ArcanistXHPASTLinter' => 'ArcanistLinter',
|
||||||
'ArcanistXHPASTLinterTestCase' => 'ArcanistLinterTestCase',
|
'ArcanistXHPASTLinterTestCase' => 'ArcanistLinterTestCase',
|
||||||
'ComprehensiveEngine' => 'ArcanistLintEngine',
|
'ComprehensiveLintEngine' => 'ArcanistLintEngine',
|
||||||
'ExampleLintEngine' => 'ArcanistLintEngine',
|
'ExampleLintEngine' => 'ArcanistLintEngine',
|
||||||
'PhutilLintEngine' => 'ArcanistLintEngine',
|
'PhutilLintEngine' => 'ArcanistLintEngine',
|
||||||
'PhutilUnitTestEngine' => 'ArcanistBaseUnitTestEngine',
|
'PhutilUnitTestEngine' => 'ArcanistBaseUnitTestEngine',
|
||||||
|
|
|
@ -183,6 +183,9 @@ abstract class ArcanistLintEngine {
|
||||||
|
|
||||||
foreach ($linters as $linter) {
|
foreach ($linters as $linter) {
|
||||||
$linter->setEngine($this);
|
$linter->setEngine($this);
|
||||||
|
if (!$linter->canRun()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$paths = $linter->getPaths();
|
$paths = $linter->getPaths();
|
||||||
|
|
||||||
foreach ($paths as $key => $path) {
|
foreach ($paths as $key => $path) {
|
||||||
|
|
|
@ -186,6 +186,10 @@ abstract class ArcanistLinter {
|
||||||
$this->activePath = $path;
|
$this->activePath = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canRun() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
abstract public function willLintPaths(array $paths);
|
abstract public function willLintPaths(array $paths);
|
||||||
abstract public function lintPath($path);
|
abstract public function lintPath($path);
|
||||||
abstract public function getLinterName();
|
abstract public function getLinterName();
|
||||||
|
|
Loading…
Add table
Reference in a new issue