wikimedia/mediawiki-core

View on GitHub
includes/Storage/SqlBlobStore.php

Summary

Maintainability
F
3 days
Test Coverage

File SqlBlobStore.php has 422 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: Minor
Found in includes/Storage/SqlBlobStore.php - About 6 hrs to fix

    Function fetchBlobs has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        private function fetchBlobs( $blobAddresses, $queryFlags ) {
            $textIdToBlobAddress = [];
            $result = [];
            $errors = [];
            foreach ( $blobAddresses as $blobAddress ) {
    Severity: Minor
    Found in includes/Storage/SqlBlobStore.php - About 5 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 fetchBlobs has 115 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function fetchBlobs( $blobAddresses, $queryFlags ) {
            $textIdToBlobAddress = [];
            $result = [];
            $errors = [];
            foreach ( $blobAddresses as $blobAddress ) {
    Severity: Major
    Found in includes/Storage/SqlBlobStore.php - About 4 hrs to fix

      SqlBlobStore has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SqlBlobStore implements BlobStore {
      
          // Note: the name has been taken unchanged from the old Revision class.
          public const TEXT_CACHE_GROUP = 'revisiontext:10';
      
      
      Severity: Minor
      Found in includes/Storage/SqlBlobStore.php - About 3 hrs to fix

        Method decompressData has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function decompressData( string $blob, array $blobFlags ) {
                if ( in_array( 'error', $blobFlags ) ) {
                    // Error row, return false
                    return false;
                }
        Severity: Minor
        Found in includes/Storage/SqlBlobStore.php - About 1 hr to fix

          Method expandBlob has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function expandBlob( $raw, $flags, $blobAddress = null ) {
                  if ( is_string( $flags ) ) {
                      $flags = self::explodeFlags( $flags );
                  }
                  if ( in_array( 'error', $flags ) ) {
          Severity: Minor
          Found in includes/Storage/SqlBlobStore.php - About 1 hr to fix

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

                public function expandBlob( $raw, $flags, $blobAddress = null ) {
                    if ( is_string( $flags ) ) {
                        $flags = self::explodeFlags( $flags );
                    }
                    if ( in_array( 'error', $flags ) ) {
            Severity: Minor
            Found in includes/Storage/SqlBlobStore.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 storeBlob has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function storeBlob( $data, $hints = [] ) {
                    $flags = $this->compressData( $data );
            
                    # Write to external storage if required
                    if ( $this->useExternalStore ) {
            Severity: Minor
            Found in includes/Storage/SqlBlobStore.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 decompressData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function decompressData( string $blob, array $blobFlags ) {
                    if ( in_array( 'error', $blobFlags ) ) {
                        // Error row, return false
                        return false;
                    }
            Severity: Minor
            Found in includes/Storage/SqlBlobStore.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 compressData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function compressData( &$blob ) {
                    $blobFlags = [];
            
                    // Revisions not marked as UTF-8 will have legacy decoding applied by decompressData().
                    // XXX: if $this->legacyEncoding is not set, we could skip this. That would however be
            Severity: Minor
            Found in includes/Storage/SqlBlobStore.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 getDBOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function getDBOptions( $bitfield ) {
                    if ( DBAccessObjectUtils::hasFlags( $bitfield, IDBAccessObject::READ_LATEST_IMMUTABLE ) ) {
                        $index = DB_REPLICA; // override READ_LATEST if set
                        $fallbackIndex = DB_PRIMARY;
                    } elseif ( DBAccessObjectUtils::hasFlags( $bitfield, IDBAccessObject::READ_LATEST ) ) {
            Severity: Minor
            Found in includes/Storage/SqlBlobStore.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