wikimedia/mediawiki-core

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

Summary

Maintainability
F
1 wk
Test Coverage

File FSFileBackend.php has 667 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Major
Found in includes/libs/filebackend/FSFileBackend.php - About 1 day to fix

    FSFileBackend has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FSFileBackend extends FileBackendStore {
        /** @var MapCacheLRU Cache for known prepared/usable directories */
        protected $usableDirCache;
    
        /** @var string|null Directory holding the container directories */
    Severity: Minor
    Found in includes/libs/filebackend/FSFileBackend.php - About 5 hrs to fix

      Function doCopyInternal has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function doCopyInternal( array $params ) {
              $status = $this->newStatus();
      
              $fsSrcPath = $this->resolveToFSPath( $params['src'] );
              if ( $fsSrcPath === null ) {
      Severity: Minor
      Found in includes/libs/filebackend/FSFileBackend.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 doCopyInternal has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function doCopyInternal( array $params ) {
              $status = $this->newStatus();
      
              $fsSrcPath = $this->resolveToFSPath( $params['src'] );
              if ( $fsSrcPath === null ) {
      Severity: Minor
      Found in includes/libs/filebackend/FSFileBackend.php - About 1 hr to fix

        Function doStoreInternal has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function doStoreInternal( array $params ) {
                $status = $this->newStatus();
        
                $fsSrcPath = $params['src']; // file system path
                $fsDstPath = $this->resolveToFSPath( $params['dst'] );
        Severity: Minor
        Found in includes/libs/filebackend/FSFileBackend.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 doStoreInternal has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function doStoreInternal( array $params ) {
                $status = $this->newStatus();
        
                $fsSrcPath = $params['src']; // file system path
                $fsDstPath = $this->resolveToFSPath( $params['dst'] );
        Severity: Minor
        Found in includes/libs/filebackend/FSFileBackend.php - About 1 hr to fix

          Method doCreateInternal has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function doCreateInternal( array $params ) {
                  $status = $this->newStatus();
          
                  $fsDstPath = $this->resolveToFSPath( $params['dst'] );
                  if ( $fsDstPath === null ) {
          Severity: Minor
          Found in includes/libs/filebackend/FSFileBackend.php - About 1 hr to fix

            Function doCreateInternal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function doCreateInternal( array $params ) {
                    $status = $this->newStatus();
            
                    $fsDstPath = $this->resolveToFSPath( $params['dst'] );
                    if ( $fsDstPath === null ) {
            Severity: Minor
            Found in includes/libs/filebackend/FSFileBackend.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 doMoveInternal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function doMoveInternal( array $params ) {
                    $status = $this->newStatus();
            
                    $fsSrcPath = $this->resolveToFSPath( $params['src'] );
                    if ( $fsSrcPath === null ) {
            Severity: Minor
            Found in includes/libs/filebackend/FSFileBackend.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 doMoveInternal has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function doMoveInternal( array $params ) {
                    $status = $this->newStatus();
            
                    $fsSrcPath = $this->resolveToFSPath( $params['src'] );
                    if ( $fsSrcPath === null ) {
            Severity: Minor
            Found in includes/libs/filebackend/FSFileBackend.php - About 1 hr to fix

              Function doGetLocalCopyMulti has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function doGetLocalCopyMulti( array $params ) {
                      $tmpFiles = []; // (path => TempFSFile)
              
                      foreach ( $params['srcs'] as $src ) {
                          $source = $this->resolveToFSPath( $src );
              Severity: Minor
              Found in includes/libs/filebackend/FSFileBackend.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 doPrepareInternal has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function doPrepareInternal( $fullCont, $dirRel, array $params ) {
                      $status = $this->newStatus();
                      [ , $shortCont, ] = FileBackend::splitStoragePath( $params['dir'] );
                      $contRoot = $this->containerFSRoot( $shortCont, $fullCont ); // must be valid
                      $fsDirectory = ( $dirRel != '' ) ? "{$contRoot}/{$dirRel}" : $contRoot;
              Severity: Minor
              Found in includes/libs/filebackend/FSFileBackend.php - About 1 hr to fix

                Method doGetLocalCopyMulti has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function doGetLocalCopyMulti( array $params ) {
                        $tmpFiles = []; // (path => TempFSFile)
                
                        foreach ( $params['srcs'] as $src ) {
                            $source = $this->resolveToFSPath( $src );
                Severity: Minor
                Found in includes/libs/filebackend/FSFileBackend.php - About 1 hr to fix

                  Function doDeleteInternal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function doDeleteInternal( array $params ) {
                          $status = $this->newStatus();
                  
                          $fsSrcPath = $this->resolveToFSPath( $params['src'] );
                          if ( $fsSrcPath === null ) {
                  Severity: Minor
                  Found in includes/libs/filebackend/FSFileBackend.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 doDeleteInternal has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function doDeleteInternal( array $params ) {
                          $status = $this->newStatus();
                  
                          $fsSrcPath = $this->resolveToFSPath( $params['src'] );
                          if ( $fsSrcPath === null ) {
                  Severity: Minor
                  Found in includes/libs/filebackend/FSFileBackend.php - About 1 hr to fix

                    Function __construct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function __construct( array $config ) {
                            parent::__construct( $config );
                    
                            if ( PHP_OS_FAMILY === 'Windows' ) {
                                $this->os = 'Windows';
                    Severity: Minor
                    Found in includes/libs/filebackend/FSFileBackend.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 doPrepareInternal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function doPrepareInternal( $fullCont, $dirRel, array $params ) {
                            $status = $this->newStatus();
                            [ , $shortCont, ] = FileBackend::splitStoragePath( $params['dir'] );
                            $contRoot = $this->containerFSRoot( $shortCont, $fullCont ); // must be valid
                            $fsDirectory = ( $dirRel != '' ) ? "{$contRoot}/{$dirRel}" : $contRoot;
                    Severity: Minor
                    Found in includes/libs/filebackend/FSFileBackend.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

                    Function doGetLocalReferenceMulti has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function doGetLocalReferenceMulti( array $params ) {
                            $fsFiles = []; // (path => FSFile)
                    
                            foreach ( $params['srcs'] as $src ) {
                                $source = $this->resolveToFSPath( $src );
                    Severity: Minor
                    Found in includes/libs/filebackend/FSFileBackend.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

                    Function doClearCache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function doClearCache( array $paths = null ) {
                            if ( is_array( $paths ) ) {
                                foreach ( $paths as $path ) {
                                    $fsPath = $this->resolveToFSPath( $path );
                                    if ( $fsPath !== null ) {
                    Severity: Minor
                    Found in includes/libs/filebackend/FSFileBackend.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 getFileNotFoundRegex has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function getFileNotFoundRegex() {
                            static $regex;
                            if ( $regex === null ) {
                                // "No such file or directory": string literal in spl_directory.c etc.
                                $alternatives = [ ': No such file or directory' ];
                    Severity: Minor
                    Found in includes/libs/filebackend/FSFileBackend.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 doPublishInternal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function doPublishInternal( $fullCont, $dirRel, array $params ) {
                            $status = $this->newStatus();
                            [ , $shortCont, ] = FileBackend::splitStoragePath( $params['dir'] );
                            $contRoot = $this->containerFSRoot( $shortCont, $fullCont ); // must be valid
                            $fsDirectory = ( $dirRel != '' ) ? "{$contRoot}/{$dirRel}" : $contRoot;
                    Severity: Minor
                    Found in includes/libs/filebackend/FSFileBackend.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 doSecureInternal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function doSecureInternal( $fullCont, $dirRel, array $params ) {
                            $status = $this->newStatus();
                            [ , $shortCont, ] = FileBackend::splitStoragePath( $params['dir'] );
                            $contRoot = $this->containerFSRoot( $shortCont, $fullCont ); // must be valid
                            $fsDirectory = ( $dirRel != '' ) ? "{$contRoot}/{$dirRel}" : $contRoot;
                    Severity: Minor
                    Found in includes/libs/filebackend/FSFileBackend.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 $status;
                    Severity: Major
                    Found in includes/libs/filebackend/FSFileBackend.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

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

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

                                if ( !empty( $params['async'] ) ) { // deferred
                                    $cmd = $this->makeCopyCommand( $fsSrcPath, $fsDstPath, $ignoreMissing );
                                    $handler = function ( $errors, StatusValue $status, array $params, $cmd ) {
                                        if ( $errors !== '' && !( $this->os === 'Windows' && $errors[0] === " " ) ) {
                                            $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] );
                        Severity: Major
                        Found in includes/libs/filebackend/FSFileBackend.php and 1 other location - About 3 hrs to fix
                        includes/libs/filebackend/FSFileBackend.php on lines 422..443

                        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 152.

                        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

                                if ( !empty( $params['async'] ) ) { // deferred
                                    $cmd = $this->makeMoveCommand( $fsSrcPath, $fsDstPath, $ignoreMissing );
                                    $handler = function ( $errors, StatusValue $status, array $params, $cmd ) {
                                        if ( $errors !== '' && !( $this->os === 'Windows' && $errors[0] === " " ) ) {
                                            $status->fatal( 'backend-fail-move', $params['src'], $params['dst'] );
                        Severity: Major
                        Found in includes/libs/filebackend/FSFileBackend.php and 1 other location - About 3 hrs to fix
                        includes/libs/filebackend/FSFileBackend.php on lines 358..394

                        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 152.

                        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

                                    if ( $srcHandle ) {
                                        $stageHandle = fopen( $fsStagePath, 'xb' );
                                        if ( $stageHandle ) {
                                            $bytes = stream_copy_to_stream( $srcHandle, $stageHandle );
                                            $stored = ( $bytes !== false && $bytes === fstat( $srcHandle )['size'] );
                        Severity: Major
                        Found in includes/libs/filebackend/FSFileBackend.php and 1 other location - About 2 hrs to fix
                        includes/libs/filebackend/FSFileBackend.php on lines 375..384

                        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 123.

                        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

                                    if ( $srcHandle ) {
                                        $stageHandle = fopen( $fsStagePath, 'xb' );
                                        if ( $stageHandle ) {
                                            $bytes = stream_copy_to_stream( $srcHandle, $stageHandle );
                                            $copied = ( $bytes !== false && $bytes === fstat( $srcHandle )['size'] );
                        Severity: Major
                        Found in includes/libs/filebackend/FSFileBackend.php and 1 other location - About 2 hrs to fix
                        includes/libs/filebackend/FSFileBackend.php on lines 313..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 123.

                        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 ( $errors, StatusValue $status, array $params, $cmd ) {
                                        if ( $errors !== '' && !( $this->os === 'Windows' && $errors[0] === " " ) ) {
                                            $status->fatal( 'backend-fail-create', $params['dst'] );
                                            trigger_error( "$cmd\n$errors", E_USER_WARNING ); // command output
                                        }
                        Severity: Minor
                        Found in includes/libs/filebackend/FSFileBackend.php and 1 other location - About 1 hr to fix
                        includes/libs/filebackend/FSFileBackend.php on lines 462..467

                        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 100.

                        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 ( $errors, StatusValue $status, array $params, $cmd ) {
                                        if ( $errors !== '' && !( $this->os === 'Windows' && $errors[0] === " " ) ) {
                                            $status->fatal( 'backend-fail-delete', $params['src'] );
                                            trigger_error( "$cmd\n$errors", E_USER_WARNING ); // command output
                                        }
                        Severity: Minor
                        Found in includes/libs/filebackend/FSFileBackend.php and 1 other location - About 1 hr to fix
                        includes/libs/filebackend/FSFileBackend.php on lines 245..250

                        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 100.

                        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