mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Run PEP8 linter on background
Test Plan: $ arc lint pep8.py --cache 0 --engine ComprehensiveLintEngine --trace Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4967
This commit is contained in:
parent
4e688b0e0e
commit
81171ca39d
3 changed files with 53 additions and 14 deletions
|
@ -61,6 +61,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistFlagWorkflow' => 'workflow/ArcanistFlagWorkflow.php',
|
||||
'ArcanistFlake8Linter' => 'lint/linter/ArcanistFlake8Linter.php',
|
||||
'ArcanistFlake8LinterTestCase' => 'lint/linter/__tests__/ArcanistFlake8LinterTestCase.php',
|
||||
'ArcanistFutureLinter' => 'lint/linter/ArcanistFutureLinter.php',
|
||||
'ArcanistGeneratedLinter' => 'lint/linter/ArcanistGeneratedLinter.php',
|
||||
'ArcanistGetConfigWorkflow' => 'workflow/ArcanistGetConfigWorkflow.php',
|
||||
'ArcanistGitAPI' => 'repository/api/ArcanistGitAPI.php',
|
||||
|
@ -206,6 +207,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistFlagWorkflow' => 'ArcanistBaseWorkflow',
|
||||
'ArcanistFlake8Linter' => 'ArcanistLinter',
|
||||
'ArcanistFlake8LinterTestCase' => 'ArcanistArcanistLinterTestCase',
|
||||
'ArcanistFutureLinter' => 'ArcanistLinter',
|
||||
'ArcanistGeneratedLinter' => 'ArcanistLinter',
|
||||
'ArcanistGetConfigWorkflow' => 'ArcanistBaseWorkflow',
|
||||
'ArcanistGitAPI' => 'ArcanistRepositoryAPI',
|
||||
|
@ -233,7 +235,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistNoEngineException' => 'ArcanistUsageException',
|
||||
'ArcanistNoLintLinter' => 'ArcanistLinter',
|
||||
'ArcanistNoLintTestCaseMisnamed' => 'ArcanistLinterTestCase',
|
||||
'ArcanistPEP8Linter' => 'ArcanistLinter',
|
||||
'ArcanistPEP8Linter' => 'ArcanistFutureLinter',
|
||||
'ArcanistPasteWorkflow' => 'ArcanistBaseWorkflow',
|
||||
'ArcanistPatchWorkflow' => 'ArcanistBaseWorkflow',
|
||||
'ArcanistPhpcsLinter' => 'ArcanistLinter',
|
||||
|
|
31
src/lint/linter/ArcanistFutureLinter.php
Normal file
31
src/lint/linter/ArcanistFutureLinter.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
abstract class ArcanistFutureLinter extends ArcanistLinter {
|
||||
|
||||
private $futures;
|
||||
|
||||
abstract function buildFutures(array $paths);
|
||||
abstract function resolveFuture($path, Future $future);
|
||||
|
||||
public function willLintPaths(array $paths) {
|
||||
$this->futures = $this->buildFutures($paths);
|
||||
if (is_array($this->futures)) {
|
||||
foreach ($this->futures as $future) {
|
||||
$future->isReady();
|
||||
}
|
||||
$this->futures = Futures($this->futures);
|
||||
}
|
||||
}
|
||||
|
||||
public function lintPath($path) {
|
||||
}
|
||||
|
||||
public function didRunLinters() {
|
||||
if ($this->futures) {
|
||||
foreach ($this->futures as $path => $future) {
|
||||
$this->resolveFuture($path, $future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -5,11 +5,7 @@
|
|||
*
|
||||
* @group linter
|
||||
*/
|
||||
final class ArcanistPEP8Linter extends ArcanistLinter {
|
||||
|
||||
public function willLintPaths(array $paths) {
|
||||
return;
|
||||
}
|
||||
final class ArcanistPEP8Linter extends ArcanistFutureLinter {
|
||||
|
||||
public function getLinterName() {
|
||||
return 'PEP8';
|
||||
|
@ -81,9 +77,8 @@ final class ArcanistPEP8Linter extends ArcanistLinter {
|
|||
return $bin;
|
||||
}
|
||||
|
||||
public function lintPath($path) {
|
||||
public function buildFutures(array $paths) {
|
||||
$severity = ArcanistLintSeverity::SEVERITY_WARNING;
|
||||
|
||||
if (!$this->getEngine()->isSeverityEnabled($severity)) {
|
||||
return;
|
||||
}
|
||||
|
@ -91,12 +86,23 @@ final class ArcanistPEP8Linter extends ArcanistLinter {
|
|||
$pep8_bin = $this->getPEP8Path();
|
||||
$options = $this->getPEP8Options();
|
||||
|
||||
list($rc, $stdout) = exec_manual(
|
||||
$futures = Futures(array())->limit(8);
|
||||
|
||||
foreach ($paths as $path) {
|
||||
$future = new ExecFuture(
|
||||
"%C %C %s",
|
||||
$pep8_bin,
|
||||
$options,
|
||||
$this->getEngine()->getFilePathOnDisk($path));
|
||||
|
||||
$futures->addFuture($future, $path);
|
||||
}
|
||||
|
||||
return $futures;
|
||||
}
|
||||
|
||||
public function resolveFuture($path, Future $future) {
|
||||
list($rc, $stdout) = $future->resolve();
|
||||
$lines = explode("\n", $stdout);
|
||||
$messages = array();
|
||||
foreach ($lines as $line) {
|
||||
|
@ -117,7 +123,7 @@ final class ArcanistPEP8Linter extends ArcanistLinter {
|
|||
$message->setCode($matches[4]);
|
||||
$message->setName('PEP8 '.$matches[4]);
|
||||
$message->setDescription($matches[5]);
|
||||
$message->setSeverity($severity);
|
||||
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
|
||||
$this->addLintMessage($message);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue