From 56b1c93a79ccb1e5bf34f5b5b27744795d5a2457 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 5 May 2015 13:57:23 +0200 Subject: Add verbosity option to app:check-code * by default only lists files with errors * option -v lists all files even if there are no errors --- core/command/app/checkcode.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/command/app/checkcode.php b/core/command/app/checkcode.php index 18d8f0d5311..6d10714d410 100644 --- a/core/command/app/checkcode.php +++ b/core/command/app/checkcode.php @@ -43,16 +43,27 @@ class CheckCode extends Command { $appId = $input->getArgument('app-id'); $codeChecker = new \OC\App\CodeChecker(); $codeChecker->listen('CodeChecker', 'analyseFileBegin', function($params) use ($output) { - $output->writeln("Analysing {$params}"); + if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $output->writeln("Analysing {$params}"); + } }); - $codeChecker->listen('CodeChecker', 'analyseFileFinished', function($params) use ($output) { - $count = count($params); - $output->writeln(" {$count} errors"); - usort($params, function($a, $b) { + $codeChecker->listen('CodeChecker', 'analyseFileFinished', function($filename, $errors) use ($output) { + $count = count($errors); + + // show filename if the verbosity is low, but there are errors in a file + if($count > 0 && OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) { + $output->writeln("Analysing {$filename}"); + } + + // show error count if there are errros present or the verbosity is high + if($count > 0 || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $output->writeln(" {$count} errors"); + } + usort($errors, function($a, $b) { return $a['line'] >$b['line']; }); - foreach($params as $p) { + foreach($errors as $p) { $line = sprintf("%' 4d", $p['line']); $output->writeln(" line $line: {$p['disallowedToken']} - {$p['reason']}"); } -- cgit v1.2.3