Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13974806
D9054.id21498.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D9054.id21498.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 19, 7:27 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713795
Default Alt Text
D9054.id21498.diff (3 KB)
Attached To
Mode
D9054: Allow global excludes to be specified in `.arclint`.
Attached
Detach File
Event Timeline
Log In to Comment