wikimedia/mediawiki-core

View on GitHub
includes/libs/filebackend/fileop/FileOp.php

Summary

Maintainability
C
1 day
Test Coverage

FileOp has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class FileOp {
    /** @var FileBackendStore */
    protected $backend;
    /** @var LoggerInterface */
    protected $logger;
Severity: Minor
Found in includes/libs/filebackend/fileop/FileOp.php - About 2 hrs to fix

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

        protected function precheckDestExistence(
            FileStatePredicates $opPredicates,
            $sourceSize,
            $sourceSha1
        ) {
    Severity: Minor
    Found in includes/libs/filebackend/fileop/FileOp.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 __construct has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        final public function __construct(
            FileBackendStore $backend, array $params, LoggerInterface $logger
        ) {
            $this->backend = $backend;
            $this->logger = $logger;
    Severity: Minor
    Found in includes/libs/filebackend/fileop/FileOp.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 precheckDestExistence has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function precheckDestExistence(
            FileStatePredicates $opPredicates,
            $sourceSize,
            $sourceSha1
        ) {
    Severity: Minor
    Found in includes/libs/filebackend/fileop/FileOp.php - About 1 hr to fix

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

          final public function dependsOn( array $deps ) {
              foreach ( $this->storagePathsChanged() as $path ) {
                  if ( isset( $deps['read'][$path] ) || isset( $deps['write'][$path] ) ) {
                      return true; // "output" or "anti" dependency
                  }
      Severity: Minor
      Found in includes/libs/filebackend/fileop/FileOp.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 precheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          final public function precheck( FileStatePredicates $predicates ) {
              if ( $this->state !== self::STATE_NEW ) {
                  return StatusValue::newFatal( 'fileop-fail-state', self::STATE_NEW, $this->state );
              }
              $this->state = self::STATE_CHECKED;
      Severity: Minor
      Found in includes/libs/filebackend/fileop/FileOp.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

      Function attempt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          final public function attempt() {
              if ( $this->state !== self::STATE_CHECKED ) {
                  return StatusValue::newFatal( 'fileop-fail-state', self::STATE_CHECKED, $this->state );
              } elseif ( $this->failed ) { // failed precheck
                  return StatusValue::newFatal( 'fileop-fail-attempt-precheck' );
      Severity: Minor
      Found in includes/libs/filebackend/fileop/FileOp.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

      There are no issues that match your filters.

      Category
      Status