Changeset View
Changeset View
Standalone View
Standalone View
arcanist/linter/AutoPEP8Linter.php
Show All 20 Lines | public function getLinterName() { | ||||
return 'autopep8'; | return 'autopep8'; | ||||
} | } | ||||
public function getLinterConfigurationName() { | public function getLinterConfigurationName() { | ||||
return 'autopep8'; | return 'autopep8'; | ||||
} | } | ||||
public function getLinterConfigurationOptions() { | public function getLinterConfigurationOptions() { | ||||
$options = array( | $options = array(); | ||||
); | |||||
return $options + parent::getLinterConfigurationOptions(); | return $options + parent::getLinterConfigurationOptions(); | ||||
} | } | ||||
public function getDefaultBinary() { | public function getDefaultBinary() { | ||||
return 'autopep8'; | return 'autopep8'; | ||||
} | } | ||||
public function getVersion() { | public function getVersion() { | ||||
list($stdout, $stderr) = execx('%C --version', | list($stdout, $stderr) = execx('%C --version', | ||||
$this->getExecutableCommand()); | $this->getExecutableCommand()); | ||||
$matches = array(); | $matches = array(); | ||||
/* Support a.b or a.b.c version numbering scheme */ | /* Support a.b or a.b.c version numbering scheme */ | ||||
$regex = '/^autopep8 (?P<version>\d+\.\d+(?:\.\d+)?)/'; | $regex = '/^autopep8 (?P<version>\d+\.\d+(?:\.\d+)?)/'; | ||||
/* | /* | ||||
* Old autopep8 output the version to stdout, newer output to stderr. | * Old autopep8 output the version to stdout, newer output to stderr. | ||||
* Try both to determine the version. | * Try both to determine the version. | ||||
*/ | */ | ||||
deadalnix: This is quite apparently broken. | |||||
FabienAuthorUnsubmitted Done Inline ActionsGood catch Fabien: Good catch | |||||
if (preg_match($regex, $stdout, $matches)) { | if (preg_match($regex, $stdout, $matches)) { | ||||
return $matches['version']; | return $matches['version']; | ||||
} | } | ||||
if (preg_match($regex, $stderr, $matches)) { | if (preg_match($regex, $stderr, $matches)) { | ||||
return $matches['version']; | return $matches['version']; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
public function getInstallInstructions() { | public function getInstallInstructions() { | ||||
return pht('Make sure autopep8 is in directory specified by $PATH'); | return pht('Make sure autopep8 is in directory specified by $PATH'); | ||||
} | } | ||||
public function shouldExpectCommandErrors() { | public function shouldExpectCommandErrors() { | ||||
return false; | return false; | ||||
} | } | ||||
protected function getMandatoryFlags() { | protected function getMandatoryFlags() { | ||||
return array( | return array(); | ||||
); | |||||
} | } | ||||
protected function parseLinterOutput($path, $err, $stdout, $stderr) { | protected function parseLinterOutput($path, $err, $stdout, $stderr) { | ||||
$ok = ($err == 0); | $ok = ($err == 0); | ||||
if (!$ok) { | if (!$ok) { | ||||
return false; | return false; | ||||
} | } | ||||
$root = $this->getProjectRoot(); | $root = $this->getProjectRoot(); | ||||
$path = Filesystem::resolvePath($path, $root); | $path = Filesystem::resolvePath($path, $root); | ||||
$orig = file_get_contents($path); | $orig = file_get_contents($path); | ||||
if ($orig == $stdout) { | if ($orig == $stdout) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$message = id(new ArcanistLintMessage()) | $message = id(new ArcanistLintMessage()) | ||||
->setPath($path) | ->setPath($path) | ||||
->setLine(1) | ->setLine(1) | ||||
->setChar(1) | ->setChar(1) | ||||
->setGranularity(ArcanistLinter::GRANULARITY_FILE) | ->setGranularity(ArcanistLinter::GRANULARITY_FILE) | ||||
->setCode('CFMT') | ->setCode('CFMT') | ||||
->setSeverity(ArcanistLintSeverity::SEVERITY_AUTOFIX) | ->setSeverity(ArcanistLintSeverity::SEVERITY_AUTOFIX) | ||||
->setName('Code style violation') | ->setName('Code style violation') | ||||
->setDescription("'$path' has code style errors.") | ->setDescription("'$path' has code style errors.") | ||||
->setOriginalText($orig) | ->setOriginalText($orig) | ||||
->setReplacementText($stdout); | ->setReplacementText($stdout); | ||||
return array($message); | return array($message); | ||||
} | } | ||||
} | } |
This is quite apparently broken.