diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2015-07-20 09:39:53 +0300 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2015-07-20 09:39:53 +0300 |
commit | 0dd1a785fe56177b13885e94cf49031493195f8a (patch) | |
tree | b9f40bde5ba4bdbf8bd3484f01745e3052778a10 /core/command | |
parent | 83a13c0635fa5c8ca25a23d3996b62c5f2d82a2b (diff) | |
parent | 3566dcf246d122bbc4010aeb42c5b2d9259f8ea5 (diff) |
Merge pull request #16935 from owncloud/allow-app-check-code-for-deprecated-classes
Allow app check code for deprecated classes
Diffstat (limited to 'core/command')
-rw-r--r-- | core/command/app/checkcode.php | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/core/command/app/checkcode.php b/core/command/app/checkcode.php index ecec51e5768..a4e7322460f 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 @@ -23,12 +24,21 @@ namespace OC\Core\Command\App; +use OC\App\CodeChecker\CodeChecker; +use OC\App\CodeChecker\EmptyCheck; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +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') @@ -37,12 +47,30 @@ class CheckCode extends Command { 'app-id', InputArgument::REQUIRED, 'check the specified app' + ) + ->addOption( + 'checker', + 'c', + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'enable the specified checker(s)', + [ 'private', 'deprecation', 'strong-comparison' ] ); } protected function execute(InputInterface $input, OutputInterface $output) { $appId = $input->getArgument('app-id'); - $codeChecker = new \OC\App\CodeChecker(); + + $checkList = new EmptyCheck(); + 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) { if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->writeln("<info>Analysing {$params}</info>"); @@ -72,9 +100,10 @@ class CheckCode extends Command { $errors = $codeChecker->analyse($appId); if (empty($errors)) { $output->writeln('<info>App is compliant - awesome job!</info>'); + return 0; } else { $output->writeln('<error>App is not compliant</error>'); - return 1; + return 101; } } } |