File SwiftFileBackend.php
has 1290 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* OpenStack Swift based file backend.
*
* This program is free software; you can redistribute it and/or modify
SwiftFileBackend
has 56 functions (exceeds 20 allowed). Consider refactoring. Open
class SwiftFileBackend extends FileBackendStore {
private const DEFAULT_HTTP_OPTIONS = [ 'httpVersion' => 'v1.1' ];
private const AUTH_FAILURE_ERROR = 'Could not connect due to prior authentication failure';
/** @var MultiHttpClient */
Function requestMultiWithAuth
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
private function requestMultiWithAuth( array $reqs, $options = [] ) {
$remainingTries = 2;
$auth = $this->getAuthentication();
while ( true ) {
if ( !$auth ) {
- 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 getDirListPageInternal
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function getDirListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
$dirs = [];
if ( $after === INF ) {
return $dirs; // nothing more
}
- 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 doGetFileStatMulti
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected function doGetFileStatMulti( array $params ) {
$stats = [];
$reqs = []; // (path => op)
// (a) Check the containers of the paths...
- 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 doStoreInternal
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doStoreInternal( array $params ) {
$status = $this->newStatus();
[ $dstCont, $dstRel ] = $this->resolveStoragePathReal( $params['dst'] );
if ( $dstRel === null ) {
Method doGetLocalCopyMulti
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doGetLocalCopyMulti( array $params ) {
$ep = array_diff_key( $params, [ 'srcs' => 1 ] ); // for error logging
// Blindly create tmp files and stream to them, catching any exception
// if the file does not exist. Do not waste time doing file stats here.
$reqs = []; // (path => op)
Method doMoveInternal
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doMoveInternal( array $params ) {
$status = $this->newStatus();
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
if ( $srcRel === null ) {
Function doGetLocalCopyMulti
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function doGetLocalCopyMulti( array $params ) {
$ep = array_diff_key( $params, [ 'srcs' => 1 ] ); // for error logging
// Blindly create tmp files and stream to them, catching any exception
// if the file does not exist. Do not waste time doing file stats here.
$reqs = []; // (path => op)
- 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 doGetFileContentsMulti
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function doGetFileContentsMulti( array $params ) {
$ep = array_diff_key( $params, [ 'srcs' => 1 ] ); // for error logging
// Blindly create tmp files and stream to them, catching any exception
// if the file does not exist. Do not waste time doing file stats here.
$reqs = []; // (path => op)
- 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 getDirListPageInternal
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDirListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
$dirs = [];
if ( $after === INF ) {
return $dirs; // nothing more
}
Method doGetFileContentsMulti
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doGetFileContentsMulti( array $params ) {
$ep = array_diff_key( $params, [ 'srcs' => 1 ] ); // for error logging
// Blindly create tmp files and stream to them, catching any exception
// if the file does not exist. Do not waste time doing file stats here.
$reqs = []; // (path => op)
Method doGetFileStatMulti
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doGetFileStatMulti( array $params ) {
$stats = [];
$reqs = []; // (path => op)
// (a) Check the containers of the paths...
Method doStreamFile
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doStreamFile( array $params ) {
$status = $this->newStatus();
$flags = !empty( $params['headless'] ) ? HTTPFileStreamer::STREAM_HEADLESS : 0;
Function doExecuteOpHandlesInternal
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
/** @var SwiftFileOpHandle[] $fileOpHandles */
'@phan-var SwiftFileOpHandle[] $fileOpHandles';
/** @var StatusValue[] $statuses */
- 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 doCopyInternal
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doCopyInternal( array $params ) {
$status = $this->newStatus();
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
if ( $srcRel === null ) {
Method doDescribeInternal
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doDescribeInternal( array $params ) {
$status = $this->newStatus();
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
if ( $srcRel === null ) {
Method doCreateInternal
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doCreateInternal( array $params ) {
$status = $this->newStatus();
[ $dstCont, $dstRel ] = $this->resolveStoragePathReal( $params['dst'] );
if ( $dstRel === null ) {
Method getFileHttpUrl
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFileHttpUrl( array $params ) {
if ( $this->swiftTempUrlKey != '' ||
( $this->rgwS3AccessKey != '' && $this->rgwS3SecretKey != '' )
) {
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
Function doMoveInternal
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function doMoveInternal( array $params ) {
$status = $this->newStatus();
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
if ( $srcRel === null ) {
- 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 getFileListPageInternal
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getFileListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
$files = []; // list of (path, stat map or null) entries
if ( $after === INF ) {
return $files; // nothing more
}
- 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 addMissingHashMetadata
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function addMissingHashMetadata( array $objHdrs, $path ) {
if ( isset( $objHdrs['x-object-meta-sha1base36'] ) ) {
return $objHdrs; // nothing to do
}
- 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 addMissingHashMetadata
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addMissingHashMetadata( array $objHdrs, $path ) {
if ( isset( $objHdrs['x-object-meta-sha1base36'] ) ) {
return $objHdrs; // nothing to do
}
Method requestMultiWithAuth
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function requestMultiWithAuth( array $reqs, $options = [] ) {
$remainingTries = 2;
$auth = $this->getAuthentication();
while ( true ) {
if ( !$auth ) {
Method objectListing
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function objectListing(
$fullCont, $type, $limit, $after = null, $prefix = null, $delim = null
) {
$status = $this->newStatus();
Method refreshAuthentication
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function refreshAuthentication() {
[ $rcode, , $rhdrs, $rbody, ] = $this->http->run( [
'method' => 'GET',
'url' => "{$this->swiftAuthUrl}/v1.0",
'headers' => [
Method doDeleteInternal
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doDeleteInternal( array $params ) {
$status = $this->newStatus();
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
if ( $srcRel === null ) {
Method __construct
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( array $config ) {
parent::__construct( $config );
// Required settings
$this->swiftAuthUrl = $config['swiftAuthUrl'];
$this->swiftUser = $config['swiftUser'];
Function doStreamFile
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function doStreamFile( array $params ) {
$status = $this->newStatus();
$flags = !empty( $params['headless'] ) ? HTTPFileStreamer::STREAM_HEADLESS : 0;
- 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 getContainerStat
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function getContainerStat( $container, $bypassCache = false ) {
/** @noinspection PhpUnusedLocalVariableInspection */
$ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
if ( $bypassCache ) { // purge cache
- 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 objectListing
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function objectListing(
$fullCont, $type, $limit, $after = null, $prefix = null, $delim = null
) {
$status = $this->newStatus();
- 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 getFileListPageInternal
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFileListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
$files = []; // list of (path, stat map or null) entries
if ( $after === INF ) {
return $files; // nothing more
}
Method getContainerStat
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getContainerStat( $container, $bypassCache = false ) {
/** @noinspection PhpUnusedLocalVariableInspection */
$ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
if ( $bypassCache ) { // purge cache
Method doExecuteOpHandlesInternal
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
/** @var SwiftFileOpHandle[] $fileOpHandles */
'@phan-var SwiftFileOpHandle[] $fileOpHandles';
/** @var StatusValue[] $statuses */
Function doStoreInternal
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function doStoreInternal( array $params ) {
$status = $this->newStatus();
[ $dstCont, $dstRel ] = $this->resolveStoragePathReal( $params['dst'] );
if ( $dstRel === null ) {
- 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 extractMutableContentHeaders
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function extractMutableContentHeaders( array $headers ) {
$contentHeaders = [];
// Normalize casing, and strip out illegal headers
foreach ( $headers as $name => $value ) {
$name = strtolower( $name );
- 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 getFileHttpUrl
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getFileHttpUrl( array $params ) {
if ( $this->swiftTempUrlKey != '' ||
( $this->rgwS3AccessKey != '' && $this->rgwS3SecretKey != '' )
) {
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
- 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 doDescribeInternal
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function doDescribeInternal( array $params ) {
$status = $this->newStatus();
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
if ( $srcRel === null ) {
- 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 getAuthentication
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getAuthentication() {
if ( $this->authErrorTimestamp !== null ) {
$interval = time() - $this->authErrorTimestamp;
if ( $interval < 60 ) {
$this->logger->debug(
Function doCopyInternal
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function doCopyInternal( array $params ) {
$status = $this->newStatus();
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
if ( $srcRel === null ) {
- 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 getAuthentication
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function getAuthentication() {
if ( $this->authErrorTimestamp !== null ) {
$interval = time() - $this->authErrorTimestamp;
if ( $interval < 60 ) {
$this->logger->debug(
- 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 buildFileObjectListing
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function buildFileObjectListing( array $objects ) {
$names = [];
foreach ( $objects as $object ) {
if ( is_object( $object ) ) {
if ( isset( $object->subdir ) || !isset( $object->name ) ) {
- 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 onError
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function onError( $status, $func, array $params, $err = '', $code = 0, $desc = '', $body = '' ) {
Function __construct
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( array $config ) {
parent::__construct( $config );
// Required settings
$this->swiftAuthUrl = $config['swiftAuthUrl'];
$this->swiftUser = $config['swiftUser'];
- 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 objectListing
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$fullCont, $type, $limit, $after = null, $prefix = null, $delim = null
Function doDeleteInternal
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function doDeleteInternal( array $params ) {
$status = $this->newStatus();
[ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
if ( $srcRel === null ) {
- 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 getDirListPageInternal
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getDirListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
Method getFileListPageInternal
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getFileListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
Function doCreateInternal
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function doCreateInternal( array $params ) {
$status = $this->newStatus();
[ $dstCont, $dstRel ] = $this->resolveStoragePathReal( $params['dst'] );
if ( $dstRel === null ) {
- 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 refreshAuthentication
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function refreshAuthentication() {
[ $rcode, , $rhdrs, $rbody, ] = $this->http->run( [
'method' => 'GET',
'url' => "{$this->swiftAuthUrl}/v1.0",
'headers' => [
- 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::TEMPURL_ERROR;
Avoid too many return
statements within this method. Open
return $status;
Avoid too many return
statements within this method. Open
return $status;
Function onError
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function onError( $status, $func, array $params, $err = '', $code = 0, $desc = '', $body = '' ) {
if ( $this->isAuthFailureResponse( $code, $err ) ) {
if ( $status instanceof StatusValue ) {
$status->fatal( 'backend-fail-connect', $this->name );
}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$handler = function ( array $request, StatusValue $status ) use ( $method, $params ) {
[ $rcode, $rdesc, , $rbody, $rerr ] = $request['response'];
if ( $rcode === 201 || $rcode === 202 ) {
// good
} elseif ( $rcode === 412 ) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 130.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$handler = function ( array $request, StatusValue $status ) use ( $method, $params ) {
[ $rcode, $rdesc, , $rbody, $rerr ] = $request['response'];
if ( $rcode === 201 || $rcode === 202 ) {
// good
} elseif ( $rcode === 412 ) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 130.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
$reqs = [ [
'method' => 'PUT',
'container' => $dstCont,
'relPath' => $dstRel,
'headers' => array_merge(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 102.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
$reqs = [ [
'method' => 'PUT',
'container' => $dstCont,
'relPath' => $dstRel,
'headers' => array_merge(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 102.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76