]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix checking for lint binary paths
authorvrana <jakubv@fb.com>
Thu, 10 Jan 2013 23:22:49 +0000 (15:22 -0800)
committervrana <jakubv@fb.com>
Thu, 10 Jan 2013 23:34:42 +0000 (15:34 -0800)
Summary: Like D4379.

Test Plan:
  $ arc unit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4391

src/lint/linter/ArcanistCppcheckLinter.php
src/lint/linter/ArcanistCpplintLinter.php
src/lint/linter/ArcanistFlake8Linter.php
src/lint/linter/ArcanistPEP8Linter.php

index 7ed4e587a413232f5e779c778bb3072e2ed450be..6b8fcf4eb198a991c9e1c55a266fc9f68dc7f07e 100644 (file)
@@ -32,43 +32,34 @@ final class ArcanistCppcheckLinter extends ArcanistLinter {
   public function getLintPath() {
     $working_copy = $this->getEngine()->getWorkingCopy();
     $prefix = $working_copy->getConfig('lint.cppcheck.prefix');
-    $bin = $working_copy->getConfig('lint.cppcheck.bin');
+    $bin = $working_copy->getConfig('lint.cppcheck.bin', 'cppcheck');
 
-    if ($bin === null && $prefix === null) {
-      $bin = 'cppcheck';
-    } else {
-      if ($bin === null) {
-        $bin = 'cppcheck';
+    if ($prefix !== null) {
+      if (!Filesystem::pathExists($prefix.'/'.$bin)) {
+        throw new ArcanistUsageException(
+          "Unable to find cppcheck binary in a specified directory. Make ".
+          "sure that 'lint.cppcheck.prefix' and 'lint.cppcheck.bin' keys are ".
+          "set correctly. If you'd rather use a copy of cppcheck 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 cppcheck binary in a specified directory. Make ".
-            "sure that 'lint.cppcheck.prefix' and 'lint.cppcheck.bin' keys are".
-            " set correctly. If you'd rather use a copy of cppcheck 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 cppcheck
-      list($err) = exec_manual('which %s', $bin);
-      if ($err) {
-        throw new ArcanistUsageException(
-          "cppcheck does not appear to be installed on this system. Install".
-          "it (from http://cppcheck.sourceforge.net/) or configure".
-          "'lint.cppcheck.prefix' in your .arcconfig to point to the".
-          "directory where it resides."
-        );
-      }
+    // Look for globally installed cppcheck
+    list($err) = exec_manual('which %s', $bin);
+    if ($err) {
+      throw new ArcanistUsageException(
+        "cppcheck does not appear to be installed on this system. Install ".
+        "it (from http://cppcheck.sourceforge.net/) or configure ".
+        "'lint.cppcheck.prefix' in your .arcconfig to point to the ".
+        "directory where it resides."
+      );
     }
 
     return $bin;
-
   }
 
   public function lintPath($path) {
index e2d3f137f9920419574e7315f9355e391cb22678..24117790a360c4b4c50d1bba510e9652e9256859 100644 (file)
@@ -27,43 +27,34 @@ final class ArcanistCpplintLinter extends ArcanistLinter {
   public function getLintPath() {
     $working_copy = $this->getEngine()->getWorkingCopy();
     $prefix = $working_copy->getConfig('lint.cpplint.prefix');
-    $bin = $working_copy->getConfig('lint.cpplint.bin');
+    $bin = $working_copy->getConfig('lint.cpplint.bin', 'cpplint.py');
 
-    if ($bin === null && $prefix === null) {
-      $bin = 'cpplint.py';
-    } else {
-      if ($bin === null) {
-        $bin = 'cpplint.py';
+    if ($prefix !== null) {
+      if (!Filesystem::pathExists($prefix.'/'.$bin)) {
+        throw new ArcanistUsageException(
+          "Unable to find cpplint.py binary in a specified directory. Make ".
+          "sure that 'lint.cpplint.prefix' and 'lint.cpplint.bin' keys are ".
+          "set correctly. If you'd rather use a copy of cpplint 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 cpplint.py binary in a specified directory. Make ".
-            "sure that 'lint.cpplint.prefix' and 'lint.cpplint.bin' keys are ".
-            "set correctly. If you'd rather use a copy of cpplint 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 cpplint.py
-      list($err) = exec_manual('which %s', $bin);
-      if ($err) {
-        throw new ArcanistUsageException(
-          "cpplint.py does not appear to be installed on this system. Install".
-          "it (e.g., with 'wget \"http://google-styleguide.googlecode.com/".
-          "svn/trunk/cpplint/cpplint.py\"') or configure 'lint.cpplint.prefix'".
-          "in your .arcconfig to point to the directory where it resides.  ".
-          "Also don't forget to chmod a+x cpplint.py!");
-      }
+    // Look for globally installed cpplint.py
+    list($err) = exec_manual('which %s', $bin);
+    if ($err) {
+      throw new ArcanistUsageException(
+        "cpplint.py does not appear to be installed on this system. Install ".
+        "it (e.g., with 'wget \"http://google-styleguide.googlecode.com/".
+        "svn/trunk/cpplint/cpplint.py\"') or configure 'lint.cpplint.prefix' ".
+        "in your .arcconfig to point to the directory where it resides. ".
+        "Also don't forget to chmod a+x cpplint.py!");
     }
 
     return $bin;
-
   }
 
   public function lintPath($path) {
index 28925dccbcd6c628ab49dc4e03570494ae6247f5..2a7690a44927f022884c4c8b2823292cd55b6dba 100644 (file)
@@ -35,7 +35,7 @@ final class ArcanistFlake8Linter extends ArcanistLinter {
           "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");
+          "globally, you can just remove these keys from your .arcconfig.");
       }
 
       $bin = csprintf("%s/%s", $prefix, $bin);
index 6cd95ad8fb1395dd1ca0d8511cdfcca346da104d..80d7ac95969810b55127ee78b800747610239de3 100644 (file)
@@ -59,7 +59,7 @@ final class ArcanistPEP8Linter extends ArcanistLinter {
             "Unable to find PEP8 binary in a specified directory. Make sure ".
             "that 'lint.pep8.prefix' and 'lint.pep8.bin' keys are set ".
             "correctly. If you'd rather use a copy of PEP8 installed ".
-            "globally, you can just remove these keys from your .arcconfig");
+            "globally, you can just remove these keys from your .arcconfig.");
         }
 
         $bin = csprintf("%s/%s", $prefix, $bin);