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
$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())
const LINT_PARSE_ERROR = 6;
const LINT_SYNTAX_ERROR = 7;
+ private $strictMath = false;
+ private $strictUnits = false;
+
public function getInfoName() {
return pht('Less');
}
);
}
+ 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'),
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) {
private $customSeverityMap = array();
private $customSeverityRules = array();
- private $config = array();
/* -( Human Readable Information )---------------------------------------- */
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;
}
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!',
);
}
+ 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();
$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');
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) {
$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);
warning:75:3
~~~~~~~~~~
~~~~~~~~~~
-{"config":{"switchhook":"ArcanistXHPASTLintTestSwitchHook"}}
+{"config":{"xhpast.switchhook":"ArcanistXHPASTLintTestSwitchHook"}}