lib/private/Server.php
Method __construct
has 761 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __construct($webRoot, \OC\Config $config) {
parent::__construct();
$this->webRoot = $webRoot;
$this->registerService('SettingsManager', function (Server $c) {
File Server.php
has 1168 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Bernhard Posselt <dev@bernhard-posselt.com>
Server
has 87 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Server extends ServerContainer implements IServerContainer, IServiceLoader {
use EventEmitterTrait;
/** @var string */
private $webRoot;
Function load
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
public function load(array $xmlPath, IUser $user = null) {
$appManager = $this->getAppManager();
$allApps = $appManager->getEnabledAppsForUser($user);
foreach ($allApps as $appId) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
Open
return new TagManager($tagMapper, $c->getUserSession());
Avoid too many return
statements within this method. Open
Open
return new Authentication\Token\DefaultTokenMapper($dbConnection);
Avoid too many return
statements within this method. Open
Open
return true;
Avoid too many return
statements within this method. Open
Open
return $userSession;
Avoid too many return
statements within this method. Open
Open
return $router;
Avoid too many return
statements within this method. Open
Open
return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
Avoid too many return
statements within this method. Open
Open
return new NoopLockingProvider();
Avoid too many return
statements within this method. Open
Open
return new CryptoWrapper(
$c->getCrypto(),
$c->getSecureRandom(),
$request,
$c->getTimeFactory()
Avoid too many return
statements within this method. Open
Open
return $this;
Avoid too many return
statements within this method. Open
Open
return $groupManager;
Avoid too many return
statements within this method. Open
Open
return new \OC\AllConfig(
$c->getSystemConfig(),
$c->getEventDispatcher()
);
Avoid too many return
statements within this method. Open
Open
return new Log($logger);
Avoid too many return
statements within this method. Open
Open
return new \OC\BackgroundJob\JobList(
$c->getDatabaseConnection(),
$config,
new TimeFactory(),
$c->getLogger()
Avoid too many return
statements within this method. Open
Open
return new TempManager(
$c->getLogger(),
$c->getConfig()
);
Avoid too many return
statements within this method. Open
Open
return new ContentSecurityPolicyManager();
Avoid too many return
statements within this method. Open
Open
return new UserStoragesService(
$c->query('StoragesBackendService'),
$c->query('StoragesDBConfigService'),
$c->query('UserSession'),
$c->query('UserMountCache'),
Avoid too many return
statements within this method. Open
Open
return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
Avoid too many return
statements within this method. Open
Open
return new TimeFactory();
Avoid too many return
statements within this method. Open
Open
return new \OC\Memcache\Factory(
$prefix,
$c->getLogger(),
$config->getSystemValue('memcache.local', null),
$config->getSystemValue('memcache.distributed', null),
Avoid too many return
statements within this method. Open
Open
return new DateTimeZone(
$c->getConfig(),
$c->getSession()
);
Avoid too many return
statements within this method. Open
Open
return $manager;
Avoid too many return
statements within this method. Open
Open
return new Request(
[
'get' => $_GET,
'post' => $_POST,
'files' => $_FILES,
Avoid too many return
statements within this method. Open
Open
return new TagMapper($c->getDatabaseConnection());
Avoid too many return
statements within this method. Open
Open
return $c->query('SystemTagManagerFactory')->getObjectMapper();
Avoid too many return
statements within this method. Open
Open
return new \OC\OCS\CoreCapabilities($c->getConfig(), $c->getURLGenerator());
Avoid too many return
statements within this method. Open
Open
return new CsrfTokenManager(
$tokenGenerator,
$sessionStorage
);
Avoid too many return
statements within this method. Open
Open
return new \OC\L10N\Factory(
$c->getConfig(),
$c->getRequest(),
$c->getThemeService(),
$c->getUserSession(),
Avoid too many return
statements within this method. Open
Open
return new AsyncBus($jobList);
Avoid too many return
statements within this method. Open
Open
return new Search();
Avoid too many return
statements within this method. Open
Open
return new Db($c->getDatabaseConnection());
Avoid too many return
statements within this method. Open
Open
return new \OC\App\AppManager(
$c->getUserSession(),
$appConfig,
$groupManager,
$c->getMemCacheFactory(),
Avoid too many return
statements within this method. Open
Open
return new \OC\Files\Type\Detection(
$c->getURLGenerator(),
\OC::$SERVERROOT . '/config/',
\OC::$SERVERROOT . '/resources/config/'
);
Avoid too many return
statements within this method. Open
Open
return $root;
Avoid too many return
statements within this method. Open
Open
return new AccountMapper($c->getConfig(), $c->getDatabaseConnection(), new AccountTermMapper($c->getDatabaseConnection()));
Avoid too many return
statements within this method. Open
Open
return new \OC\User\Manager(
$c->getConfig(),
$c->getLogger(),
$c->getAccountMapper(),
new SyncService(
Avoid too many return
statements within this method. Open
Open
return true;
Avoid too many return
statements within this method. Open
Open
return new AvatarManager(
$c->getUserManager(),
$c->getLazyRootFolder(), // initialize the root folder lazily
$c->getL10N('lib'),
$c->getLogger()
Avoid too many return
statements within this method. Open
Open
return new WebDavClientService(
$c->getConfig(),
new \OC\Security\CertificateManager($uid, new View(), $c->getConfig())
);
Avoid too many return
statements within this method. Open
Open
return new DateTimeFormatter(
$c->getDateTimeZone()->getTimeZone(),
$c->getL10N('lib', $language)
);
Avoid too many return
statements within this method. Open
Open
return $manager;
Avoid too many return
statements within this method. Open
Open
return $policyManager;
Avoid too many return
statements within this method. Open
Open
return new LazyRoot(function () use ($c) {
return $c->getRootFolder();
});
Avoid too many return
statements within this method. Open
Open
return new \OC\NavigationManager(
$c->getAppManager(),
$c->getURLGenerator(),
$c->getL10NFactory(),
$c->getUserSession(),
Avoid too many return
statements within this method. Open
Open
return new \OC\SystemConfig($config);
Avoid too many return
statements within this method. Open
Open
return new \OC\AppConfig($c->getDatabaseConnection());
Avoid too many return
statements within this method. Open
Open
return new \OC\AppHelper();
Avoid too many return
statements within this method. Open
Open
return new \OC\Memcache\Factory(
'',
$c->getLogger(),
'\\OC\\Memcache\\ArrayCache',
'\\OC\\Memcache\\ArrayCache',
Avoid too many return
statements within this method. Open
Open
return $mountCache;
Avoid too many return
statements within this method. Open
Open
return new GlobalStoragesService(
$c->query('StoragesBackendService'),
$c->query('StoragesDBConfigService'),
$c->query('UserMountCache'),
$c->query('Crypto')
Avoid too many return
statements within this method. Open
Open
return new UserGlobalStoragesService(
$c->query('StoragesBackendService'),
$c->query('StoragesDBConfigService'),
$c->query('UserSession'),
$c->query('GroupManager'),
Avoid too many return
statements within this method. Open
Open
return $c->query('SystemTagManagerFactory')->getManager();
Avoid too many return
statements within this method. Open
Open
return new URLGenerator(
$config,
$cacheFactory,
$router,
new \OC\Helper\EnvironmentHelper()
Avoid too many return
statements within this method. Open
Open
return new ClientService(
$c->getConfig(),
new \OC\Security\CertificateManager($uid, new View(), $c->getConfig())
);
Avoid too many return
statements within this method. Open
Open
return new Mailer(
$c->getConfig(),
$c->getLogger(),
new \OC_Defaults()
);
Avoid too many return
statements within this method. Open
Open
return new \OC\Files\Mount\Manager();
Avoid too many return
statements within this method. Open
Open
return $factory->getManager();
Avoid too many return
statements within this method. Open
Open
return $service;
Avoid too many return
statements within this method. Open
Open
return new RedisFactory($systemConfig);
Avoid too many return
statements within this method. Open
Open
return $connection;
Avoid too many return
statements within this method. Open
Open
return new HTTPHelper(
$config,
$c->getHTTPClientService()
);
Avoid too many return
statements within this method. Open
Open
return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
Avoid too many return
statements within this method. Open
Open
return new EventDispatcher();
Avoid too many return
statements within this method. Open
Open
return new Cache\File();
Avoid too many return
statements within this method. Open
Open
return new MemcacheLockingProvider($memcache, $ttl);
Avoid too many return
statements within this method. Open
Open
return new \OC\Files\Type\Loader(
$c->getDatabaseConnection(),
$c->getMemCacheFactory()
);
Avoid too many return
statements within this method. Open
Open
return new LicenseManager(
$c->query(LicenseFetcher::class),
// can't query for MessageService because there is no implementation
// registered for the \OCP\L10N\IFactory interface in the server.
new MessageService(
Avoid too many return
statements within this method. Open
Open
return new Encryption\File($util);
Avoid too many return
statements within this method. Open
Open
return new Encryption\Keys\Storage(
$view,
$util,
$c->getUserSession()
);
Avoid too many return
statements within this method. Open
Open
return $factory;
Avoid too many return
statements within this method. Open
Open
return new \OC\Activity\Manager(
$c->getRequest(),
$c->getUserSession(),
$c->getConfig()
);
Avoid too many return
statements within this method. Open
Open
return new ThemeService(
$this->getSystemConfig()->getValue('theme'),
$c->getAppManager(),
new \OC\Helper\EnvironmentHelper()
);
Avoid too many return
statements within this method. Open
Open
return new SecureRandom();
Avoid too many return
statements within this method. Open
Open
return new Hasher($c->getConfig());
Avoid too many return
statements within this method. Open
Open
return $eventLogger;
Avoid too many return
statements within this method. Open
Open
return $queryLogger;
Avoid too many return
statements within this method. Open
Open
return new Manager($c->getEventDispatcher());
Avoid too many return
statements within this method. Open
Open
return new \OC\Authentication\TwoFactorAuth\Manager(
$c->getAppManager(),
$c->getSession(),
$c->getGroupManager(),
$c->getConfig(),
Avoid too many return
statements within this method. Open
Open
return new Checker(
new EnvironmentHelper(),
new FileAccessHelper(),
new AppLocator(),
$config,
Avoid too many return
statements within this method. Open
Open
return $manager;
Avoid too many return
statements within this method. Open
Open
return new Crypto($c->getConfig(), $c->getSecureRandom());
Avoid too many return
statements within this method. Open
Open
return new IniGetWrapper();
Avoid too many return
statements within this method. Open
Open
return new TrustedDomainHelper($this->getConfig());
Avoid too many return
statements within this method. Open
Open
return new DBConfigService(
$c->getDatabaseConnection(),
$c->getCrypto()
);