owncloud/core

lib/private/legacy/util.php

Summary

F
1 wk

File util.php has 889 lines of code (exceeds 250 allowed). Consider refactoring. Open

<?php
/**
* @author Andreas Fischer <bantu@owncloud.com>
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
Found in lib/private/legacy/util.php - About 2 days to fix

Function checkServer has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open

    public static function checkServer(\OCP\IConfig $config) {$l = \OC::$server->getL10N('lib');$errors = [];
$CONFIG_DATADIRECTORY =$config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data');  Found in lib/private/legacy/util.php - About 1 day to fix 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 OC_Util has 53 functions (exceeds 20 allowed). Consider refactoring. Open class OC_Util { public static$scripts = [];
public static $styles = []; public static$headers = [];
private static $rootMounted = false; Found in lib/private/legacy/util.php - About 7 hrs to fix Method checkServer has 175 lines of code (exceeds 25 allowed). Consider refactoring. Open  public static function checkServer(\OCP\IConfig$config) {
$l = \OC::$server->getL10N('lib');
$errors = [];$CONFIG_DATADIRECTORY = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data');


Found in lib/private/legacy/util.php - About 7 hrs to fix

Method setupFS has 135 lines of code (exceeds 25 allowed). Consider refactoring. Open

    public static function setupFS($user = '') { //setting up the filesystem twice can only lead to trouble if (self::$fsSetup) {
return false;
}
Found in lib/private/legacy/util.php - About 5 hrs to fix

Function setupFS has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open

    public static function setupFS($user = '') { //setting up the filesystem twice can only lead to trouble if (self::$fsSetup) {
return false;
}
Found in lib/private/legacy/util.php - About 4 hrs to fix

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"

Function getDefaultPageUrl has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open

    public static function getDefaultPageUrl() {
$urlGenerator = \OC::$server->getURLGenerator();
// Deny the redirect if the URL contains a @
// This prevents unvalidated redirects like ?redirect_url=:user@domain.com
if (isset($_REQUEST['redirect_url']) && \strpos($_REQUEST['redirect_url'], '@') === false) {
Found in lib/private/legacy/util.php - About 2 hrs to fix

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"

Function needUpgrade has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open

    public static function needUpgrade(\OCP\IConfig $config) { if ($config->getSystemValue('installed', false)) {
$installedVersion =$config->getSystemValue('version', '0.0.0');
$currentVersion = \implode('.', \OCP\Util::getVersion());$versionDiff = \version_compare($currentVersion,$installedVersion);
Found in lib/private/legacy/util.php - About 2 hrs to fix

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"

Function copyr has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open

    public static function copyr($source, \OCP\Files\Folder$target) {
$dir = @\opendir($source);
if ($dir === false) { throw new NoReadAccessException('No read permission for folder ' .$source);
}
Found in lib/private/legacy/util.php - About 2 hrs to fix

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"

Function addExternalResource has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open

    private static function addExternalResource($application,$prepend, $path,$type = "script") {
if ($type === "style") { if (!\in_array($path, self::$styles)) { if ($prepend === true) {
\array_unshift(self::$styles,$path);
Found in lib/private/legacy/util.php - About 1 hr to fix

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"

Method needUpgrade has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open

    public static function needUpgrade(\OCP\IConfig $config) { if ($config->getSystemValue('installed', false)) {
$installedVersion =$config->getSystemValue('version', '0.0.0');
$currentVersion = \implode('.', \OCP\Util::getVersion());$versionDiff = \version_compare($currentVersion,$installedVersion);
Found in lib/private/legacy/util.php - About 1 hr to fix

Method copyr has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open

    public static function copyr($source, \OCP\Files\Folder$target) {
$dir = @\opendir($source);
if ($dir === false) { throw new NoReadAccessException('No read permission for folder ' .$source);
}
Found in lib/private/legacy/util.php - About 1 hr to fix

Function checkDatabaseVersion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open

    public static function checkDatabaseVersion() {
$l = \OC::$server->getL10N('lib');
$errors = [];$dbType = \OC::$server->getSystemConfig()->getValue('dbtype', 'sqlite'); if ($dbType === 'pgsql') {
Found in lib/private/legacy/util.php - About 45 mins to fix

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"

Avoid too many return statements within this method. Open

                return new \OC\Files\Storage\Wrapper\PermissionsMask([
'storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE ]); Found in lib/private/legacy/util.php - About 30 mins to fix Avoid too many return statements within this method. Open  return true; Found in lib/private/legacy/util.php - About 30 mins to fix Avoid too many return statements within this method. Open  return$storage;
Found in lib/private/legacy/util.php - About 30 mins to fix

            return $storage; Found in lib/private/legacy/util.php - About 30 mins to fix Avoid too many return statements within this method. Open  return$storage;
Found in lib/private/legacy/util.php - About 30 mins to fix

                return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]); Found in lib/private/legacy/util.php - About 30 mins to fix Avoid too many return statements within this method. Open  return$storage;
Found in lib/private/legacy/util.php - About 30 mins to fix

Avoid too many return statements within this method. Open

        return true;
Found in lib/private/legacy/util.php - About 30 mins to fix

                return new \OC\Files\Storage\Wrapper\Encoding(['storage' => $storage]); Found in lib/private/legacy/util.php - About 30 mins to fix Avoid too many return statements within this method. Open  return$storage;
Found in lib/private/legacy/util.php - About 30 mins to fix

Avoid too many return statements within this method. Open

            return false;
Found in lib/private/legacy/util.php - About 30 mins to fix

            return $storage; Found in lib/private/legacy/util.php - About 30 mins to fix Avoid too many return statements within this method. Open  return new \OC\Files\Storage\Wrapper\ReadOnlyJail( [ 'storage' =>$storage,
'path' => 'files'
Found in lib/private/legacy/util.php - About 30 mins to fix

                return new \OC\Files\Storage\Wrapper\Checksum(['storage' => $storage]); Found in lib/private/legacy/util.php - About 30 mins to fix Avoid too many return statements within this method. Open  return new \OC\Files\Storage\Wrapper\Quota(['storage' =>$storage, 'quota' => $quota, 'root' => 'files']); Found in lib/private/legacy/util.php - About 30 mins to fix Function getUserQuota has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open  public static function getUserQuota($userId) {
if ($userId instanceof IUser) {$user = $userId; } else {$user = \OC::$server->getUserManager()->get($userId);
Found in lib/private/legacy/util.php - About 25 mins to fix

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"

Function isValidFileName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

    public static function isValidFileName($file) {$trimmed = \trim($file); if ($trimmed === '') {
return false;
}
Found in lib/private/legacy/util.php - About 25 mins to fix

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"