Page MenuHomePhabricator

D17350.diff
No OneTemporary

D17350.diff

diff --git a/src/lint/linter/ArcanistExternalLinter.php b/src/lint/linter/ArcanistExternalLinter.php
--- a/src/lint/linter/ArcanistExternalLinter.php
+++ b/src/lint/linter/ArcanistExternalLinter.php
@@ -10,6 +10,7 @@
*/
abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
+ private $batchSize;
private $bin;
private $interpreter;
private $flags;
@@ -54,6 +55,16 @@
}
/**
+ * Documentation goes here.
+ *
+ * @return bool
+ * @task bin
+ */
+ protected function supportsBatchMode() {
+ return true;
+ }
+
+ /**
* Return true to continue when the external linter exits with an error code.
* By default, linters which exit with an error code are assumed to have
* failed. However, some linters exit with a specific code to indicate that
@@ -197,6 +208,26 @@
return $this;
}
+ final public function getBatchSize() {
+ if (!$this->supportsBatchMode()) {
+ return 1;
+ }
+
+ return coalesce($this->batchSize, 1);
+ }
+
+ /**
+ * Documentation goes here.
+ *
+ * @param int
+ * @return this
+ * @task bin
+ */
+ final public function setBatchSize($batch_size) {
+ $this->batchSize = $batch_size;
+ return $this;
+ }
+
/* -( Parsing Linter Output )---------------------------------------------- */
@@ -416,13 +447,16 @@
$bin = csprintf('%C %Ls', $executable, $this->getCommandFlags());
$futures = array();
- foreach ($paths as $path) {
- $disk_path = $this->getEngine()->getFilePathOnDisk($path);
- $path_argument = $this->getPathArgumentForLinterFuture($disk_path);
- $future = new ExecFuture('%C %C', $bin, $path_argument);
+ foreach (array_chunk($paths, $this->getBatchSize()) as $chunk_paths) {
+ $path_arguments = array();
+ foreach ($chunk_paths as $path) {
+ $path_arguments[] = $this->getEngine()->getFilePathOnDisk($path);
+ }
+
+ $future = new ExecFuture('%C %Ls', $bin, $path_arguments);
$future->setCWD($this->getProjectRoot());
- $futures[$path] = $future;
+ $futures[] = $future;
}
return $futures;
@@ -497,11 +531,22 @@
);
}
+ if ($this->supportsBatchMode()) {
+ $options['batch-size'] = array(
+ 'type' => 'optional int',
+ 'help' => pht('Documentation goes here.'),
+ );
+ }
+
return $options + parent::getLinterConfigurationOptions();
}
public function setLinterConfigurationValue($key, $value) {
switch ($key) {
+ case 'batch-size':
+ $this->setBatchSize($value);
+ return;
+
case 'interpreter':
$root = $this->getProjectRoot();

File Metadata

Mime Type
text/plain
Expires
Mar 21 2025, 10:18 PM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7713187
Default Alt Text
D17350.diff (2 KB)

Event Timeline