[Pkg-owncloud-commits] [owncloud] 75/122: Add verbosity option to app:check-code

David Prévot taffit at moszumanska.debian.org
Sat May 9 00:00:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 56b1c93a79ccb1e5bf34f5b5b27744795d5a2457
Author: Morris Jobke <hey at morrisjobke.de>
Date:   Tue May 5 13:57:23 2015 +0200

    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 +++++++++++++++++------
 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 18d8f0d..6d10714 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 75db9ab..f0a328d 100644
--- a/lib/private/app/codechecker.php
+++ b/lib/private/app/codechecker.php
@@ -118,7 +118,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);
 		}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list