diff --git a/src/lint/linter/ArcanistCppcheckLinter.php b/src/lint/linter/ArcanistCppcheckLinter.php index 7ed4e587..6b8fcf4e 100644 --- a/src/lint/linter/ArcanistCppcheckLinter.php +++ b/src/lint/linter/ArcanistCppcheckLinter.php @@ -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"); - } - - $bin = csprintf("%s/%s", $prefix, $bin); - - return $bin; - } - - // Look for globally installed cppcheck - list($err) = exec_manual('which %s', $bin); - if ($err) { + if ($prefix !== null) { + if (!Filesystem::pathExists($prefix.'/'.$bin)) { 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." - ); + "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); + + 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." + ); } return $bin; - } public function lintPath($path) { diff --git a/src/lint/linter/ArcanistCpplintLinter.php b/src/lint/linter/ArcanistCpplintLinter.php index e2d3f137..24117790 100644 --- a/src/lint/linter/ArcanistCpplintLinter.php +++ b/src/lint/linter/ArcanistCpplintLinter.php @@ -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"); - } - - $bin = csprintf("%s/%s", $prefix, $bin); - - return $bin; - } - - // Look for globally installed cpplint.py - list($err) = exec_manual('which %s', $bin); - if ($err) { + if ($prefix !== null) { + if (!Filesystem::pathExists($prefix.'/'.$bin)) { 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!"); + "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); + + 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!"); } return $bin; - } public function lintPath($path) { diff --git a/src/lint/linter/ArcanistFlake8Linter.php b/src/lint/linter/ArcanistFlake8Linter.php index 28925dcc..2a7690a4 100644 --- a/src/lint/linter/ArcanistFlake8Linter.php +++ b/src/lint/linter/ArcanistFlake8Linter.php @@ -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); diff --git a/src/lint/linter/ArcanistPEP8Linter.php b/src/lint/linter/ArcanistPEP8Linter.php index 6cd95ad8..80d7ac95 100644 --- a/src/lint/linter/ArcanistPEP8Linter.php +++ b/src/lint/linter/ArcanistPEP8Linter.php @@ -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);