mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-22 21:40:54 +01:00
Remove the getConfig
and setConfig
method.
Summary: It seems that there is a lot of overlap between `getConfig` / `setConfig` and `getLinterConfigurationOptions` / `setLinterConfigurationValue` respectively. Test Plan: `arc lint` and `arc unit`. Reviewers: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9067
This commit is contained in:
parent
1b820dbb14
commit
be803ce577
6 changed files with 59 additions and 20 deletions
|
@ -33,7 +33,7 @@ final class ComprehensiveLintEngine extends ArcanistLintEngine {
|
|||
$py_paths = preg_grep('/\.py$/', $paths);
|
||||
$linters[] = id(new ArcanistPyFlakesLinter())->setPaths($py_paths);
|
||||
$linters[] = id(new ArcanistPEP8Linter())
|
||||
->setConfig(array('flags' => array($this->getPEP8WithTextOptions())))
|
||||
->setFlags(array($this->getPEP8WithTextOptions()))
|
||||
->setPaths($py_paths);
|
||||
|
||||
$linters[] = id(new ArcanistRubyLinter())
|
||||
|
|
|
@ -16,6 +16,9 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter {
|
|||
const LINT_PARSE_ERROR = 6;
|
||||
const LINT_SYNTAX_ERROR = 7;
|
||||
|
||||
private $strictMath = false;
|
||||
private $strictUnits = false;
|
||||
|
||||
public function getInfoName() {
|
||||
return pht('Less');
|
||||
}
|
||||
|
@ -54,6 +57,19 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter {
|
|||
);
|
||||
}
|
||||
|
||||
public function setLinterConfigurationValue($key, $value) {
|
||||
switch ($key) {
|
||||
case 'lessc.strict-math':
|
||||
$this->strictMath = $value;
|
||||
return;
|
||||
case 'lessc.strict-units':
|
||||
$this->strictUnits = $value;
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::setLinterConfigurationValue($key, $value);
|
||||
}
|
||||
|
||||
public function getLintNameMap() {
|
||||
return array(
|
||||
self::LINT_RUNTIME_ERROR => pht('Runtime Error'),
|
||||
|
@ -104,10 +120,8 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter {
|
|||
return array(
|
||||
'--lint',
|
||||
'--no-color',
|
||||
'--strict-math='.
|
||||
($this->getConfig('lessc.strict-math') ? 'on' : 'off'),
|
||||
'--strict-units='.
|
||||
($this->getConfig('lessc.strict-units') ? 'on' : 'off'));
|
||||
'--strict-math='.($this->strictMath ? 'on' : 'off'),
|
||||
'--strict-units='.($this->strictUnits ? 'on' : 'off'));
|
||||
}
|
||||
|
||||
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
||||
|
|
|
@ -24,7 +24,6 @@ abstract class ArcanistLinter {
|
|||
|
||||
private $customSeverityMap = array();
|
||||
private $customSeverityRules = array();
|
||||
private $config = array();
|
||||
|
||||
|
||||
/* -( Human Readable Information )---------------------------------------- */
|
||||
|
@ -89,15 +88,6 @@ abstract class ArcanistLinter {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setConfig(array $config) {
|
||||
$this->config = $config;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getConfig($key, $default = null) {
|
||||
return idx($this->config, $key, $default);
|
||||
}
|
||||
|
||||
public function getActivePath() {
|
||||
return $this->activePath;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
|||
const LINT_REUSED_ITERATOR_REFERENCE = 39;
|
||||
const LINT_KEYWORD_CASING = 40;
|
||||
|
||||
private $naminghook;
|
||||
private $switchhook;
|
||||
|
||||
public function getLintNameMap() {
|
||||
return array(
|
||||
self::LINT_PHP_SYNTAX_ERROR => 'PHP Syntax Error!',
|
||||
|
@ -129,6 +132,32 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
|||
);
|
||||
}
|
||||
|
||||
public function getLinterConfigurationOptions() {
|
||||
return parent::getLinterConfigurationOptions() + array(
|
||||
'xhpast.naminghook' => array(
|
||||
'type' => 'optional ArcanistXHPASTLintNamingHook',
|
||||
'help' => pht(''),
|
||||
),
|
||||
'xhpast.switchhook' => array(
|
||||
'type' => 'optional ArcanistXHPASTLintSwitchHook',
|
||||
'help' => pht(''),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function setLinterConfigurationValue($key, $value) {
|
||||
switch ($key) {
|
||||
case 'xhpast.naminghook':
|
||||
$this->naminghook = $value;
|
||||
return;
|
||||
case 'xhpast.switchhook':
|
||||
$this->switchhook = $value;
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::setLinterConfigurationValue($key, $value);
|
||||
}
|
||||
|
||||
public function getCacheVersion() {
|
||||
$version = '4';
|
||||
$path = xhpast_get_binary_path();
|
||||
|
@ -464,8 +493,9 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
|||
$hook_obj = null;
|
||||
$working_copy = $this->getEngine()->getWorkingCopy();
|
||||
if ($working_copy) {
|
||||
$hook_class = $working_copy->getProjectConfig('lint.xhpast.switchhook');
|
||||
$hook_class = $this->getConfig('switchhook', $hook_class);
|
||||
$hook_class = $this->switchhook
|
||||
? $this->switchhook
|
||||
: $this->getDeprecatedConfiguration('lint.xhpast.switchhook');
|
||||
if ($hook_class) {
|
||||
$hook_obj = newv($hook_class, array());
|
||||
assert_instances_of(array($hook_obj), 'ArcanistXHPASTLintSwitchHook');
|
||||
|
@ -1673,7 +1703,9 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
|||
if ($working_copy) {
|
||||
// If a naming hook is configured, give it a chance to override the
|
||||
// default results for all the symbol names.
|
||||
$hook_class = $working_copy->getProjectConfig('lint.xhpast.naminghook');
|
||||
$hook_class = $this->naminghook
|
||||
? $this->naminghook
|
||||
: $working_copy->getProjectConfig('lint.xhpast.naminghook');
|
||||
if ($hook_class) {
|
||||
$hook_obj = newv($hook_class, array());
|
||||
foreach ($names as $k => $name_attrs) {
|
||||
|
|
|
@ -96,7 +96,10 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
|||
$path_name = idx($config, 'path', $path);
|
||||
$linter->addPath($path_name);
|
||||
$linter->addData($path_name, $data);
|
||||
$linter->setConfig(idx($config, 'config', array()));
|
||||
$config = idx($config, 'config', array());
|
||||
foreach ($config as $key => $value) {
|
||||
$linter->setLinterConfigurationValue($key, $value);
|
||||
}
|
||||
|
||||
$engine->addLinter($linter);
|
||||
$engine->addFileData($path_name, $data);
|
||||
|
|
|
@ -94,4 +94,4 @@ warning:71:3
|
|||
warning:75:3
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
{"config":{"switchhook":"ArcanistXHPASTLintTestSwitchHook"}}
|
||||
{"config":{"xhpast.switchhook":"ArcanistXHPASTLintTestSwitchHook"}}
|
||||
|
|
Loading…
Reference in a new issue