Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14230566
D17783.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D17783.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D17783: Improve `ArcanistLinterStandardTestCase`
Attached
Detach File
Event Timeline
Log In to Comment