File File.php
has 511 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Bart Visscher <bartv@thisnet.nl>
* @author Björn Schießle <bjoern@schiessle.org>
* @author Jakob Sack <mail@jakobsack.de>
Function put
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
public function put($data) {
try {
$exists = $this->fileView->file_exists($this->path);
if ($this->info && $exists && !$this->info->isUpdateable()) {
throw new Forbidden();
- 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 createFileChunked
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
private function createFileChunked($data) {
list($path, $name) = \Sabre\Uri\split($this->path);
$info = \OC_FileChunking::decodeName($name);
if (empty($info)) {
- 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 put
has 138 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function put($data) {
try {
$exists = $this->fileView->file_exists($this->path);
if ($this->info && $exists && !$this->info->isUpdateable()) {
throw new Forbidden();
Method createFileChunked
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createFileChunked($data) {
list($path, $name) = \Sabre\Uri\split($this->path);
$info = \OC_FileChunking::decodeName($name);
if (empty($info)) {
Method emitPreHooks
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function emitPreHooks($exists, $path = null) {
if ($path === null) {
$path = $this->path;
}
$hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
Function convertToSabreException
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function convertToSabreException(\Exception $e) {
if ($e instanceof FileContentNotAllowedException) {
// the file content is not permitted
throw new DAVForbiddenException($e->getMessage(), $e->getRetry(), $e);
}
- 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 convertToSabreException
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertToSabreException(\Exception $e) {
if ($e instanceof FileContentNotAllowedException) {
// the file content is not permitted
throw new DAVForbiddenException($e->getMessage(), $e->getRetry(), $e);
}
Function emitPreHooks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function emitPreHooks($exists, $path = null) {
if ($path === null) {
$path = $this->path;
}
$hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($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 get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get() {
//throw exception if encryption is disabled but files are still encrypted
try {
$viewPath = \ltrim($this->path, '/');
if (!$this->info->isReadable() || !$this->fileView->file_exists($viewPath)) {
- 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 cleanFailedUpload
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function cleanFailedUpload(Storage $partStorage, $internalPartPath): void {
if ($partStorage->file_exists($internalPartPath)) {
try {
# broken/uncompleted uploaded files shall not go into trash-bin
if (class_exists(\OCA\Files_Trashbin\Storage::class)) {
- 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"