From 4298b4ea8b769f1b7355ec40731a2d0cab74d5c5 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 9 May 2014 06:00:36 -0700 Subject: [PATCH] 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 --- .../ArcanistConfigurationDrivenLintEngine.php | 53 ++++++++----------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php index cb121a80..08e5aba2 100644 --- a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php +++ b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php @@ -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>', - '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); - } - - }