File util.php
has 965 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Adam Williamson <awilliam@redhat.com>
* @author Andreas Fischer <bantu@owncloud.com>
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
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');
- 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
OC_Util
has 55 functions (exceeds 20 allowed). Consider refactoring. Open
class OC_Util {
public static $scripts = [];
public static $styles = [];
public static $headers = [];
private static $rootMounted = false;
Method checkServer
has 189 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');
Method setupFS
has 140 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function setupFS($user = '', $fullInit = true) {
//setting up the filesystem twice can only lead to trouble
if (self::$fsSetup) {
return false;
}
Function setupFS
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public static function setupFS($user = '', $fullInit = true) {
//setting up the filesystem twice can only lead to trouble
if (self::$fsSetup) {
return false;
}
- 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 getDefaultPageUrl
has a Cognitive Complexity of 25 (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) {
- 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 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);
- 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 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);
}
- 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 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);
- 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 getDefaultPageUrl
has 33 lines of code (exceeds 25 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) {
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);
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);
}
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') {
- 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 checkPreSignedUrl
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function checkPreSignedUrl(): bool {
$request = \Sabre\HTTP\Sapi::createFromServerArray($_SERVER);
$verifier = new Verifier($request, \OC::$server->getConfig());
if ($verifier->isSignedRequest()) {
if (!$verifier->signedRequestIsValid()) {
- 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
return false;
Avoid too many return
statements within this method. Open
return $storage;
Avoid too many return
statements within this method. Open
return $storage;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return $storage;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]);
Avoid too many return
statements within this method. Open
return $storage;
Avoid too many return
statements within this method. Open
return $storage;
Avoid too many return
statements within this method. Open
return new \OC\Files\Storage\Wrapper\Checksum(['storage' => $storage]);
Avoid too many return
statements within this method. Open
return $storage;
Avoid too many return
statements within this method. Open
return new \OC\Files\Storage\Wrapper\Encoding(['storage' => $storage]);
Avoid too many return
statements within this method. Open
return new \OC\Files\Storage\Wrapper\ReadOnlyJail(
[
'storage' => $storage,
'mask' => \OCP\Constants::PERMISSION_READ,
'path' => 'files'
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
]);
Avoid too many return
statements within this method. Open
return new \OC\Files\Storage\Wrapper\Quota([
'mountPoint' => $mountPoint,
'storage' => $storage,
'quota' => $quota,
'root' => 'files'
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);
- 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 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;
}
- 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"