mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-22 20:51:09 +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',
|
||||
'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',
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue