diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-05-06 11:21:23 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-05-06 11:21:23 +0200 |
commit | 9a159372cb31b9fe4616e5403773eb078c5ad828 (patch) | |
tree | 853cd513f9d59fc443d510cc9aca579198a743bd | |
parent | 874d35b27af68597c56d7c6147f998ca17aba2f5 (diff) | |
parent | 56b1c93a79ccb1e5bf34f5b5b27744795d5a2457 (diff) | |
download | nextcloud-server-9a159372cb31b9fe4616e5403773eb078c5ad828.tar.gz nextcloud-server-9a159372cb31b9fe4616e5403773eb078c5ad828.zip |
Merge pull request #16067 from owncloud/verbosity-in-app-code-check
Add verbosity option to app:check-code
-rw-r--r-- | core/command/app/checkcode.php | 23 | ||||
-rw-r--r-- | lib/private/app/codechecker.php | 2 |
2 files changed, 18 insertions, 7 deletions
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("<info>Analysing {$params}</info>"); + if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $output->writeln("<info>Analysing {$params}</info>"); + } }); - $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("<info>Analysing {$filename}</info>"); + } + + // 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(" <error>line $line: {$p['disallowedToken']} - {$p['reason']}</error>"); } diff --git a/lib/private/app/codechecker.php b/lib/private/app/codechecker.php index 918d04a0bd6..8c2f3405fb9 100644 --- a/lib/private/app/codechecker.php +++ b/lib/private/app/codechecker.php @@ -119,7 +119,7 @@ class CodeChecker extends BasicEmitter { /** @var SplFileInfo $file */ $this->emit('CodeChecker', 'analyseFileBegin', [$file->getPathname()]); $fileErrors = $this->analyseFile($file); - $this->emit('CodeChecker', 'analyseFileFinished', [$fileErrors]); + $this->emit('CodeChecker', 'analyseFileFinished', [$file->getPathname(), $fileErrors]); $errors = array_merge($fileErrors, $errors); } |