Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistLinter.php
| Show First 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | final protected function getData($path) { | ||||
| } | } | ||||
| return $this->data[$path]; | return $this->data[$path]; | ||||
| } | } | ||||
| public function getCacheVersion() { | public function getCacheVersion() { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| final public function getLintMessageFullCode($short_code) { | |||||
| return $this->getLinterName().$short_code; | |||||
| } | |||||
| final public function getLintMessageSeverity($code) { | final public function getLintMessageSeverity($code) { | ||||
| $map = $this->customSeverityMap; | $map = $this->customSeverityMap; | ||||
| if (isset($map[$code])) { | if (isset($map[$code])) { | ||||
| return $map[$code]; | return $map[$code]; | ||||
| } | } | ||||
| foreach ($this->customSeverityRules as $rule => $severity) { | foreach ($this->customSeverityRules as $rule => $severity) { | ||||
| if (preg_match($rule, $code)) { | if (preg_match($rule, $code)) { | ||||
| Show All 21 Lines | /* -( Executing Linters )-------------------------------------------------- */ | ||||
| final public function getLintMessageName($code) { | final public function getLintMessageName($code) { | ||||
| $map = $this->getLintNameMap(); | $map = $this->getLintNameMap(); | ||||
| if (isset($map[$code])) { | if (isset($map[$code])) { | ||||
| return $map[$code]; | return $map[$code]; | ||||
| } | } | ||||
| return pht('Unknown lint message!'); | return pht('Unknown lint message!'); | ||||
| } | } | ||||
| final protected function addLintMessage(ArcanistLintMessage $message) { | final private function addLintMessage(ArcanistLintMessage $message) { | ||||
| $root = $this->getProjectRoot(); | $root = $this->getProjectRoot(); | ||||
| $path = Filesystem::resolvePath($message->getPath(), $root); | $path = Filesystem::resolvePath($message->getPath(), $root); | ||||
| $message->setPath(Filesystem::readablePath($path, $root)); | $message->setPath(Filesystem::readablePath($path, $root)); | ||||
| $message->setLinterName($this->getLinterName()); | |||||
| // If the linter message doesn't have a name, lookup the name | |||||
| // from the linter code. | |||||
| if (!$message->getName()) { | |||||
| $message->setName($this->getLintMessageName($message->getCode())); | |||||
| } | |||||
| if ($message->getSeverity() === null && $this->canCustomizeLintSeverities()) { | |||||
| $this->getLintMessageSeverity($message->getCode()); | |||||
| } | |||||
| $this->messages[] = $message; | $this->messages[] = $message; | ||||
| return $message; | return $message; | ||||
| } | } | ||||
| final public function getLintMessages() { | final public function getLintMessages() { | ||||
| return $this->messages; | return $this->messages; | ||||
| } | } | ||||
| final public function raiseLintAtLine( | final public function raiseLintAtLine( | ||||
| $line, | $line, | ||||
| $char, | $char, | ||||
| $code, | $code, | ||||
| $desc, | $desc, | ||||
| $original = null, | $original = null, | ||||
| $replacement = null) { | $replacement = null) { | ||||
| $message = id(new ArcanistLintMessage()) | $message = id(new ArcanistLintMessage()) | ||||
| ->setPath($this->getActivePath()) | ->setPath($this->getActivePath()) | ||||
| ->setLine($line) | ->setLine($line) | ||||
| ->setChar($char) | ->setChar($char) | ||||
| ->setCode($this->getLintMessageFullCode($code)) | ->setCode($code) | ||||
| ->setSeverity($this->getLintMessageSeverity($code)) | ->setSeverity($this->getLintMessageSeverity($code)) | ||||
| ->setName($this->getLintMessageName($code)) | ->setName($this->getLintMessageName($code)) | ||||
| ->setDescription($desc) | ->setDescription($desc) | ||||
| ->setOriginalText($original) | ->setOriginalText($original) | ||||
| ->setReplacementText($replacement); | ->setReplacementText($replacement); | ||||
| return $this->addLintMessage($message); | return $this->addLintMessage($message); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines | |||||