File helper.php
has 397 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Björn Schießle <bjoern@schiessle.org>
OC_Helper
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class OC_Helper {
private static $templateManager;
/**
* Creates an absolute url for public use
Method getStorageInfo
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getStorageInfo($path, $rootInfo = null) {
// return storage info without adding mount points
$includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
if (!$rootInfo) {
Function getStorageInfo
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function getStorageInfo($path, $rootInfo = null) {
// return storage info without adding mount points
$includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
if (!$rootInfo) {
- 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 rmdirr
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function rmdirr($dir, $deleteSelf = true) {
if (\is_dir($dir)) {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
- 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 buildNotExistingFileNameForView
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function buildNotExistingFileNameForView($path, $filename, \OC\Files\View $view) {
if ($path === '/') {
$path = '';
}
if ($pos = \strrpos($filename, '.')) {
Function buildNotExistingFileNameForView
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function buildNotExistingFileNameForView($path, $filename, \OC\Files\View $view) {
if ($path === '/') {
$path = '';
}
if ($pos = \strrpos($filename, '.')) {
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
public static function copyr($src, $dest) {
if (\is_dir($src)) {
if (!\is_dir($dest)) {
\mkdir($dest);
}
- 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 canExecute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function canExecute($name, $path = false) {
// path defaults to PATH from environment if not set
if ($path === false) {
$path = \getenv("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 rmdirr
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function rmdirr($dir, $deleteSelf = true) {
if (\is_dir($dir)) {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
Function streamCopy
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function streamCopy($source, $target) {
if (!$source or !$target) {
return [0, false];
}
$bufSize = 8192;
- 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 findBinaryPath
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function findBinaryPath($program) {
$memcache = \OC::$server->getMemCacheFactory()->create('findBinaryPath');
if ($memcache->hasKey($program)) {
return $memcache->get($program);
}
- 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 "$bytes TB";
Avoid too many return
statements within this method. Open
return "$bytes PB";
Avoid too many return
statements within this method. Open
return $bytes . "G";
Avoid too many return
statements within this method. Open
return "$bytes GB";
Function humanFileSize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function humanFileSize($bytes) {
if ($bytes < 0) {
return "?";
}
if ($bytes < 1024) {
- 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 getGlobalStorageInfo
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function getGlobalStorageInfo() {
$quota = OC_Util::getUserQuota(\OCP\User::getUser());
$rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext');
$used = $rootInfo['size'];
- 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"