Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistLinter.php
| Show First 20 Lines • Show All 301 Lines • ▼ Show 20 Lines | /* -( Human Readable Information )---------------------------------------- */ | ||||
| public function willLintPaths(array $paths) { | public function willLintPaths(array $paths) { | ||||
| return; | return; | ||||
| } | } | ||||
| abstract public function lintPath($path); | abstract public function lintPath($path); | ||||
| abstract public function getLinterName(); | abstract public function getLinterName(); | ||||
| /** | |||||
| * TODO | |||||
| * | |||||
| * @return string | |||||
| */ | |||||
| public function getVersion() { | public function getVersion() { | ||||
| return null; | return null; | ||||
| } | } | ||||
| /** | |||||
| * TODO | |||||
| * | |||||
| * @return bool | |||||
| */ | |||||
| final public function hasVersion() { | |||||
| $method = new ReflectionMethod($this, 'getVersion'); | |||||
| return $method->getDeclaringClass()->isAbstract(); | |||||
| } | |||||
| /** | |||||
| * Compare the version of the linter with a target version. | |||||
| * | |||||
| * @param string The target version for the linter. | |||||
| * @param string The desired version relationship. The possible values are | |||||
| * `<`, `<=`, `>`, `>=`, `==`, `=`, `!=` and `<>`. | |||||
| * @return bool True if the relationship is the one specified by the operator, | |||||
| * false otherwise. | |||||
| */ | |||||
| protected function compareVersion($target_version, $operator) { | |||||
| if (!$this->hasVersion()) { | |||||
| throw new Exception(pht( | |||||
| 'Version cannot be compared because %s does not provide version '. | |||||
| 'information.', | |||||
| get_class($this))); | |||||
| } | |||||
| $version = $this->getVersion(); | |||||
| if (!$version) { | |||||
| // TODO: We should output the minimum version requirement here. | |||||
| throw new Exception(pht('Unable to parse version.')); | |||||
| } | |||||
| // The PHP version_compare method does a pretty good job in the general | |||||
| // case. | |||||
| return version_compare($version, $target_version, $operator); | |||||
| } | |||||
| public function didRunLinters() { | public function didRunLinters() { | ||||
| // This is a hook. | // This is a hook. | ||||
| } | } | ||||
| final protected function isCodeEnabled($code) { | final protected function isCodeEnabled($code) { | ||||
| $severity = $this->getLintMessageSeverity($code); | $severity = $this->getLintMessageSeverity($code); | ||||
| return $this->getEngine()->isSeverityEnabled($severity); | return $this->getEngine()->isSeverityEnabled($severity); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines | |||||