]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't run disabled lint rules in other linters.
authorvrana <jakubv@fb.com>
Thu, 14 Feb 2013 23:49:22 +0000 (15:49 -0800)
committervrana <jakubv@fb.com>
Thu, 14 Feb 2013 23:54:10 +0000 (15:54 -0800)
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

src/lint/linter/ArcanistJSHintLinter.php
src/lint/linter/ArcanistPEP8Linter.php
src/lint/linter/ArcanistPhutilXHPASTLinter.php
src/lint/linter/ArcanistSpellingLinter.php

index ac6ecc3187ceeaa649a8aa44b75ad8673297e396..9a066dae2928e4f24558ff86462b47f7d9f5f647 100644 (file)
@@ -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) {
index 735cfcfd17f28c601f3cf7ef4f0557c8acb7860c..3e4a51a04f7d393424a914f9b6a73d7a39fc1277 100644 (file)
@@ -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);
     }
   }
index bd98b3da2d730e04a268e435e8fdfaeb708b77a0..7d03bbbfcfb3520799985f1bd9df62ceb99b1c0a 100644 (file)
@@ -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;
+        }
+      }
+    }
   }
 
 
index 032e51e14746e6752206bd5e6c0265767f3839bd..928bad430eabc3fdbd05b014747a62bef388f38f 100644 (file)
@@ -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);
         }