mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Rename ComprehensiveLintEngine
class for consistency
Summary: Ref T5655. Test Plan: Ran `arc lint` with `lint.engine` set to `ComprehensiveLintEngine` and saw a deprecation notice. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley Maniphest Tasks: T5655 Differential Revision: https://secure.phabricator.com/D11673
This commit is contained in:
parent
3498d6adfc
commit
b32cce79b2
3 changed files with 66 additions and 47 deletions
|
@ -44,6 +44,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistCommitLinterTestCase' => 'lint/linter/__tests__/ArcanistCommitLinterTestCase.php',
|
'ArcanistCommitLinterTestCase' => 'lint/linter/__tests__/ArcanistCommitLinterTestCase.php',
|
||||||
'ArcanistCommitWorkflow' => 'workflow/ArcanistCommitWorkflow.php',
|
'ArcanistCommitWorkflow' => 'workflow/ArcanistCommitWorkflow.php',
|
||||||
'ArcanistCompilerLintRenderer' => 'lint/renderer/ArcanistCompilerLintRenderer.php',
|
'ArcanistCompilerLintRenderer' => 'lint/renderer/ArcanistCompilerLintRenderer.php',
|
||||||
|
'ArcanistComprehensiveLintEngine' => 'lint/engine/ArcanistComprehensiveLintEngine.php',
|
||||||
'ArcanistConduitLinter' => 'lint/linter/ArcanistConduitLinter.php',
|
'ArcanistConduitLinter' => 'lint/linter/ArcanistConduitLinter.php',
|
||||||
'ArcanistConfiguration' => 'configuration/ArcanistConfiguration.php',
|
'ArcanistConfiguration' => 'configuration/ArcanistConfiguration.php',
|
||||||
'ArcanistConfigurationDrivenLintEngine' => 'lint/engine/ArcanistConfigurationDrivenLintEngine.php',
|
'ArcanistConfigurationDrivenLintEngine' => 'lint/engine/ArcanistConfigurationDrivenLintEngine.php',
|
||||||
|
@ -251,6 +252,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistCommitLinterTestCase' => 'ArcanistLinterTestCase',
|
'ArcanistCommitLinterTestCase' => 'ArcanistLinterTestCase',
|
||||||
'ArcanistCommitWorkflow' => 'ArcanistWorkflow',
|
'ArcanistCommitWorkflow' => 'ArcanistWorkflow',
|
||||||
'ArcanistCompilerLintRenderer' => 'ArcanistLintRenderer',
|
'ArcanistCompilerLintRenderer' => 'ArcanistLintRenderer',
|
||||||
|
'ArcanistComprehensiveLintEngine' => 'ArcanistLintEngine',
|
||||||
'ArcanistConduitLinter' => 'ArcanistLinter',
|
'ArcanistConduitLinter' => 'ArcanistLinter',
|
||||||
'ArcanistConfigurationDrivenLintEngine' => 'ArcanistLintEngine',
|
'ArcanistConfigurationDrivenLintEngine' => 'ArcanistLintEngine',
|
||||||
'ArcanistConsoleLintRenderer' => 'ArcanistLintRenderer',
|
'ArcanistConsoleLintRenderer' => 'ArcanistLintRenderer',
|
||||||
|
@ -382,7 +384,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistXMLLinter' => 'ArcanistLinter',
|
'ArcanistXMLLinter' => 'ArcanistLinter',
|
||||||
'ArcanistXMLLinterTestCase' => 'ArcanistLinterTestCase',
|
'ArcanistXMLLinterTestCase' => 'ArcanistLinterTestCase',
|
||||||
'CSharpToolsTestEngine' => 'XUnitTestEngine',
|
'CSharpToolsTestEngine' => 'XUnitTestEngine',
|
||||||
'ComprehensiveLintEngine' => 'ArcanistLintEngine',
|
'ComprehensiveLintEngine' => 'ArcanistComprehensiveLintEngine',
|
||||||
'NoseTestEngine' => 'ArcanistUnitTestEngine',
|
'NoseTestEngine' => 'ArcanistUnitTestEngine',
|
||||||
'PhpunitTestEngine' => 'ArcanistUnitTestEngine',
|
'PhpunitTestEngine' => 'ArcanistUnitTestEngine',
|
||||||
'PhpunitTestEngineTestCase' => 'ArcanistTestCase',
|
'PhpunitTestEngineTestCase' => 'ArcanistTestCase',
|
||||||
|
|
57
src/lint/engine/ArcanistComprehensiveLintEngine.php
Normal file
57
src/lint/engine/ArcanistComprehensiveLintEngine.php
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic lint engine which just applies several linters based on the file types.
|
||||||
|
*
|
||||||
|
* @todo Should be final but isn't because of @{class:ComprehensiveLintEngine}.
|
||||||
|
*/
|
||||||
|
class ArcanistComprehensiveLintEngine extends ArcanistLintEngine {
|
||||||
|
|
||||||
|
public function buildLinters() {
|
||||||
|
$linters = array();
|
||||||
|
|
||||||
|
$paths = $this->getPaths();
|
||||||
|
|
||||||
|
foreach ($paths as $key => $path) {
|
||||||
|
if (preg_match('@^externals/@', $path)) {
|
||||||
|
// Third-party stuff lives in /externals/; don't run lint engines
|
||||||
|
// against it.
|
||||||
|
unset($paths[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$text_paths = preg_grep('/\.(php|css|hpp|cpp|l|y|py|pl)$/', $paths);
|
||||||
|
$linters[] = id(new ArcanistGeneratedLinter())->setPaths($text_paths);
|
||||||
|
$linters[] = id(new ArcanistNoLintLinter())->setPaths($text_paths);
|
||||||
|
$linters[] = id(new ArcanistTextLinter())->setPaths($text_paths);
|
||||||
|
|
||||||
|
$linters[] = id(new ArcanistFilenameLinter())->setPaths($paths);
|
||||||
|
|
||||||
|
$linters[] = id(new ArcanistXHPASTLinter())
|
||||||
|
->setPaths(preg_grep('/\.php$/', $paths));
|
||||||
|
|
||||||
|
$py_paths = preg_grep('/\.py$/', $paths);
|
||||||
|
$linters[] = id(new ArcanistPyFlakesLinter())->setPaths($py_paths);
|
||||||
|
$linters[] = id(new ArcanistPEP8Linter())
|
||||||
|
->setFlags($this->getPEP8WithTextOptions())
|
||||||
|
->setPaths($py_paths);
|
||||||
|
|
||||||
|
$linters[] = id(new ArcanistRubyLinter())
|
||||||
|
->setPaths(preg_grep('/\.rb$/', $paths));
|
||||||
|
|
||||||
|
$linters[] = id(new ArcanistJSHintLinter())
|
||||||
|
->setPaths(preg_grep('/\.js$/', $paths));
|
||||||
|
|
||||||
|
return $linters;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPEP8WithTextOptions() {
|
||||||
|
// E101 is subset of TXT2 (Tab Literal).
|
||||||
|
// E501 is same as TXT3 (Line Too Long).
|
||||||
|
// W291 is same as TXT6 (Trailing Whitespace).
|
||||||
|
// W292 is same as TXT4 (File Does Not End in Newline).
|
||||||
|
// W293 is same as TXT6 (Trailing Whitespace).
|
||||||
|
return array('--ignore=E101,E501,W291,W292,W293');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,55 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic lint engine which just applies several linters based on the file types.
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
final class ComprehensiveLintEngine extends ArcanistLintEngine {
|
final class ComprehensiveLintEngine extends ArcanistComprehensiveLintEngine {
|
||||||
|
|
||||||
public function buildLinters() {
|
public function buildLinters() {
|
||||||
$linters = array();
|
phutil_deprecated(
|
||||||
|
__CLASS__,
|
||||||
$paths = $this->getPaths();
|
'You should use `ArcanistComprehensiveLintEngine` instead.');
|
||||||
|
parent::buildLinters();
|
||||||
foreach ($paths as $key => $path) {
|
|
||||||
if (preg_match('@^externals/@', $path)) {
|
|
||||||
// Third-party stuff lives in /externals/; don't run lint engines
|
|
||||||
// against it.
|
|
||||||
unset($paths[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$text_paths = preg_grep('/\.(php|css|hpp|cpp|l|y|py|pl)$/', $paths);
|
|
||||||
$linters[] = id(new ArcanistGeneratedLinter())->setPaths($text_paths);
|
|
||||||
$linters[] = id(new ArcanistNoLintLinter())->setPaths($text_paths);
|
|
||||||
$linters[] = id(new ArcanistTextLinter())->setPaths($text_paths);
|
|
||||||
|
|
||||||
$linters[] = id(new ArcanistFilenameLinter())->setPaths($paths);
|
|
||||||
|
|
||||||
$linters[] = id(new ArcanistXHPASTLinter())
|
|
||||||
->setPaths(preg_grep('/\.php$/', $paths));
|
|
||||||
|
|
||||||
$py_paths = preg_grep('/\.py$/', $paths);
|
|
||||||
$linters[] = id(new ArcanistPyFlakesLinter())->setPaths($py_paths);
|
|
||||||
$linters[] = id(new ArcanistPEP8Linter())
|
|
||||||
->setFlags($this->getPEP8WithTextOptions())
|
|
||||||
->setPaths($py_paths);
|
|
||||||
|
|
||||||
$linters[] = id(new ArcanistRubyLinter())
|
|
||||||
->setPaths(preg_grep('/\.rb$/', $paths));
|
|
||||||
|
|
||||||
$linters[] = id(new ArcanistJSHintLinter())
|
|
||||||
->setPaths(preg_grep('/\.js$/', $paths));
|
|
||||||
|
|
||||||
return $linters;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getPEP8WithTextOptions() {
|
|
||||||
// E101 is subset of TXT2 (Tab Literal).
|
|
||||||
// E501 is same as TXT3 (Line Too Long).
|
|
||||||
// W291 is same as TXT6 (Trailing Whitespace).
|
|
||||||
// W292 is same as TXT4 (File Does Not End in Newline).
|
|
||||||
// W293 is same as TXT6 (Trailing Whitespace).
|
|
||||||
return array('--ignore=E101,E501,W291,W292,W293');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue