diff --git a/src/lint/linter/ArcanistLicenseLinter.php b/src/lint/linter/ArcanistLicenseLinter.php index 024c88fa..03401f63 100644 --- a/src/lint/linter/ArcanistLicenseLinter.php +++ b/src/lint/linter/ArcanistLicenseLinter.php @@ -35,8 +35,11 @@ abstract class ArcanistLicenseLinter extends ArcanistLinter { abstract protected function getLicensePatterns(); public function lintPath($path) { - $working_copy = $this->getEngine()->getWorkingCopy(); - $copyright_holder = $working_copy->getConfig('copyright_holder'); + $copyright_holder = $this->getConfig('copyright_holder'); + if ($copyright_holder === null) { + $working_copy = $this->getEngine()->getWorkingCopy(); + $copyright_holder = $working_copy->getConfig('copyright_holder'); + } if (!$copyright_holder) { return; diff --git a/src/lint/linter/ArcanistLinter.php b/src/lint/linter/ArcanistLinter.php index cf3da352..2b5dd53b 100644 --- a/src/lint/linter/ArcanistLinter.php +++ b/src/lint/linter/ArcanistLinter.php @@ -17,12 +17,22 @@ abstract class ArcanistLinter { protected $stopAllLinters = false; private $customSeverityMap = array(); + private $config = array(); public function setCustomSeverityMap(array $map) { $this->customSeverityMap = $map; 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; } diff --git a/src/lint/linter/__tests__/ArcanistLinterTestCase.php b/src/lint/linter/__tests__/ArcanistLinterTestCase.php index 364e65f8..2873fb50 100644 --- a/src/lint/linter/__tests__/ArcanistLinterTestCase.php +++ b/src/lint/linter/__tests__/ArcanistLinterTestCase.php @@ -68,6 +68,7 @@ abstract class ArcanistLinterTestCase extends ArcanistTestCase { $linter->addPath($path); $linter->addData($path, $data); + $linter->setConfig(idx($config, 'config', array())); $engine->addLinter($linter); $engine->addFileData($path, $data); diff --git a/src/lint/linter/__tests__/apachelicense/c-basic.lint-test b/src/lint/linter/__tests__/apachelicense/c-basic.lint-test index 1c49d4ae..109eeb62 100644 --- a/src/lint/linter/__tests__/apachelicense/c-basic.lint-test +++ b/src/lint/linter/__tests__/apachelicense/c-basic.lint-test @@ -27,3 +27,5 @@ error:1:1 int main(int argv, char **argv) { return 0; } +~~~~~~~~~~ +{"config": {"copyright_holder": "Facebook, Inc."}} diff --git a/src/lint/linter/__tests__/apachelicense/greedy.lint-test b/src/lint/linter/__tests__/apachelicense/greedy.lint-test index e111c0bd..33a8a6a7 100644 --- a/src/lint/linter/__tests__/apachelicense/greedy.lint-test +++ b/src/lint/linter/__tests__/apachelicense/greedy.lint-test @@ -35,3 +35,5 @@ function Copyright(Copyright $copyright) { } /* More Comments */ +~~~~~~~~~~ +{"config": {"copyright_holder": "Facebook, Inc."}} diff --git a/src/lint/linter/__tests__/apachelicense/php-basic.lint-test b/src/lint/linter/__tests__/apachelicense/php-basic.lint-test index 1b43f13c..72d75e3b 100644 --- a/src/lint/linter/__tests__/apachelicense/php-basic.lint-test +++ b/src/lint/linter/__tests__/apachelicense/php-basic.lint-test @@ -23,3 +23,5 @@ error:1:1 */ do_stuff(); +~~~~~~~~~~ +{"config": {"copyright_holder": "Facebook, Inc."}} diff --git a/src/lint/linter/__tests__/apachelicense/php-script.lint-test b/src/lint/linter/__tests__/apachelicense/php-script.lint-test index 36254ec4..9cce53e0 100644 --- a/src/lint/linter/__tests__/apachelicense/php-script.lint-test +++ b/src/lint/linter/__tests__/apachelicense/php-script.lint-test @@ -25,3 +25,5 @@ error:1:1 */ do_stuff(); +~~~~~~~~~~ +{"config": {"copyright_holder": "Facebook, Inc."}} diff --git a/src/lint/linter/__tests__/apachelicense/php-update-mess.lint-test b/src/lint/linter/__tests__/apachelicense/php-update-mess.lint-test index a4d306bf..286f0dc9 100644 --- a/src/lint/linter/__tests__/apachelicense/php-update-mess.lint-test +++ b/src/lint/linter/__tests__/apachelicense/php-update-mess.lint-test @@ -27,3 +27,5 @@ error:1:1 */ do_stuff(); +~~~~~~~~~~ +{"config": {"copyright_holder": "Facebook, Inc."}} diff --git a/src/lint/linter/__tests__/apachelicense/php-update-multi.lint-test b/src/lint/linter/__tests__/apachelicense/php-update-multi.lint-test index 4fb90031..6a54847e 100644 --- a/src/lint/linter/__tests__/apachelicense/php-update-multi.lint-test +++ b/src/lint/linter/__tests__/apachelicense/php-update-multi.lint-test @@ -25,3 +25,5 @@ error:1:1 */ do_stuff(); +~~~~~~~~~~ +{"config": {"copyright_holder": "Facebook, Inc."}} diff --git a/src/lint/linter/__tests__/apachelicense/php-update-single.lint-test b/src/lint/linter/__tests__/apachelicense/php-update-single.lint-test index 4fb90031..6a54847e 100644 --- a/src/lint/linter/__tests__/apachelicense/php-update-single.lint-test +++ b/src/lint/linter/__tests__/apachelicense/php-update-single.lint-test @@ -25,3 +25,5 @@ error:1:1 */ do_stuff(); +~~~~~~~~~~ +{"config": {"copyright_holder": "Facebook, Inc."}}