diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -292,6 +292,7 @@ 'ArcanistPhrequentWorkflow' => 'workflow/ArcanistPhrequentWorkflow.php', 'ArcanistPhutilLibraryLinter' => 'lint/linter/ArcanistPhutilLibraryLinter.php', 'ArcanistPhutilXHPASTLinterStandard' => 'lint/linter/standards/phutil/ArcanistPhutilXHPASTLinterStandard.php', + 'ArcanistPhutilXHPASTLinterStandardTestCase' => 'lint/linter/standards/phutil/__tests__/ArcanistPhutilXHPASTLinterStandardTestCase.php', 'ArcanistPlusOperatorOnStringsXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistPlusOperatorOnStringsXHPASTLinterRule.php', 'ArcanistPlusOperatorOnStringsXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistPlusOperatorOnStringsXHPASTLinterRuleTestCase.php', 'ArcanistPregQuoteMisuseXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistPregQuoteMisuseXHPASTLinterRule.php', @@ -642,7 +643,7 @@ 'ArcanistLintWorkflow' => 'ArcanistWorkflow', 'ArcanistLinter' => 'Phobject', 'ArcanistLinterStandard' => 'Phobject', - 'ArcanistLinterStandardTestCase' => 'PhutilTestCase', + 'ArcanistLinterStandardTestCase' => 'ArcanistLinterTestCase', 'ArcanistLinterTestCase' => 'PhutilTestCase', 'ArcanistLintersWorkflow' => 'ArcanistWorkflow', 'ArcanistListAssignmentXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', @@ -706,6 +707,7 @@ 'ArcanistPhrequentWorkflow' => 'ArcanistWorkflow', 'ArcanistPhutilLibraryLinter' => 'ArcanistLinter', 'ArcanistPhutilXHPASTLinterStandard' => 'ArcanistLinterStandard', + 'ArcanistPhutilXHPASTLinterStandardTestCase' => 'ArcanistLinterStandardTestCase', 'ArcanistPlusOperatorOnStringsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistPlusOperatorOnStringsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistPregQuoteMisuseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', diff --git a/src/lint/linter/ArcanistLinter.php b/src/lint/linter/ArcanistLinter.php --- a/src/lint/linter/ArcanistLinter.php +++ b/src/lint/linter/ArcanistLinter.php @@ -578,11 +578,7 @@ $standard = ArcanistLinterStandard::getStandard( $standard_name, $this); - - foreach ($standard->getLinterConfiguration() as $k => $v) { - $this->setLinterConfigurationValue($k, $v); - } - $this->addCustomSeverityMap($standard->getLinterSeverityMap()); + $this->applyStandard($standard); } return; @@ -593,6 +589,13 @@ throw new Exception(pht('Incomplete implementation: %s!', $key)); } + public function applyStandard(ArcanistLinterStandard $standard) { + foreach ($standard->getLinterConfiguration() as $k => $v) { + $this->setLinterConfigurationValue($k, $v); + } + $this->addCustomSeverityMap($standard->getLinterSeverityMap()); + } + protected function canCustomizeLintSeverities() { return true; } diff --git a/src/lint/linter/standards/__tests__/ArcanistLinterStandardTestCase.php b/src/lint/linter/standards/__tests__/ArcanistLinterStandardTestCase.php --- a/src/lint/linter/standards/__tests__/ArcanistLinterStandardTestCase.php +++ b/src/lint/linter/standards/__tests__/ArcanistLinterStandardTestCase.php @@ -1,10 +1,22 @@ assertTrue(true); } + abstract protected function getBaseLinter(); + + abstract protected function getStandard(); + + protected function getLinter() { + $linter = $this->getBaseLinter(); + $linter->applyStandard($this->getStandard()); + + return $linter; + } + } diff --git a/src/lint/linter/standards/phutil/__tests__/ArcanistPhutilXHPASTLinterStandardTestCase.php b/src/lint/linter/standards/phutil/__tests__/ArcanistPhutilXHPASTLinterStandardTestCase.php new file mode 100644 --- /dev/null +++ b/src/lint/linter/standards/phutil/__tests__/ArcanistPhutilXHPASTLinterStandardTestCase.php @@ -0,0 +1,18 @@ +executeTestsInDirectory(dirname(__FILE__).'/xhpast/'); + } + +} diff --git a/src/lint/linter/standards/phutil/__tests__/xhpast/blacklisted-function.lint-test b/src/lint/linter/standards/phutil/__tests__/xhpast/blacklisted-function.lint-test new file mode 100644 --- /dev/null +++ b/src/lint/linter/standards/phutil/__tests__/xhpast/blacklisted-function.lint-test @@ -0,0 +1,5 @@ +