From: Joshua Spence Date: Wed, 11 Jun 2014 01:20:59 +0000 (-0700) Subject: Don't lint symlinks by default. X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=02e3905cf50a128f58c7c6fc7a3266a09a1e286d;p=arcanist.git Don't lint symlinks by default. 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 --- diff --git a/src/lint/engine/ArcanistLintEngine.php b/src/lint/engine/ArcanistLintEngine.php index 8ccfd5f9..2ba79fc7 100644 --- a/src/lint/engine/ArcanistLintEngine.php +++ b/src/lint/engine/ArcanistLintEngine.php @@ -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, diff --git a/src/lint/linter/ArcanistFilenameLinter.php b/src/lint/linter/ArcanistFilenameLinter.php index 40d63250..59d38c00 100644 --- a/src/lint/linter/ArcanistFilenameLinter.php +++ b/src/lint/linter/ArcanistFilenameLinter.php @@ -49,4 +49,8 @@ final class ArcanistFilenameLinter extends ArcanistLinter { return true; } + public function shouldLintSymbolicLinks() { + return true; + } + } diff --git a/src/lint/linter/ArcanistLinter.php b/src/lint/linter/ArcanistLinter.php index 60cc53f1..410f0903 100644 --- a/src/lint/linter/ArcanistLinter.php +++ b/src/lint/linter/ArcanistLinter.php @@ -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