]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't lint symlinks by default.
authorJoshua Spence <josh@joshuaspence.com>
Wed, 11 Jun 2014 01:20:59 +0000 (18:20 -0700)
committerepriestley <git@epriestley.com>
Wed, 11 Jun 2014 01:20:59 +0000 (18:20 -0700)
Summary: Fixes T5300. Currently, if a dead symbolic link is linted, all kinds of errors will be thrown by most linters because they will try to read the (non-existent) file contents. Instead, let's not lint symbolic links by default. In the case that the target of a symbolic link is inside the working copy, then it should be being linted anyway.

Test Plan: Created a symbolic link and verified that it wasn't linted (by any linter other than the `ArcanistFilenameLinter`).

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T5300

Differential Revision: https://secure.phabricator.com/D9448

src/lint/engine/ArcanistLintEngine.php
src/lint/linter/ArcanistFilenameLinter.php
src/lint/linter/ArcanistLinter.php

index 8ccfd5f9cc0e1bdf3651aae28fac2a085ccf1ed6..2ba79fc7e2e19b4a49e417dfe42e3fe8c98bf89d 100644 (file)
@@ -190,6 +190,10 @@ abstract class ArcanistLintEngine {
     return ArcanistDiffUtils::isHeuristicBinaryFile($data);
   }
 
+  final public function isSymbolicLink($path) {
+    return is_link($this->getFilePathOnDisk($path));
+  }
+
   final public function getFilePathOnDisk($path) {
     return Filesystem::resolvePath(
       $path,
index 40d63250ad5911a89c7a1302219ff29e82966630..59d38c0080e30869e91da73371ec5c78a204b5b0 100644 (file)
@@ -49,4 +49,8 @@ final class ArcanistFilenameLinter extends ArcanistLinter {
     return true;
   }
 
+  public function shouldLintSymbolicLinks() {
+    return true;
+  }
+
 }
index 60cc53f1a5ed654684d1abfb9f41652002fb1879..410f0903d75f48d13e95cf7bd65217e4ae7e5387 100644 (file)
@@ -148,6 +148,10 @@ abstract class ArcanistLinter {
         continue;
       }
 
+      if (!$this->shouldLintSymbolicLinks() && $engine->isSymbolicLink($path)) {
+        continue;
+      }
+
       $keep[] = $path;
     }
 
@@ -442,6 +446,10 @@ abstract class ArcanistLinter {
     return false;
   }
 
+  protected function shouldLintSymbolicLinks() {
+    return false;
+  }
+
   /**
    * Map a configuration lint code to an `arc` lint code. Primarily, this is
    * intended for validation, but can also be used to normalize case or