Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistLinter.php
| Show All 10 Lines | |||||
| abstract class ArcanistLinter { | abstract class ArcanistLinter { | ||||
| const GRANULARITY_FILE = 1; | const GRANULARITY_FILE = 1; | ||||
| const GRANULARITY_DIRECTORY = 2; | const GRANULARITY_DIRECTORY = 2; | ||||
| const GRANULARITY_REPOSITORY = 3; | const GRANULARITY_REPOSITORY = 3; | ||||
| const GRANULARITY_GLOBAL = 4; | const GRANULARITY_GLOBAL = 4; | ||||
| private $id; | private $id; | ||||
| protected $paths = array(); | protected $paths = array(); | ||||
| private $filteredPaths = null; | |||||
| protected $data = array(); | protected $data = array(); | ||||
| protected $engine; | protected $engine; | ||||
| protected $activePath; | protected $activePath; | ||||
| protected $messages = array(); | protected $messages = array(); | ||||
| protected $stopAllLinters = false; | protected $stopAllLinters = false; | ||||
| private $customSeverityMap = array(); | private $customSeverityMap = array(); | ||||
| private $customSeverityRules = array(); | private $customSeverityRules = array(); | ||||
| ▲ Show 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | /* -( Executing Linters )-------------------------------------------------- */ | ||||
| } | } | ||||
| final public function didStopAllLinters() { | final public function didStopAllLinters() { | ||||
| return $this->stopAllLinters; | return $this->stopAllLinters; | ||||
| } | } | ||||
| final public function addPath($path) { | final public function addPath($path) { | ||||
| $this->paths[$path] = $path; | $this->paths[$path] = $path; | ||||
| $this->filteredPaths = null; | |||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function setPaths(array $paths) { | final public function setPaths(array $paths) { | ||||
| $this->paths = $paths; | $this->paths = $paths; | ||||
| $this->filteredPaths = null; | |||||
| return $this; | return $this; | ||||
| } | } | ||||
| /** | /** | ||||
| * Filter out paths which this linter doesn't act on (for example, because | * Filter out paths which this linter doesn't act on (for example, because | ||||
| * they are binaries and the linter doesn't apply to binaries). | * they are binaries and the linter doesn't apply to binaries). | ||||
| * | |||||
| * @param list<string> | |||||
| * @return list<string> | |||||
| */ | */ | ||||
| final private function filterPaths($paths) { | final private function filterPaths(array $paths) { | ||||
| $engine = $this->getEngine(); | $engine = $this->getEngine(); | ||||
| $keep = array(); | $keep = array(); | ||||
| foreach ($paths as $path) { | foreach ($paths as $path) { | ||||
| if (!$this->shouldLintDeletedFiles() && !$engine->pathExists($path)) { | if (!$this->shouldLintDeletedFiles() && !$engine->pathExists($path)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Show All 11 Lines | foreach ($paths as $path) { | ||||
| $keep[] = $path; | $keep[] = $path; | ||||
| } | } | ||||
| return $keep; | return $keep; | ||||
| } | } | ||||
| final public function getPaths() { | final public function getPaths() { | ||||
| return $this->filterPaths(array_values($this->paths)); | if ($this->filteredPaths === null) { | ||||
| $this->filteredPaths = $this->filterPaths(array_values($this->paths)); | |||||
| } | |||||
| return $this->filteredPaths; | |||||
| } | } | ||||
| final public function addData($path, $data) { | final public function addData($path, $data) { | ||||
| $this->data[$path] = $data; | $this->data[$path] = $data; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final protected function getData($path) { | final protected function getData($path) { | ||||
| ▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines | |||||