mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Updating the pylint linter to set the output fomat correctly depending on the version of pylint installed
See: <https://github.com/facebook/arcanist/pull/161> Reviewed by: epriestley
This commit is contained in:
parent
b4e91e1a37
commit
85000be96f
1 changed files with 33 additions and 2 deletions
|
@ -161,8 +161,16 @@ final class ArcanistPyLintLinter extends ArcanistLinter {
|
||||||
|
|
||||||
private function getPyLintOptions() {
|
private function getPyLintOptions() {
|
||||||
// '-rn': don't print lint report/summary at end
|
// '-rn': don't print lint report/summary at end
|
||||||
// '-iy': show message codes for lint warnings/errors
|
$options = array('-rn');
|
||||||
$options = array('-rn', '-iy');
|
|
||||||
|
// Version 0.x.x include the pylint message ids in the output
|
||||||
|
if (version_compare($this->getLinterVersion(), "1", 'lt')) {
|
||||||
|
array_push($options, '-iy', "--output-format=text");
|
||||||
|
}
|
||||||
|
// Version 1.x.x set the output specifically to the 0.x.x format
|
||||||
|
else {
|
||||||
|
array_push($options, "--msg-template='{msg_id}:{line:3d}: {obj}: {msg}'");
|
||||||
|
}
|
||||||
|
|
||||||
$working_copy = $this->getEngine()->getWorkingCopy();
|
$working_copy = $this->getEngine()->getWorkingCopy();
|
||||||
$config = $this->getEngine()->getConfigurationManager();
|
$config = $this->getEngine()->getConfigurationManager();
|
||||||
|
@ -191,6 +199,29 @@ final class ArcanistPyLintLinter extends ArcanistLinter {
|
||||||
return 'PyLint';
|
return 'PyLint';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getLinterVersion() {
|
||||||
|
|
||||||
|
$pylint_bin = $this->getPyLintPath();
|
||||||
|
$options = '--version';
|
||||||
|
|
||||||
|
list($stdout) = execx(
|
||||||
|
'%s %s',
|
||||||
|
$pylint_bin,
|
||||||
|
$options);
|
||||||
|
|
||||||
|
$lines = explode("\n", $stdout);
|
||||||
|
$matches = null;
|
||||||
|
|
||||||
|
// If the version command didn't return anything or the regex didn't match
|
||||||
|
// Assume a future version that at least is compatible with 1.x.x
|
||||||
|
if (count($lines) == 0 ||
|
||||||
|
!preg_match('/pylint\s((?:\d+\.?)+)/', $lines[0], $matches)) {
|
||||||
|
return "999";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $matches[1];
|
||||||
|
}
|
||||||
|
|
||||||
public function lintPath($path) {
|
public function lintPath($path) {
|
||||||
$pylint_bin = $this->getPyLintPath();
|
$pylint_bin = $this->getPyLintPath();
|
||||||
$python_path = $this->getPyLintPythonPath();
|
$python_path = $this->getPyLintPythonPath();
|
||||||
|
|
Loading…
Reference in a new issue