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
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 ) {
- Read upRead up
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 ) {
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';
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;
}
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 ) ) {
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 ) ) {
- Read upRead up
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 ) {
- Read upRead up
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;
}
- Read upRead up
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
- Read upRead up
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 ) ) {
- Read upRead up
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"