wikimedia/mediawiki-core

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

Summary

Maintainability
D
2 days
Test Coverage

FileBackend has 81 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class FileBackend implements LoggerAwareInterface {
    /** @var string Unique backend name */
    protected $name;

    /** @var string Unique domain name */
Severity: Major
Found in includes/libs/filebackend/FileBackend.php - About 1 day to fix

    File FileBackend.php has 397 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @defgroup FileBackend File backend
     *
     * File backend is used to interact with file storage systems,
    Severity: Minor
    Found in includes/libs/filebackend/FileBackend.php - About 5 hrs to fix

      Method __construct has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct( array $config ) {
              if ( !array_key_exists( 'name', $config ) ) {
                  throw new InvalidArgumentException( 'Backend name not specified.' );
              }
              $this->name = $config['name'];
      Severity: Minor
      Found in includes/libs/filebackend/FileBackend.php - About 1 hr to fix

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

            final public static function splitStoragePath( $storagePath ) {
                if ( self::isStoragePath( $storagePath ) ) {
                    // Remove the "mwstore://" prefix and split the path
                    $parts = explode( '/', substr( $storagePath, 10 ), 3 );
                    if ( count( $parts ) >= 2 && $parts[0] != '' && $parts[1] != '' ) {
        Severity: Minor
        Found in includes/libs/filebackend/FileBackend.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

        Consider simplifying this complex logical expression.
        Open

                    if (
                        $path === '.' ||
                        $path === '..' ||
                        strpos( $path, './' ) === 0 ||
                        strpos( $path, '../' ) === 0 ||
        Severity: Major
        Found in includes/libs/filebackend/FileBackend.php - About 40 mins to fix

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

              public function __construct( array $config ) {
                  if ( !array_key_exists( 'name', $config ) ) {
                      throw new InvalidArgumentException( 'Backend name not specified.' );
                  }
                  $this->name = $config['name'];
          Severity: Minor
          Found in includes/libs/filebackend/FileBackend.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

          There are no issues that match your filters.

          Category
          Status