Changeset View
Changeset View
Standalone View
Standalone View
src/lint/engine/ArcanistLintEngine.php
| Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | abstract class ArcanistLintEngine { | ||||
| final public function setMinimumSeverity($severity) { | final public function setMinimumSeverity($severity) { | ||||
| $this->minimumSeverity = $severity; | $this->minimumSeverity = $severity; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function run() { | final public function run() { | ||||
| $linters = $this->buildLinters(); | $linters = $this->buildLinters(); | ||||
| if (!$linters) { | if (!$linters) { | ||||
| throw new ArcanistNoEffectException('No linters to run.'); | throw new ArcanistNoEffectException(pht('No linters to run.')); | ||||
| } | } | ||||
| foreach ($linters as $key => $linter) { | foreach ($linters as $key => $linter) { | ||||
| $linter->setLinterID($key); | $linter->setLinterID($key); | ||||
| } | } | ||||
| $linters = msort($linters, 'getLinterPriority'); | $linters = msort($linters, 'getLinterPriority'); | ||||
| foreach ($linters as $linter) { | foreach ($linters as $linter) { | ||||
| $linter->setEngine($this); | $linter->setEngine($this); | ||||
| } | } | ||||
| $have_paths = false; | $have_paths = false; | ||||
| foreach ($linters as $linter) { | foreach ($linters as $linter) { | ||||
| if ($linter->getPaths()) { | if ($linter->getPaths()) { | ||||
| $have_paths = true; | $have_paths = true; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (!$have_paths) { | if (!$have_paths) { | ||||
| throw new ArcanistNoEffectException('No paths are lintable.'); | throw new ArcanistNoEffectException(pht('No paths are lintable.')); | ||||
| } | } | ||||
| $versions = array($this->getCacheVersion()); | $versions = array($this->getCacheVersion()); | ||||
| foreach ($linters as $linter) { | foreach ($linters as $linter) { | ||||
| $version = get_class($linter).':'.$linter->getCacheVersion(); | $version = get_class($linter).':'.$linter->getCacheVersion(); | ||||
| $symbols = id(new PhutilSymbolLoader()) | $symbols = id(new PhutilSymbolLoader()) | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | foreach ($this->results as $path => $result) { | ||||
| // Ignore this, it's noncritical that we access this data and it | // Ignore this, it's noncritical that we access this data and it | ||||
| // might be unreadable or a directory or whatever else for plenty | // might be unreadable or a directory or whatever else for plenty | ||||
| // of legitimate reasons. | // of legitimate reasons. | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if ($exceptions) { | if ($exceptions) { | ||||
| throw new PhutilAggregateException('Some linters failed:', $exceptions); | throw new PhutilAggregateException( | ||||
| pht('Some linters failed:'), | |||||
| $exceptions); | |||||
| } | } | ||||
| return $this->results; | return $this->results; | ||||
| } | } | ||||
| final public function isSeverityEnabled($severity) { | final public function isSeverityEnabled($severity) { | ||||
| $minimum = $this->minimumSeverity; | $minimum = $this->minimumSeverity; | ||||
| return ArcanistLintSeverity::isAtLeastAsSevere($severity, $minimum); | return ArcanistLintSeverity::isAtLeastAsSevere($severity, $minimum); | ||||
| ▲ Show 20 Lines • Show All 327 Lines • Show Last 20 Lines | |||||