Changeset View
Changeset View
Standalone View
Standalone View
arcanist/linter/ClangFormatLinter.php
Show All 34 Lines | final class ClangFormatLinter extends ArcanistExternalLinter { | ||||
} | } | ||||
public function getVersion() { | public function getVersion() { | ||||
list($stdout) = execx('%C -version', $this->getExecutableCommand()); | list($stdout) = execx('%C -version', $this->getExecutableCommand()); | ||||
$matches = array(); | $matches = array(); | ||||
$regex = '/^clang-format version (?P<version>\d+\.\d+)\./'; | $regex = '/^clang-format version (?P<version>\d+\.\d+)\./'; | ||||
if (preg_match($regex, $stdout, $matches)) { | if (preg_match($regex, $stdout, $matches)) { | ||||
return $matches['version']; | $version = $matches['version']; | ||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } | ||||
/* | |||||
* FIXME: This is a hack to only allow for clang-format version 7.x. | |||||
* The .arclint `version` field only allow to filter versions using `=`, | |||||
* `>`, `<`, `>=` or `<=`. There is no facility to define that the required | |||||
* version should be >= 7.0 and < 8.0. | |||||
*/ | |||||
if ($version[0] != '7') { | |||||
throw new Exception(pht('Linter %s requires clang-format version 7.x. '. | |||||
'You have version %s.', | |||||
ClangFormatLinter::class, | |||||
$version)); | |||||
} | |||||
return $version; | |||||
} | } | ||||
public function getInstallInstructions() { | public function getInstallInstructions() { | ||||
return pht('Make sure clang-format is in directory specified by $PATH'); | return pht('Make sure clang-format is in directory specified by $PATH'); | ||||
} | } | ||||
public function shouldExpectCommandErrors() { | public function shouldExpectCommandErrors() { | ||||
return false; | return false; | ||||
Show All 35 Lines |