mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-11 15:21:03 +01:00
Run all willLintPaths() before any lintPath()
Summary: FB runs some linters on background and it's a magnificent hack using `ParallelLinter` (two instances), `BackgroundLinter` and `FutureLinter`. I want to simplify this by resolving the futures in engine instead of in some virtual linter. It also seems like a better place to do it. It should also fix caching problems I have with them (because the virtual linters don't know about the cache at all). Test Plan: None yet. Reviewers: epriestley, nh Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4380
This commit is contained in:
parent
38e2e1336f
commit
35de4a5d1f
1 changed files with 35 additions and 30 deletions
|
@ -164,7 +164,6 @@ abstract class ArcanistLintEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
$stopped = array();
|
|
||||||
$linters = $this->buildLinters();
|
$linters = $this->buildLinters();
|
||||||
|
|
||||||
if (!$linters) {
|
if (!$linters) {
|
||||||
|
@ -189,9 +188,8 @@ abstract class ArcanistLintEngine {
|
||||||
}
|
}
|
||||||
$this->cacheVersion = crc32(implode("\n", $versions));
|
$this->cacheVersion = crc32(implode("\n", $versions));
|
||||||
|
|
||||||
$exceptions = array();
|
$linters_paths = array();
|
||||||
foreach ($linters as $linter_name => $linter) {
|
foreach ($linters as $linter_name => $linter) {
|
||||||
try {
|
|
||||||
$linter->setEngine($this);
|
$linter->setEngine($this);
|
||||||
if (!$linter->canRun()) {
|
if (!$linter->canRun()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -204,9 +202,6 @@ abstract class ArcanistLintEngine {
|
||||||
// Make sure each path has a result generated, even if it is empty
|
// Make sure each path has a result generated, even if it is empty
|
||||||
// (i.e., the file has no lint messages).
|
// (i.e., the file has no lint messages).
|
||||||
$result = $this->getResultForPath($path);
|
$result = $this->getResultForPath($path);
|
||||||
if (isset($stopped[$path])) {
|
|
||||||
unset($paths[$key]);
|
|
||||||
}
|
|
||||||
if (isset($this->cachedResults[$path][$this->cacheVersion])) {
|
if (isset($this->cachedResults[$path][$this->cacheVersion])) {
|
||||||
if ($cache_granularity == ArcanistLinter::GRANULARITY_FILE) {
|
if ($cache_granularity == ArcanistLinter::GRANULARITY_FILE) {
|
||||||
unset($paths[$key]);
|
unset($paths[$key]);
|
||||||
|
@ -214,17 +209,27 @@ abstract class ArcanistLintEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$paths = array_values($paths);
|
$paths = array_values($paths);
|
||||||
|
$linters_paths[$linter_name] = $paths;
|
||||||
|
|
||||||
if ($paths) {
|
if ($paths) {
|
||||||
$linter->willLintPaths($paths);
|
$linter->willLintPaths($paths);
|
||||||
foreach ($paths as $path) {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$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->willLintPath($path);
|
||||||
$linter->lintPath($path);
|
$linter->lintPath($path);
|
||||||
if ($linter->didStopAllLinters()) {
|
if ($linter->didStopAllLinters()) {
|
||||||
$stopped[$path] = true;
|
$stopped[$path] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$minimum = $this->minimumSeverity;
|
$minimum = $this->minimumSeverity;
|
||||||
foreach ($linter->getLintMessages() as $message) {
|
foreach ($linter->getLintMessages() as $message) {
|
||||||
|
|
Loading…
Reference in a new issue