Page MenuHomePhabricator

D9054.diff
No OneTemporary

D9054.diff

diff --git a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php
--- a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php
+++ b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php
@@ -25,9 +25,13 @@
PhutilTypeSpec::checkMap(
$config,
array(
+ 'exclude' => 'optional string | list<string>',
'linters' => 'map<string, map<string, wild>>',
));
+ $global_exclude = (array)idx($config, 'exclude', array());
+ $this->validateRegexps($global_exclude);
+
$built_linters = array();
$all_paths = $this->getPaths();
foreach ($config['linters'] as $name => $spec) {
@@ -81,7 +85,11 @@
$console = PhutilConsole::getConsole();
$console->writeLog("Examining paths for linter \"%s\".\n", $name);
- $paths = $this->matchPaths($all_paths, $include, $exclude);
+ $paths = $this->matchPaths(
+ $all_paths,
+ $include,
+ $exclude,
+ $global_exclude);
$console->writeLog(
"Found %d matching paths for linter \"%s\".\n",
count($paths),
@@ -126,7 +134,12 @@
return $map;
}
- private function matchPaths(array $paths, array $include, array $exclude) {
+ private function matchPaths(
+ array $paths,
+ array $include,
+ array $exclude,
+ array $global_exclude) {
+
$console = PhutilConsole::getConsole();
$match = array();
@@ -173,6 +186,22 @@
}
}
+ if ($global_exclude) {
+ $console->writeLog(" Testing global \"exclude\" rules.\n");
+ foreach ($global_exclude as $rule) {
+ if (preg_match($rule, $path)) {
+ $console->writeLog(
+ " Path matches global \"exclude\" rule: %s\n",
+ $rule);
+ continue 2;
+ } else {
+ $console->writeLog(
+ " Path does not match global \"exclude\" rule: %s\n",
+ $rule);
+ }
+ }
+ }
+
$console->writeLog(" Path matches.\n");
$match[] = $path;
}
@@ -180,17 +209,28 @@
return $match;
}
- private function validateRegexps(array $regexps, $linter, $config) {
+ private function validateRegexps(
+ array $regexps,
+ $linter = null,
+ $config = null) {
+
foreach ($regexps as $regexp) {
$ok = @preg_match($regexp, '');
if ($ok === false) {
- throw new Exception(
- pht(
- 'Regular expression "%s" (in "%s" configuration for linter "%s") '.
- 'is not a valid regular expression.',
- $regexp,
- $config,
- $linter));
+ if ($linter) {
+ throw new Exception(
+ pht(
+ 'Regular expression "%s" (in "%s" configuration for linter '.
+ '"%s") is not a valid regular expression.',
+ $regexp,
+ $config,
+ $linter));
+ } else {
+ throw new Exception(
+ pht(
+ 'Regular expression "%s" is not a valid regular expression.',
+ $regexp));
+ }
}
}
}

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 24, 4:33 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713795
Default Alt Text
D9054.diff (3 KB)

Event Timeline