From: vrana Date: Thu, 14 Feb 2013 23:49:22 +0000 (-0800) Subject: Don't run disabled lint rules in other linters. X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=cd50b0884e9e6faa280b554e3501cf99ca27674f;p=arcanist.git Don't run disabled lint rules in other linters. Summary: D4963 for other linters. Test Plan: Saw time 0.001 instead of 0.113 in spellcheck linter. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4965 --- diff --git a/src/lint/linter/ArcanistJSHintLinter.php b/src/lint/linter/ArcanistJSHintLinter.php index ac6ecc31..9a066dae 100644 --- a/src/lint/linter/ArcanistJSHintLinter.php +++ b/src/lint/linter/ArcanistJSHintLinter.php @@ -118,6 +118,10 @@ final class ArcanistJSHintLinter extends ArcanistLinter { } public function willLintPaths(array $paths) { + if (!$this->isCodeEnabled(self::JSHINT_ERROR)) { + return; + } + $jshint_bin = $this->getJSHintPath(); $jshint_options = $this->getJSHintOptions(); $futures = array(); @@ -137,6 +141,10 @@ final class ArcanistJSHintLinter extends ArcanistLinter { } public function lintPath($path) { + if (!$this->isCodeEnabled(self::JSHINT_ERROR)) { + return; + } + list($rc, $stdout, $stderr) = $this->results[$path]; if ($rc === 0) { diff --git a/src/lint/linter/ArcanistPEP8Linter.php b/src/lint/linter/ArcanistPEP8Linter.php index 735cfcfd..3e4a51a0 100644 --- a/src/lint/linter/ArcanistPEP8Linter.php +++ b/src/lint/linter/ArcanistPEP8Linter.php @@ -82,6 +82,12 @@ final class ArcanistPEP8Linter extends ArcanistLinter { } public function lintPath($path) { + $severity = ArcanistLintSeverity::SEVERITY_WARNING; + + if (!$this->getEngine()->isSeverityEnabled($severity)) { + return; + } + $pep8_bin = $this->getPEP8Path(); $options = $this->getPEP8Options(); @@ -111,7 +117,7 @@ final class ArcanistPEP8Linter extends ArcanistLinter { $message->setCode($matches[4]); $message->setName('PEP8 '.$matches[4]); $message->setDescription($matches[5]); - $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING); + $message->setSeverity($severity); $this->addLintMessage($message); } } diff --git a/src/lint/linter/ArcanistPhutilXHPASTLinter.php b/src/lint/linter/ArcanistPhutilXHPASTLinter.php index bd98b3da..7d03bbbf 100644 --- a/src/lint/linter/ArcanistPhutilXHPASTLinter.php +++ b/src/lint/linter/ArcanistPhutilXHPASTLinter.php @@ -80,9 +80,20 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter { $root = $tree->getRootNode(); - $this->lintArrayCombine($root); - $this->lintUnsafeDynamicString($root); - $this->lintDeprecatedFunctions($root); + $method_codes = array( + 'lintArrayCombine' => self::LINT_ARRAY_COMBINE, + 'lintUnsafeDynamicString' => self::LINT_UNSAFE_DYNAMIC_STRING, + 'lintDeprecatedFunctions' => self::LINT_DEPRECATED_FUNCTION, + ); + + foreach ($method_codes as $method => $codes) { + foreach ((array)$codes as $code) { + if ($this->isCodeEnabled($code)) { + call_user_func(array($this, $method), $root); + break; + } + } + } } diff --git a/src/lint/linter/ArcanistSpellingLinter.php b/src/lint/linter/ArcanistSpellingLinter.php index 032e51e1..928bad43 100644 --- a/src/lint/linter/ArcanistSpellingLinter.php +++ b/src/lint/linter/ArcanistSpellingLinter.php @@ -73,13 +73,20 @@ final class ArcanistSpellingLinter extends ArcanistLinter { public function lintPath($path) { foreach ($this->partialWordRules as $severity => $wordlist) { if ($severity >= $this->severity) { + if (!$this->isCodeEnabled($severity)) { + continue; + } foreach ($wordlist as $misspell => $correct) { $this->checkPartialWord($path, $misspell, $correct, $severity); } } } + foreach ($this->wholeWordRules as $severity => $wordlist) { if ($severity >= $this->severity) { + if (!$this->isCodeEnabled($severity)) { + continue; + } foreach ($wordlist as $misspell => $correct) { $this->checkWholeWord($path, $misspell, $correct, $severity); }