Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistLinter.php
| Show First 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | return ($this->getLintMessageSeverity($code) !== | ||||
| ArcanistLintSeverity::SEVERITY_DISABLED); | ArcanistLintSeverity::SEVERITY_DISABLED); | ||||
| } | } | ||||
| 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 'Unknown lint message!'; | return pht('Unknown lint message!'); | ||||
| } | } | ||||
| final protected function addLintMessage(ArcanistLintMessage $message) { | final protected function addLintMessage(ArcanistLintMessage $message) { | ||||
| $root = $this->getEngine()->getWorkingCopy()->getProjectRoot(); | $root = $this->getEngine()->getWorkingCopy()->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)); | ||||
| $this->messages[] = $message; | $this->messages[] = $message; | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | return array( | ||||
| 'Provide a map of regular expressions to severity levels. All '. | 'Provide a map of regular expressions to severity levels. All '. | ||||
| 'matching codes have their severity adjusted.'), | 'matching codes have their severity adjusted.'), | ||||
| ), | ), | ||||
| ); | ); | ||||
| } | } | ||||
| public function setLinterConfigurationValue($key, $value) { | public function setLinterConfigurationValue($key, $value) { | ||||
| $sev_map = array( | $sev_map = array( | ||||
| 'error' => ArcanistLintSeverity::SEVERITY_ERROR, | 'error' => ArcanistLintSeverity::SEVERITY_ERROR, | ||||
| 'warning' => ArcanistLintSeverity::SEVERITY_WARNING, | 'warning' => ArcanistLintSeverity::SEVERITY_WARNING, | ||||
| 'autofix' => ArcanistLintSeverity::SEVERITY_AUTOFIX, | 'autofix' => ArcanistLintSeverity::SEVERITY_AUTOFIX, | ||||
| 'advice' => ArcanistLintSeverity::SEVERITY_ADVICE, | 'advice' => ArcanistLintSeverity::SEVERITY_ADVICE, | ||||
| 'disabled' => ArcanistLintSeverity::SEVERITY_DISABLED, | 'disabled' => ArcanistLintSeverity::SEVERITY_DISABLED, | ||||
| ); | ); | ||||
| switch ($key) { | switch ($key) { | ||||
| case 'severity': | case 'severity': | ||||
| if (!$this->canCustomizeLintSeverities()) { | if (!$this->canCustomizeLintSeverities()) { | ||||
| break; | break; | ||||
| } | } | ||||
| Show All 35 Lines | switch ($key) { | ||||
| $severity, | $severity, | ||||
| $valid)); | $valid)); | ||||
| } | } | ||||
| } | } | ||||
| $this->setCustomSeverityRules($value); | $this->setCustomSeverityRules($value); | ||||
| return; | return; | ||||
| } | } | ||||
| throw new Exception("Incomplete implementation: {$key}!"); | throw new Exception(pht('Incomplete implementation: %s!', $key)); | ||||
| } | } | ||||
| protected function canCustomizeLintSeverities() { | protected function canCustomizeLintSeverities() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| protected function shouldLintBinaryFiles() { | protected function shouldLintBinaryFiles() { | ||||
| return false; | return false; | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | final protected function getDeprecatedConfiguration($key, $default = null) { | ||||
| // discouraged. | // discouraged. | ||||
| if ($result !== $sentinel) { | if ($result !== $sentinel) { | ||||
| $console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
| $console->writeErr( | $console->writeErr( | ||||
| "**%s**: %s\n", | "**%s**: %s\n", | ||||
| pht('Deprecation Warning'), | pht('Deprecation Warning'), | ||||
| pht( | pht( | ||||
| 'Configuration option "%s" is deprecated. Generally, linters should '. | 'Configuration option "%s" is deprecated. Generally, linters should '. | ||||
| 'now be configured using an `.arclint` file. See "Arcanist User '. | 'now be configured using an `%s` file. See "Arcanist User '. | ||||
| 'Guide: Lint" in the documentation for more information.', | 'Guide: Lint" in the documentation for more information.', | ||||
| $key)); | $key, | ||||
| '.arclint')); | |||||
| return $result; | return $result; | ||||
| } | } | ||||
| return $default; | return $default; | ||||
| } | } | ||||
| } | } | ||||