From 17a26dfcc1f4d02b54e6cbb500f41bbe25609f1e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 7 Feb 2018 16:03:21 +0100 Subject: Validate the info.xml against the appstore schema file Signed-off-by: Joas Schilling --- core/Command/App/CheckCode.php | 54 ++++-------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) (limited to 'core/Command') diff --git a/core/Command/App/CheckCode.php b/core/Command/App/CheckCode.php index 82a137e58e1..a129bcf1e10 100644 --- a/core/Command/App/CheckCode.php +++ b/core/Command/App/CheckCode.php @@ -44,20 +44,12 @@ use OC\App\CodeChecker\PrivateCheck; class CheckCode extends Command implements CompletionAwareInterface { - /** @var InfoParser */ - private $infoParser; - protected $checkers = [ 'private' => PrivateCheck::class, 'deprecation' => DeprecationCheck::class, 'strong-comparison' => StrongComparisonCheck::class, ]; - public function __construct(InfoParser $infoParser) { - parent::__construct(); - $this->infoParser = $infoParser; - } - protected function configure() { $this ->setName('app:check-code') @@ -134,50 +126,12 @@ class CheckCode extends Command implements CompletionAwareInterface { } if(!$input->getOption('skip-validate-info')) { - $infoChecker = new InfoChecker($this->infoParser); - - $infoChecker->listen('InfoChecker', 'mandatoryFieldMissing', function($key) use ($output) { - $output->writeln("Mandatory field missing: $key"); - }); - - $infoChecker->listen('InfoChecker', 'deprecatedFieldFound', function($key, $value) use ($output) { - if($value === [] || is_null($value) || $value === '') { - $output->writeln("Deprecated field available: $key"); - } else { - $output->writeln("Deprecated field available: $key => $value"); - } - }); - - $infoChecker->listen('InfoChecker', 'missingRequirement', function($minMax) use ($output) { - $output->writeln("Nextcloud $minMax version requirement missing"); - }); - - $infoChecker->listen('InfoChecker', 'differentVersions', function($versionFile, $infoXML) use ($output) { - $output->writeln("Different versions provided (appinfo/version: $versionFile - appinfo/info.xml: $infoXML)"); + // Can not inject because of circular dependency + $infoChecker = new InfoChecker(\OC::$server->getAppManager()); + $infoChecker->listen('InfoChecker', 'parseError', function($error) use ($output) { + $output->writeln("Invalid appinfo.xml file found: $error"); }); - $infoChecker->listen('InfoChecker', 'sameVersions', function($path) use ($output) { - $output->writeln("Version file isn't needed anymore and can be safely removed ($path)"); - }); - - $infoChecker->listen('InfoChecker', 'migrateVersion', function($version) use ($output) { - $output->writeln("Migrate the app version to appinfo/info.xml (add $version to appinfo/info.xml and remove appinfo/version)"); - }); - - if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { - $infoChecker->listen('InfoChecker', 'mandatoryFieldFound', function($key, $value) use ($output) { - $output->writeln("Mandatory field available: $key => $value"); - }); - - $infoChecker->listen('InfoChecker', 'optionalFieldFound', function($key, $value) use ($output) { - $output->writeln("Optional field available: $key => $value"); - }); - - $infoChecker->listen('InfoChecker', 'unusedFieldFound', function($key, $value) use ($output) { - $output->writeln("Unused field available: $key => $value"); - }); - } - $infoErrors = $infoChecker->analyse($appId); $errors = array_merge($errors, $infoErrors); -- cgit v1.2.3