File Cache.php
has 627 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Andreas Fischer <bantu@owncloud.com>
* @author Björn Schießle <bjoern@schiessle.org>
* @author Florin Peter <github@florin-peter.de>
Cache
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Cache implements ICache {
use MoveFromCacheTrait {
MoveFromCacheTrait::moveFromCache as moveFromCacheFallback;
}
Function buildParts
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected function buildParts(array $data) {
$fields = [
'path', 'parent', 'name', 'mimetype', 'size', 'mtime', 'storage_mtime', 'encrypted',
'etag', 'permissions', 'checksum'];
- 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 calculateFolderSize
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function calculateFolderSize($path, $entry = null) {
$totalSize = 0;
if ($entry === null or !isset($entry['fileid'])) {
$entry = $this->get($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 update
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function update($id, array $data) {
unset(self::$path_cache[(int)$id]);
if (isset($data['path'])) {
// normalize path
$data['path'] = $this->normalize($data['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 handleChildrenMove
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleChildrenMove($sourceStorageId, $sourcePath, $targetStorageId, $targetPath) {
$platformName = $this->connection->getDatabasePlatform()->getName();
$versionString = $this->connection->getDatabaseVersionString();
$versionArray = \explode('.', $versionString);
Method getChildrenWithFilter
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getChildrenWithFilter($fileId, $mimetypeFilter = null) {
if ($fileId > -1) {
$qb = $this->connection->getQueryBuilder();
$qb->select(
'fileid',
Method get
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get($file) {
if (\is_string($file) or $file == '') {
// normalize file
$file = $this->normalize($file);
Method update
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update($id, array $data) {
unset(self::$path_cache[(int)$id]);
if (isset($data['path'])) {
// normalize path
$data['path'] = $this->normalize($data['path']);
Function get
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function get($file) {
if (\is_string($file) or $file == '') {
// normalize file
$file = $this->normalize($file);
- 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 buildParts
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function buildParts(array $data) {
$fields = [
'path', 'parent', 'name', 'mimetype', 'size', 'mtime', 'storage_mtime', 'encrypted',
'etag', 'permissions', 'checksum'];
Method calculateFolderSize
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function calculateFolderSize($path, $entry = null) {
$totalSize = 0;
if ($entry === null or !isset($entry['fileid'])) {
$entry = $this->get($path);
}
Method searchByTag
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function searchByTag($tag, $userId) {
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' .
'`mimetype`, `mimepart`, `size`, `mtime`, ' .
'`encrypted`, `etag`, `permissions`, `checksum` ' .
'FROM `*PREFIX*filecache` `file`, ' .
Method insert
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function insert($file, array $data) {
// normalize file
$file = $this->normalize($file);
if (isset($this->partial[$file])) { //add any saved partial data
Function moveFromCache
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
self::$path_cache->clear();
if ($sourceCache instanceof Cache) {
// normalize source and target
$sourcePath = $this->normalize($sourcePath);
- 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 moveFromCache
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
self::$path_cache->clear();
if ($sourceCache instanceof Cache) {
// normalize source and target
$sourcePath = $this->normalize($sourcePath);
Function getPathById
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getPathById($id) {
if (!isset(self::$path_cache[(int)$id])) {
$sql = 'SELECT `storage`, `path` FROM `*PREFIX*filecache` WHERE `fileid` = ?';
$result = $this->connection->executeQuery($sql, [$id]);
if ($row = $result->fetch()) {
- 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 getChildrenWithFilter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function getChildrenWithFilter($fileId, $mimetypeFilter = null) {
if ($fileId > -1) {
$qb = $this->connection->getQueryBuilder();
$qb->select(
'fileid',
- 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 getStatus
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getStatus($file) {
// normalize file
$file = $this->normalize($file);
$pathHash = \md5($file);
- 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 handleChildrenMove
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function handleChildrenMove($sourceStorageId, $sourcePath, $targetStorageId, $targetPath) {
$platformName = $this->connection->getDatabasePlatform()->getName();
$versionString = $this->connection->getDatabaseVersionString();
$versionArray = \explode('.', $versionString);
- 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 self::NOT_FOUND;