1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01:00

Simplified the logic in various functions.

Summary:
- Tidied up `ArcanistCSSLintLinter::getDefaultBinary`.
- Tidied up `CSSLintLinter::getDefaultFlags` function.
- Tidied up `ArcanistPhpcsLinter::getDefaultBinary` function.
- Tidied up `ArcanistPEP8Linter::getDefaultFlags` function
- Tidied up `ArcanistFlake8Linter::getDefaultFlags`.
- Tidied up `ArcanistCppcheckLinter::getLintOptions`.
- Tidied up `ArcanistCppcheckLinter::getLintPath`.
- Tidied up `ArcanistCpplintLinter::getLintOptions`.
- Tidied up `ArcanistCpplintLinter::getLintPath`.
- Removed child functions which are identical to the corresponding parent functions.

Test Plan: `arc lint` and `arc unit`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: chad, Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8385
This commit is contained in:
Joshua Spence 2014-03-04 11:00:01 -08:00 committed by epriestley
parent 9fb2a147f9
commit 9bca4bfda8
10 changed files with 12 additions and 87 deletions

View file

@ -23,23 +23,15 @@ final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
} }
public function getDefaultFlags() { public function getDefaultFlags() {
$config = $this->getEngine()->getConfigurationManager();
$options = $config->getConfigFromAnySource('lint.csslint.options');
// TODO: Deprecation warning. // TODO: Deprecation warning.
$config = $this->getEngine()->getConfigurationManager();
return $options; return $config->getConfigFromAnySource('lint.csslint.options');
} }
public function getDefaultBinary() { public function getDefaultBinary() {
// TODO: Deprecation warning. // TODO: Deprecation warning.
$config = $this->getEngine()->getConfigurationManager(); $config = $this->getEngine()->getConfigurationManager();
$bin = $config->getConfigFromAnySource('lint.csslint.bin'); return $config->getConfigFromAnySource('lint.csslint.bin', 'csslint');
if ($bin) {
return $bin;
}
return 'csslint';
} }
public function getInstallInstructions() { public function getInstallInstructions() {

View file

@ -64,14 +64,6 @@ final class ArcanistCSharpLinter extends ArcanistLinter {
return parent::setCustomSeverityMap($map); return parent::setCustomSeverityMap($map);
} }
public function getLintSeverityMap() {
return array();
}
public function getLintNameMap() {
return array();
}
/** /**
* Determines what executables and lint paths to use. Between platforms * Determines what executables and lint paths to use. Between platforms
* this also changes whether the lint engine is run under .NET or Mono. It * this also changes whether the lint engine is run under .NET or Mono. It

View file

@ -10,10 +10,6 @@
*/ */
final class ArcanistCppcheckLinter extends ArcanistLinter { final class ArcanistCppcheckLinter extends ArcanistLinter {
public function willLintPaths(array $paths) {
return;
}
public function getLinterName() { public function getLinterName() {
return 'cppcheck'; return 'cppcheck';
} }
@ -21,11 +17,9 @@ final class ArcanistCppcheckLinter extends ArcanistLinter {
public function getLintOptions() { public function getLintOptions() {
$config = $this->getEngine()->getConfigurationManager(); $config = $this->getEngine()->getConfigurationManager();
// You will for sure want some options. The below default tends to be ok // You will for sure want some options. The below default tends to be ok
$options = $config->getConfigFromAnySource( return $config->getConfigFromAnySource(
'lint.cppcheck.options', 'lint.cppcheck.options',
'-j2 --inconclusive --enable=performance,style,portability,information'); '-j2 --inconclusive --enable=performance,style,portability,information');
return $options;
} }
public function getLintPath() { public function getLintPath() {
@ -42,9 +36,7 @@ final class ArcanistCppcheckLinter extends ArcanistLinter {
"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); return csprintf("%s/%s", $prefix, $bin);
return $bin;
} }
// Look for globally installed cppcheck // Look for globally installed cppcheck

View file

@ -9,19 +9,13 @@
*/ */
final class ArcanistCpplintLinter extends ArcanistLinter { final class ArcanistCpplintLinter extends ArcanistLinter {
public function willLintPaths(array $paths) {
return;
}
public function getLinterName() { public function getLinterName() {
return 'cpplint.py'; return 'cpplint.py';
} }
public function getLintOptions() { public function getLintOptions() {
$config = $this->getEngine()->getConfigurationManager(); $config = $this->getEngine()->getConfigurationManager();
$options = $config->getConfigFromAnySource('lint.cpplint.options', ''); return $config->getConfigFromAnySource('lint.cpplint.options', '');
return $options;
} }
public function getLintPath() { public function getLintPath() {
@ -38,9 +32,7 @@ final class ArcanistCpplintLinter extends ArcanistLinter {
"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); return csprintf("%s/%s", $prefix, $bin);
return $bin;
} }
// Look for globally installed cpplint.py // Look for globally installed cpplint.py

View file

@ -18,12 +18,8 @@ final class ArcanistFlake8Linter extends ArcanistExternalLinter {
public function getDefaultFlags() { public function getDefaultFlags() {
// TODO: Deprecated. // TODO: Deprecated.
$config = $this->getEngine()->getConfigurationManager(); $config = $this->getEngine()->getConfigurationManager();
return $config->getConfigFromAnySource('lint.flake8.options', '');
$options = $config->getConfigFromAnySource('lint.flake8.options', '');
return $options;
} }
public function getDefaultBinary() { public function getDefaultBinary() {

View file

@ -22,15 +22,10 @@ final class ArcanistPEP8Linter extends ArcanistExternalLinter {
public function getDefaultFlags() { public function getDefaultFlags() {
// TODO: Warn that all of this is deprecated. // TODO: Warn that all of this is deprecated.
$config = $this->getEngine()->getConfigurationManager(); $config = $this->getEngine()->getConfigurationManager();
$options = $config->getConfigFromAnySource('lint.pep8.options'); return $config->getConfigFromAnySource(
'lint.pep8.options',
if ($options === null) { $this->getConfig('options'));
$options = $this->getConfig('options');
}
return $options;
} }
public function shouldUseInterpreter() { public function shouldUseInterpreter() {

View file

@ -49,12 +49,7 @@ final class ArcanistPhpcsLinter extends ArcanistExternalLinter {
public function getDefaultBinary() { public function getDefaultBinary() {
// TODO: Deprecation warnings. // TODO: Deprecation warnings.
$config = $this->getEngine()->getConfigurationManager(); $config = $this->getEngine()->getConfigurationManager();
$bin = $config->getConfigFromAnySource('lint.phpcs.bin'); return $config->getConfigFromAnySource('lint.phpcs.bin', 'phpcs');
if ($bin) {
return $bin;
}
return 'phpcs';
} }
public function shouldExpectCommandErrors() { public function shouldExpectCommandErrors() {

View file

@ -28,10 +28,6 @@ final class ArcanistPhutilLibraryLinter extends ArcanistLinter {
return 'PHL'; return 'PHL';
} }
public function getLintSeverityMap() {
return array();
}
public function willLintPaths(array $paths) { public function willLintPaths(array $paths) {
if (!xhpast_is_available()) { if (!xhpast_is_available()) {
throw new Exception(xhpast_get_build_instructions()); throw new Exception(xhpast_get_build_instructions());

View file

@ -7,23 +7,10 @@
*/ */
final class ArcanistPyFlakesLinter extends ArcanistLinter { final class ArcanistPyFlakesLinter extends ArcanistLinter {
public function willLintPaths(array $paths) {
return;
}
public function getLinterName() { public function getLinterName() {
return 'PyFlakes'; return 'PyFlakes';
} }
public function getLintSeverityMap() {
return array();
}
public function getLintNameMap() {
return array(
);
}
public function getPyFlakesOptions() { public function getPyFlakesOptions() {
return null; return null;
} }

View file

@ -187,22 +187,10 @@ final class ArcanistPyLintLinter extends ArcanistLinter {
return implode(" ", $options); return implode(" ", $options);
} }
public function willLintPaths(array $paths) {
return;
}
public function getLinterName() { public function getLinterName() {
return 'PyLint'; return 'PyLint';
} }
public function getLintSeverityMap() {
return array();
}
public function getLintNameMap() {
return array();
}
public function lintPath($path) { public function lintPath($path) {
$pylint_bin = $this->getPyLintPath(); $pylint_bin = $this->getPyLintPath();
$python_path = $this->getPyLintPythonPath(); $python_path = $this->getPyLintPythonPath();