]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix checking for flake8 path
authorvrana <jakubv@fb.com>
Wed, 9 Jan 2013 21:37:08 +0000 (13:37 -0800)
committervrana <jakubv@fb.com>
Wed, 9 Jan 2013 21:41:10 +0000 (13:41 -0800)
Test Plan:
  $ arc unit # without flake8 in path

Reviewers: zeeg

Reviewed By: zeeg

CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D4379

src/lint/linter/ArcanistFlake8Linter.php

index 7bb20fdaa60aa10199ed915f00903c3200963d2d..28925dccbcd6c628ab49dc4e03570494ae6247f5 100644 (file)
@@ -27,38 +27,30 @@ final class ArcanistFlake8Linter extends ArcanistLinter {
   public function getFlake8Path() {
     $working_copy = $this->getEngine()->getWorkingCopy();
     $prefix = $working_copy->getConfig('lint.flake8.prefix');
-    $bin = $working_copy->getConfig('lint.flake8.bin');
+    $bin = $working_copy->getConfig('lint.flake8.bin', 'flake8');
 
-    if ($bin === null && $prefix === null) {
-      $bin = 'flake8';
-    } else {
-      if ($bin === null) {
-        $bin = 'flake8';
+    if ($prefix !== null) {
+      if (!Filesystem::pathExists($prefix.'/'.$bin)) {
+        throw new ArcanistUsageException(
+          "Unable to find flake8 binary in a specified directory. Make sure ".
+          "that 'lint.flake8.prefix' and 'lint.flake8.bin' keys are set ".
+          "correctly. If you'd rather use a copy of flake8 installed ".
+          "globally, you can just remove these keys from your .arcconfig");
       }
 
-      if ($prefix !== null) {
-        if (!Filesystem::pathExists($prefix.'/'.$bin)) {
-          throw new ArcanistUsageException(
-            "Unable to find flake8 binary in a specified directory. Make sure ".
-            "that 'lint.flake8.prefix' and 'lint.flake8.bin' keys are set ".
-            "correctly. If you'd rather use a copy of flake8 installed ".
-            "globally, you can just remove these keys from your .arcconfig");
-        }
-
-        $bin = csprintf("%s/%s", $prefix, $bin);
+      $bin = csprintf("%s/%s", $prefix, $bin);
 
-        return $bin;
-      }
+      return $bin;
+    }
 
-      // Look for globally installed flake8
-      list($err) = exec_manual('which %s', $bin);
-      if ($err) {
-        throw new ArcanistUsageException(
-          "flake8 does not appear to be installed on this system. Install it ".
-          "(e.g., with 'easy_install flake8') or configure ".
-          "'lint.flake8.prefix' in your .arcconfig to point to the directory ".
-          "where it resides.");
-      }
+    // Look for globally installed flake8
+    list($err) = exec_manual('which %s', $bin);
+    if ($err) {
+      throw new ArcanistUsageException(
+        "flake8 does not appear to be installed on this system. Install it ".
+        "(e.g., with 'easy_install flake8') or configure ".
+        "'lint.flake8.prefix' in your .arcconfig to point to the directory ".
+        "where it resides.");
     }
 
     return $bin;