Page MenuHomePhabricator

D17783.diff
No OneTemporary

D17783.diff

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 @@
<?php
-final class ArcanistLinterStandardTestCase extends PhutilTestCase {
+abstract class ArcanistLinterStandardTestCase
+ extends ArcanistLinterTestCase {
public function testLoadAllStandards() {
ArcanistLinterStandard::loadAllStandards();
$this->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 @@
+<?php
+
+final class ArcanistPhutilXHPASTLinterStandardTestCase
+ extends ArcanistLinterStandardTestCase {
+
+ protected function getBaseLinter() {
+ return new ArcanistXHPASTLinter();
+ }
+
+ protected function getStandard() {
+ return new ArcanistPhutilXHPASTLinterStandard();
+ }
+
+ public function testLinter() {
+ $this->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 @@
+<?php
+
+eval("echo 'hello'");
+~~~~~~~~~~
+error:3:1

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 12, 9:09 PM (21 h, 30 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6872233
Default Alt Text
D17783.diff (4 KB)

Event Timeline