Function getShippedApps
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
protected static function getShippedApps() {
$shippedApps = [];
foreach (\OC::$APPSROOTS as $app_dir) {
if ($dir = \opendir($app_dir['path'])) {
$nodes = \scandir($app_dir['path']);
- 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
Function checkAppsIntegrity
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public static function checkAppsIntegrity($data, $extractDir, $path, $isShipped = false) {
$l = \OC::$server->getL10N('lib');
//load the info.xml file of the app
if (!\is_file($extractDir.'/appinfo/info.xml')) {
//try to find it in a subdir
- 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
File Installer.php
has 315 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Brice Maron <brice@bmaron.net>
Function installApp
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function installApp($data = []) {
$l = \OC::$server->getL10N('lib');
list($extractDir, $path) = self::downloadApp($data);
- 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
Method installApp
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function installApp($data = []) {
$l = \OC::$server->getL10N('lib');
list($extractDir, $path) = self::downloadApp($data);
Method checkAppsIntegrity
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function checkAppsIntegrity($data, $extractDir, $path, $isShipped = false) {
$l = \OC::$server->getL10N('lib');
//load the info.xml file of the app
if (!\is_file($extractDir.'/appinfo/info.xml')) {
//try to find it in a subdir
Function downloadApp
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static function downloadApp($data = []) {
$l = \OC::$server->getL10N('lib');
if (!isset($data['source'])) {
throw new \Exception($l->t("No source specified when installing app"));
- 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
Method downloadApp
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function downloadApp($data = []) {
$l = \OC::$server->getL10N('lib');
if (!isset($data['source'])) {
throw new \Exception($l->t("No source specified when installing app"));
Function installShippedApps
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function installShippedApps($softErrors = false) {
$errors = [];
$appsToInstall = Installer::getShippedApps();
foreach ($appsToInstall as $appToInstall) {
- 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
Method installShippedApp
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function installShippedApp($app) {
\OC::$server->getLogger()->info('Attempting to install shipped app: '.$app);
$info = OC_App::getAppInfo($app);
if ($info === null) {
Method getShippedApps
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function getShippedApps() {
$shippedApps = [];
foreach (\OC::$APPSROOTS as $app_dir) {
if ($dir = \opendir($app_dir['path'])) {
$nodes = \scandir($app_dir['path']);
Avoid deeply nested control flow statements. Open
if (\is_file($extractDir.'/'.$folder.'/appinfo/info.xml')) {
$extractDir.='/'.$folder;
}
Function installShippedApp
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function installShippedApp($app) {
\OC::$server->getLogger()->info('Attempting to install shipped app: '.$app);
$info = OC_App::getAppInfo($app);
if ($info === null) {
- 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 deeply nested control flow statements. Open
if (($enabled || \in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps()))
&& \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') {
$shippedApps[] = $filename;
}