wikimedia/mediawiki-core

View on GitHub
includes/libs/filebackend/SwiftFileBackend.php

Summary

Maintainability
F
2 wks
Test Coverage

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
Severity: Major
Found in includes/libs/filebackend/SwiftFileBackend.php - About 3 days to fix

    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 */
    Severity: Major
    Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 day to fix

      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 ) {
      Severity: Minor
      Found in includes/libs/filebackend/SwiftFileBackend.php - About 4 hrs to fix

      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
              }
      Severity: Minor
      Found in includes/libs/filebackend/SwiftFileBackend.php - About 3 hrs to fix

      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...
      Severity: Minor
      Found in includes/libs/filebackend/SwiftFileBackend.php - About 2 hrs to fix

      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 ) {
      Severity: Major
      Found in includes/libs/filebackend/SwiftFileBackend.php - About 2 hrs to fix

        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)
        Severity: Major
        Found in includes/libs/filebackend/SwiftFileBackend.php - About 2 hrs to fix

          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 ) {
          Severity: Major
          Found in includes/libs/filebackend/SwiftFileBackend.php - About 2 hrs to fix

            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)
            Severity: Minor
            Found in includes/libs/filebackend/SwiftFileBackend.php - About 2 hrs to fix

            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)
            Severity: Minor
            Found in includes/libs/filebackend/SwiftFileBackend.php - About 2 hrs to fix

            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
                    }
            Severity: Minor
            Found in includes/libs/filebackend/SwiftFileBackend.php - About 2 hrs to fix

              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)
              Severity: Minor
              Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                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...
                Severity: Minor
                Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                  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;
                  
                  
                  Severity: Minor
                  Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                    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 */
                    Severity: Minor
                    Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                    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 ) {
                    Severity: Minor
                    Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                      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 ) {
                      Severity: Minor
                      Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                        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 ) {
                        Severity: Minor
                        Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                          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'] );
                          Severity: Minor
                          Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                            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 ) {
                            Severity: Minor
                            Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                            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
                                    }
                            Severity: Minor
                            Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                            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
                                    }
                            
                            
                            Severity: Minor
                            Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                            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
                                    }
                            
                            
                            Severity: Minor
                            Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                              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 ) {
                              Severity: Minor
                              Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                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();
                                
                                
                                Severity: Minor
                                Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                  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' => [
                                  Severity: Minor
                                  Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                    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 ) {
                                    Severity: Minor
                                    Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                      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'];
                                      Severity: Minor
                                      Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                        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;
                                        
                                        
                                        Severity: Minor
                                        Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                        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
                                        Severity: Minor
                                        Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                        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();
                                        
                                        
                                        Severity: Minor
                                        Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                        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
                                                }
                                        Severity: Minor
                                        Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                          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
                                          Severity: Minor
                                          Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                            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 */
                                            Severity: Minor
                                            Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                              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 ) {
                                              Severity: Minor
                                              Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                              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 );
                                              Severity: Minor
                                              Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                              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'] );
                                              Severity: Minor
                                              Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                              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 ) {
                                              Severity: Minor
                                              Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                              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(
                                              Severity: Minor
                                              Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                                                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 ) {
                                                Severity: Minor
                                                Found in includes/libs/filebackend/SwiftFileBackend.php - About 55 mins to fix

                                                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(
                                                Severity: Minor
                                                Found in includes/libs/filebackend/SwiftFileBackend.php - About 55 mins to fix

                                                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 ) ) {
                                                Severity: Minor
                                                Found in includes/libs/filebackend/SwiftFileBackend.php - About 55 mins to fix

                                                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 = '' ) {
                                                Severity: Major
                                                Found in includes/libs/filebackend/SwiftFileBackend.php - About 50 mins to fix

                                                  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'];
                                                  Severity: Minor
                                                  Found in includes/libs/filebackend/SwiftFileBackend.php - About 45 mins to fix

                                                  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
                                                  Severity: Minor
                                                  Found in includes/libs/filebackend/SwiftFileBackend.php - About 45 mins to fix

                                                    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 ) {
                                                    Severity: Minor
                                                    Found in includes/libs/filebackend/SwiftFileBackend.php - About 45 mins to fix

                                                    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 ) {
                                                    Severity: Minor
                                                    Found in includes/libs/filebackend/SwiftFileBackend.php - About 35 mins to fix

                                                      Method getFileListPageInternal has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                          public function getFileListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
                                                      Severity: Minor
                                                      Found in includes/libs/filebackend/SwiftFileBackend.php - About 35 mins to fix

                                                        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 ) {
                                                        Severity: Minor
                                                        Found in includes/libs/filebackend/SwiftFileBackend.php - About 35 mins to fix

                                                        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' => [
                                                        Severity: Minor
                                                        Found in includes/libs/filebackend/SwiftFileBackend.php - About 35 mins to fix

                                                        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;
                                                        Severity: Major
                                                        Found in includes/libs/filebackend/SwiftFileBackend.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                  return $status;
                                                          Severity: Major
                                                          Found in includes/libs/filebackend/SwiftFileBackend.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                    return $status;
                                                            Severity: Major
                                                            Found in includes/libs/filebackend/SwiftFileBackend.php - About 30 mins to fix

                                                              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 );
                                                                          }
                                                              Severity: Minor
                                                              Found in includes/libs/filebackend/SwiftFileBackend.php - About 25 mins to fix

                                                              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 ) {
                                                              Severity: Major
                                                              Found in includes/libs/filebackend/SwiftFileBackend.php and 1 other location - About 2 hrs to fix
                                                              includes/libs/filebackend/SwiftFileBackend.php on lines 399..410

                                                              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

                                                              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 ) {
                                                              Severity: Major
                                                              Found in includes/libs/filebackend/SwiftFileBackend.php and 1 other location - About 2 hrs to fix
                                                              includes/libs/filebackend/SwiftFileBackend.php on lines 311..322

                                                              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

                                                              Further Reading

                                                              Identical blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      $reqs = [ [
                                                                          'method' => 'PUT',
                                                                          'container' => $dstCont,
                                                                          'relPath' => $dstRel,
                                                                          'headers' => array_merge(
                                                              Severity: Major
                                                              Found in includes/libs/filebackend/SwiftFileBackend.php and 1 other location - About 1 hr to fix
                                                              includes/libs/filebackend/SwiftFileBackend.php on lines 441..452

                                                              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

                                                              Further Reading

                                                              Identical blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      $reqs = [ [
                                                                          'method' => 'PUT',
                                                                          'container' => $dstCont,
                                                                          'relPath' => $dstRel,
                                                                          'headers' => array_merge(
                                                              Severity: Major
                                                              Found in includes/libs/filebackend/SwiftFileBackend.php and 1 other location - About 1 hr to fix
                                                              includes/libs/filebackend/SwiftFileBackend.php on lines 497..508

                                                              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

                                                              Further Reading

                                                              There are no issues that match your filters.

                                                              Category
                                                              Status