}
$this->cacheVersion = crc32(implode("\n", $versions));
- $linters_paths = array();
- foreach ($linters as $linter_name => $linter) {
- $linter->setEngine($this);
- if (!$linter->canRun()) {
- continue;
- }
- $paths = $linter->getPaths();
-
- $cache_granularity = $linter->getCacheGranularity();
-
- foreach ($paths as $key => $path) {
- // 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($this->cachedResults[$path][$this->cacheVersion])) {
- if ($cache_granularity == ArcanistLinter::GRANULARITY_FILE) {
- unset($paths[$key]);
- }
- }
- }
- $paths = array_values($paths);
- $linters_paths[$linter_name] = $paths;
-
- if ($paths) {
- $linter->willLintPaths($paths);
- }
- }
-
$stopped = array();
$exceptions = array();
foreach ($linters as $linter_name => $linter) {
try {
- foreach ($linters_paths[$linter_name] as $path) {
- if (isset($stopped[$path])) {
- continue;
- }
- $linter->willLintPath($path);
- $linter->lintPath($path);
- if ($linter->didStopAllLinters()) {
- $stopped[$path] = true;
- }
+ $linter->setEngine($this);
+ if (!$linter->canRun()) {
+ continue;
}
+ $paths = $linter->getPaths();
+
+ $cache_granularity = $linter->getCacheGranularity();
- $minimum = $this->minimumSeverity;
- foreach ($linter->getLintMessages() as $message) {
- if (!ArcanistLintSeverity::isAtLeastAsSevere($message, $minimum)) {
- continue;
+ foreach ($paths as $key => $path) {
+ // 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])) {
+ unset($paths[$key]);
}
- if (!$this->isRelevantMessage($message)) {
- continue;
+ if (isset($this->cachedResults[$path][$this->cacheVersion])) {
+ if ($cache_granularity == ArcanistLinter::GRANULARITY_FILE) {
+ unset($paths[$key]);
+ }
}
- if ($cache_granularity != ArcanistLinter::GRANULARITY_FILE) {
- $message->setUncacheable(true);
+ }
+ $paths = array_values($paths);
+
+ if ($paths) {
+ $linter->willLintPaths($paths);
+ foreach ($paths as $path) {
+ $linter->willLintPath($path);
+ $linter->lintPath($path);
+ if ($linter->didStopAllLinters()) {
+ $stopped[$path] = true;
+ }
}
- $result = $this->getResultForPath($message->getPath());
- $result->addMessage($message);
}
+
} catch (Exception $ex) {
if (!is_string($linter_name)) {
$linter_name = get_class($linter);
}
}
+ $this->didRunLinters($linters);
+
+ foreach ($linters as $linter) {
+ $minimum = $this->minimumSeverity;
+ foreach ($linter->getLintMessages() as $message) {
+ if (!ArcanistLintSeverity::isAtLeastAsSevere($message, $minimum)) {
+ continue;
+ }
+ if (!$this->isRelevantMessage($message)) {
+ continue;
+ }
+ if ($cache_granularity != ArcanistLinter::GRANULARITY_FILE) {
+ $message->setUncacheable(true);
+ }
+ $result = $this->getResultForPath($message->getPath());
+ $result->addMessage($message);
+ }
+ }
+
if ($this->cachedResults) {
foreach ($this->cachedResults as $path => $messages) {
foreach (idx($messages, $this->cacheVersion, array()) as $message) {
abstract protected function buildLinters();
+ protected function didRunLinters(array $linters) {
+ assert_instances_of($linters, 'ArcanistLinter');
+ foreach ($linters as $linter) {
+ $linter->didRunLinters();
+ }
+ }
+
private function isRelevantMessage(ArcanistLintMessage $message) {
// When a user runs "arc lint", we default to raising only warnings on
// lines they have changed (errors are still raised anywhere in the