diff --git a/src/lint/engine/ArcanistLintEngine.php b/src/lint/engine/ArcanistLintEngine.php index fd5816eb..358ba281 100644 --- a/src/lint/engine/ArcanistLintEngine.php +++ b/src/lint/engine/ArcanistLintEngine.php @@ -53,6 +53,7 @@ abstract class ArcanistLintEngine { private $cachedResults; private $cacheVersion; private $results = array(); + private $stopped = array(); private $minimumSeverity = ArcanistLintSeverity::SEVERITY_DISABLED; private $changedLines = array(); @@ -188,9 +189,12 @@ abstract class ArcanistLintEngine { } $this->cacheVersion = crc32(implode("\n", $versions)); - $stopped = array(); + $this->stopped = array(); $exceptions = array(); foreach ($linters as $linter_name => $linter) { + if (!is_string($linter_name)) { + $linter_name = get_class($linter); + } try { $linter->setEngine($this); if (!$linter->canRun()) { @@ -204,12 +208,19 @@ abstract class ArcanistLintEngine { // Make sure each path has a result generated, even if it is empty // (i.e., the file has no lint messages). $result = $this->getResultForPath($path); - if (isset($stopped[$path])) { + if (isset($this->stopped[$path])) { unset($paths[$key]); } if (isset($this->cachedResults[$path][$this->cacheVersion])) { if ($cache_granularity == ArcanistLinter::GRANULARITY_FILE) { unset($paths[$key]); + + $cached_stopped = idx( + $this->cachedResults[$path][$this->cacheVersion], + 'stopped'); + if ($cached_stopped == $linter_name) { + $this->stopped[$path] = $linter_name; + } } } } @@ -221,15 +232,12 @@ abstract class ArcanistLintEngine { $linter->willLintPath($path); $linter->lintPath($path); if ($linter->didStopAllLinters()) { - $stopped[$path] = true; + $this->stopped[$path] = $linter_name; } } } } catch (Exception $ex) { - if (!is_string($linter_name)) { - $linter_name = get_class($linter); - } $exceptions[$linter_name] = $ex; } } @@ -255,7 +263,9 @@ abstract class ArcanistLintEngine { if ($this->cachedResults) { foreach ($this->cachedResults as $path => $messages) { - foreach (idx($messages, $this->cacheVersion, array()) as $message) { + $messages = idx($messages, $this->cacheVersion, array()); + unset($messages['stopped']); + foreach ($messages as $message) { $this->getResultForPath($path)->addMessage( ArcanistLintMessage::newFromDictionary($message)); } @@ -291,7 +301,7 @@ abstract class ArcanistLintEngine { } /** - * @param dict>> + * @param dict>> * @return this */ public function setCachedResults(array $results) { @@ -303,6 +313,10 @@ abstract class ArcanistLintEngine { return $this->results; } + public function getStoppedPaths() { + return $this->stopped; + } + abstract protected function buildLinters(); protected function didRunLinters(array $linters) { @@ -401,7 +415,7 @@ abstract class ArcanistLintEngine { } protected function getCacheVersion() { - return 0; + return 1; } protected function getPEP8WithTextOptions() { diff --git a/src/workflow/ArcanistLintWorkflow.php b/src/workflow/ArcanistLintWorkflow.php index 22b29831..faf32b61 100644 --- a/src/workflow/ArcanistLintWorkflow.php +++ b/src/workflow/ArcanistLintWorkflow.php @@ -504,6 +504,7 @@ EOTEXT $cache = $this->readScratchJSONFile('lint-cache.json'); $cached = idx($cache, $this->getCacheKey(), array()); if ($cached || $use_cache) { + $stopped = $engine->getStoppedPaths(); foreach ($results as $result) { $path = $result->getPath(); if (!$use_cache) { @@ -517,6 +518,9 @@ EOTEXT $hash = md5_file($abs_path); $version = $result->getCacheVersion(); $cached[$path] = array($hash => array($version => array())); + if (isset($stopped[$path])) { + $cached[$path][$hash][$version]['stopped'] = $stopped[$path]; + } foreach ($result->getMessages() as $message) { if ($message->isUncacheable()) { continue;