diff options
author | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2015-07-10 22:17:55 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-07-17 12:34:56 +0200 |
commit | 0de5c35dbad2cd2023cff08c0b142aedb16c4ea9 (patch) | |
tree | c4271b8690111421cbee8016d0e105d345538641 /core/command | |
parent | a0c6f2e5e071a287717e58f32c5b3cf6e219f321 (diff) | |
download | nextcloud-server-0de5c35dbad2cd2023cff08c0b142aedb16c4ea9.tar.gz nextcloud-server-0de5c35dbad2cd2023cff08c0b142aedb16c4ea9.zip |
Allow specifying the checkers used in app:check-code
By default, all are enabled, but specific ones can be selected through command
line options.
Diffstat (limited to 'core/command')
-rw-r--r-- | core/command/app/checkcode.php | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/core/command/app/checkcode.php b/core/command/app/checkcode.php index 3f4fb95868c..79c34d6fb48 100644 --- a/core/command/app/checkcode.php +++ b/core/command/app/checkcode.php @@ -3,6 +3,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 @@ -24,10 +25,7 @@ namespace OC\Core\Command\App; use OC\App\CodeChecker\CodeChecker; -use OC\App\CodeChecker\DeprecationCheck; use OC\App\CodeChecker\EmptyCheck; -use OC\App\CodeChecker\PrivateCheck; -use OC\App\CodeChecker\StrongComparisonCheck; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -35,6 +33,12 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class CheckCode extends Command { + protected $checkers = [ + 'private' => '\OC\App\CodeChecker\PrivateCheck', + 'deprecation' => '\OC\App\CodeChecker\DeprecationCheck', + 'strong-comparison' => '\OC\App\CodeChecker\StrongComparisonCheck', + ]; + protected function configure() { $this ->setName('app:check-code') @@ -45,22 +49,26 @@ class CheckCode extends Command { 'check the specified app' ) ->addOption( - 'deprecated', - 'd', - InputOption::VALUE_NONE, - 'check the specified app' + 'checker', + 'c', + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'enable the specified checker', + [ 'private', 'deprecation', 'strong-comparison' ] ); } protected function execute(InputInterface $input, OutputInterface $output) { $appId = $input->getArgument('app-id'); + $checkList = new EmptyCheck(); - if ($input->getOption('deprecated')) { - $checkList = new DeprecationCheck($checkList); - $checkList = new StrongComparisonCheck($checkList); - } else { - $checkList = new PrivateCheck($checkList); + foreach ($input->getOption('checker') as $checker) { + if (!isset($this->checkers[$checker])) { + throw new \InvalidArgumentException('Invalid checker: '.$checker); + } + $checkerClass = $this->checkers[$checker]; + $checkList = new $checkerClass($checkList); } + $codeChecker = new CodeChecker($checkList); $codeChecker->listen('CodeChecker', 'analyseFileBegin', function($params) use ($output) { @@ -92,9 +100,7 @@ class CheckCode extends Command { $errors = $codeChecker->analyse($appId); if (empty($errors)) { $output->writeln('<info>App is compliant - awesome job!</info>'); - } elseif ($input->getOption('deprecated')) { - $output->writeln('<comment>App uses deprecated functionality</comment>'); - return 102; + return 0; } else { $output->writeln('<error>App is not compliant</error>'); return 101; |