mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 18:22:41 +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',
|
'ArcanistFlagWorkflow' => 'workflow/ArcanistFlagWorkflow.php',
|
||||||
'ArcanistFlake8Linter' => 'lint/linter/ArcanistFlake8Linter.php',
|
'ArcanistFlake8Linter' => 'lint/linter/ArcanistFlake8Linter.php',
|
||||||
'ArcanistFlake8LinterTestCase' => 'lint/linter/__tests__/ArcanistFlake8LinterTestCase.php',
|
'ArcanistFlake8LinterTestCase' => 'lint/linter/__tests__/ArcanistFlake8LinterTestCase.php',
|
||||||
|
'ArcanistFutureLinter' => 'lint/linter/ArcanistFutureLinter.php',
|
||||||
'ArcanistGeneratedLinter' => 'lint/linter/ArcanistGeneratedLinter.php',
|
'ArcanistGeneratedLinter' => 'lint/linter/ArcanistGeneratedLinter.php',
|
||||||
'ArcanistGetConfigWorkflow' => 'workflow/ArcanistGetConfigWorkflow.php',
|
'ArcanistGetConfigWorkflow' => 'workflow/ArcanistGetConfigWorkflow.php',
|
||||||
'ArcanistGitAPI' => 'repository/api/ArcanistGitAPI.php',
|
'ArcanistGitAPI' => 'repository/api/ArcanistGitAPI.php',
|
||||||
|
@ -206,6 +207,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistFlagWorkflow' => 'ArcanistBaseWorkflow',
|
'ArcanistFlagWorkflow' => 'ArcanistBaseWorkflow',
|
||||||
'ArcanistFlake8Linter' => 'ArcanistLinter',
|
'ArcanistFlake8Linter' => 'ArcanistLinter',
|
||||||
'ArcanistFlake8LinterTestCase' => 'ArcanistArcanistLinterTestCase',
|
'ArcanistFlake8LinterTestCase' => 'ArcanistArcanistLinterTestCase',
|
||||||
|
'ArcanistFutureLinter' => 'ArcanistLinter',
|
||||||
'ArcanistGeneratedLinter' => 'ArcanistLinter',
|
'ArcanistGeneratedLinter' => 'ArcanistLinter',
|
||||||
'ArcanistGetConfigWorkflow' => 'ArcanistBaseWorkflow',
|
'ArcanistGetConfigWorkflow' => 'ArcanistBaseWorkflow',
|
||||||
'ArcanistGitAPI' => 'ArcanistRepositoryAPI',
|
'ArcanistGitAPI' => 'ArcanistRepositoryAPI',
|
||||||
|
@ -233,7 +235,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistNoEngineException' => 'ArcanistUsageException',
|
'ArcanistNoEngineException' => 'ArcanistUsageException',
|
||||||
'ArcanistNoLintLinter' => 'ArcanistLinter',
|
'ArcanistNoLintLinter' => 'ArcanistLinter',
|
||||||
'ArcanistNoLintTestCaseMisnamed' => 'ArcanistLinterTestCase',
|
'ArcanistNoLintTestCaseMisnamed' => 'ArcanistLinterTestCase',
|
||||||
'ArcanistPEP8Linter' => 'ArcanistLinter',
|
'ArcanistPEP8Linter' => 'ArcanistFutureLinter',
|
||||||
'ArcanistPasteWorkflow' => 'ArcanistBaseWorkflow',
|
'ArcanistPasteWorkflow' => 'ArcanistBaseWorkflow',
|
||||||
'ArcanistPatchWorkflow' => 'ArcanistBaseWorkflow',
|
'ArcanistPatchWorkflow' => 'ArcanistBaseWorkflow',
|
||||||
'ArcanistPhpcsLinter' => 'ArcanistLinter',
|
'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
|
* @group linter
|
||||||
*/
|
*/
|
||||||
final class ArcanistPEP8Linter extends ArcanistLinter {
|
final class ArcanistPEP8Linter extends ArcanistFutureLinter {
|
||||||
|
|
||||||
public function willLintPaths(array $paths) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLinterName() {
|
public function getLinterName() {
|
||||||
return 'PEP8';
|
return 'PEP8';
|
||||||
|
@ -81,9 +77,8 @@ final class ArcanistPEP8Linter extends ArcanistLinter {
|
||||||
return $bin;
|
return $bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lintPath($path) {
|
public function buildFutures(array $paths) {
|
||||||
$severity = ArcanistLintSeverity::SEVERITY_WARNING;
|
$severity = ArcanistLintSeverity::SEVERITY_WARNING;
|
||||||
|
|
||||||
if (!$this->getEngine()->isSeverityEnabled($severity)) {
|
if (!$this->getEngine()->isSeverityEnabled($severity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -91,12 +86,23 @@ final class ArcanistPEP8Linter extends ArcanistLinter {
|
||||||
$pep8_bin = $this->getPEP8Path();
|
$pep8_bin = $this->getPEP8Path();
|
||||||
$options = $this->getPEP8Options();
|
$options = $this->getPEP8Options();
|
||||||
|
|
||||||
list($rc, $stdout) = exec_manual(
|
$futures = Futures(array())->limit(8);
|
||||||
|
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
$future = new ExecFuture(
|
||||||
"%C %C %s",
|
"%C %C %s",
|
||||||
$pep8_bin,
|
$pep8_bin,
|
||||||
$options,
|
$options,
|
||||||
$this->getEngine()->getFilePathOnDisk($path));
|
$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);
|
$lines = explode("\n", $stdout);
|
||||||
$messages = array();
|
$messages = array();
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
|
@ -117,7 +123,7 @@ final class ArcanistPEP8Linter extends ArcanistLinter {
|
||||||
$message->setCode($matches[4]);
|
$message->setCode($matches[4]);
|
||||||
$message->setName('PEP8 '.$matches[4]);
|
$message->setName('PEP8 '.$matches[4]);
|
||||||
$message->setDescription($matches[5]);
|
$message->setDescription($matches[5]);
|
||||||
$message->setSeverity($severity);
|
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
|
||||||
$this->addLintMessage($message);
|
$this->addLintMessage($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue