1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Remove debug key from .arclint file format.

Summary: Having a `debug` key in the `.arclint` file format doesn't seem right. Instead, it would be better to just use a `PhutilConsole` and the `writeLog` method so that "debug" messages are output when using `arc --trace`.

Test Plan: Ran `arc lint --trace` in a repository using `.arclint`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9021
This commit is contained in:
Joshua Spence 2014-05-09 06:00:36 -07:00 committed by epriestley
parent 1591b21e86
commit 4298b4ea8b

View file

@ -2,8 +2,6 @@
final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
private $debugMode;
public function buildLinters() {
$working_copy = $this->getWorkingCopy();
$config_path = $working_copy->getProjectPath('.arclint');
@ -28,11 +26,8 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
$config,
array(
'linters' => 'map<string, map<string, wild>>',
'debug' => 'optional bool',
));
$this->debugMode = idx($config, 'debug', false);
$built_linters = array();
$all_paths = $this->getPaths();
foreach ($config['linters'] as $name => $spec) {
@ -84,10 +79,11 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
$this->validateRegexps($include, $name, 'include');
$this->validateRegexps($exclude, $name, 'exclude');
$this->debugLog('Examining paths for linter "%s".', $name);
$console = PhutilConsole::getConsole();
$console->writeLog("Examining paths for linter \"%s\".\n", $name);
$paths = $this->matchPaths($all_paths, $include, $exclude);
$this->debugLog(
'Found %d matching paths for linter "%s".',
$console->writeLog(
"Found %d matching paths for linter \"%s\".\n",
count($paths),
$name);
@ -131,48 +127,53 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
}
private function matchPaths(array $paths, array $include, array $exclude) {
$debug = $this->debugMode;
$console = PhutilConsole::getConsole();
$match = array();
foreach ($paths as $path) {
$this->debugLog("Examining path '%s'...", $path);
$console->writeLog("Examining path '%s'...\n", $path);
$keep = false;
if (!$include) {
$keep = true;
$this->debugLog(
" Including path by default because there is no 'include' rule.");
$console->writeLog(
" Including path by default because there is no 'include' rule.\n");
} else {
$this->debugLog(' Testing "include" rules.');
$console->writeLog(" Testing \"include\" rules.\n");
foreach ($include as $rule) {
if (preg_match($rule, $path)) {
$keep = true;
$this->debugLog(' Path matches include rule: %s', $rule);
$console->writeLog(" Path matches include rule: %s\n", $rule);
break;
} else {
$this->debugLog(' Path does not match include rule: %s', $rule);
$console->writeLog(
" Path does not match include rule: %s\n",
$rule);
}
}
}
if (!$keep) {
$this->debugLog(' Path does not match any include rules, discarding.');
$console->writeLogLog(
" Path does not match any include rules, discarding.\n");
continue;
}
if ($exclude) {
$this->debugLog(' Testing "exclude" rules.');
$console->writeLog(" Testing \"exclude\" rules.\n");
foreach ($exclude as $rule) {
if (preg_match($rule, $path)) {
$this->debugLog(' Path matches "exclude" rule: %s', $rule);
$console->writeLog(" Path matches \"exclude\" rule: %s\n", $rule);
continue 2;
} else {
$this->debugLog(' Path does not match "exclude" rule: %s', $rule);
$console->writeLog(
" Path does not match \"exclude\" rule: %s\n",
$rule);
}
}
}
$this->debugLog(' Path matches.');
$console->writeLog(" Path matches.\n");
$match[] = $path;
}
@ -194,16 +195,4 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
}
}
private function debugLog($pattern /* , $arg, ... */) {
if (!$this->debugMode) {
return;
}
$console = PhutilConsole::getConsole();
$argv = func_get_args();
$argv[0] .= "\n";
call_user_func_array(array($console, 'writeErr'), $argv);
}
}