wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    final protected function assertValidUpsertRowArray( array $rows, array $uniqueKey ) {
        foreach ( $rows as $row ) {
            foreach ( $uniqueKey as $column ) {
                if ( !isset( $row[$column] ) ) {
                    throw new DBLanguageError(
Severity: Minor
Found in includes/libs/rdbms/platform/SQLPlatform.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 shutdown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function shutdown(
        $flags = self::SHUTDOWN_NORMAL,
        callable $workCallback = null,
        &$cpIndex = null,
        &$cpClientId = null
Severity: Minor
Found in includes/libs/rdbms/lbfactory/LBFactory.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 commit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public function commit( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
        static $modes = [ self::FLUSHING_ONE, self::FLUSHING_ALL_PEERS, self::FLUSHING_INTERNAL ];
        if ( !in_array( $flush, $modes, true ) ) {
            throw new DBUnexpectedError( $this, "$fname: invalid flush parameter '$flush'" );
        }
Severity: Minor
Found in includes/libs/rdbms/database/Database.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 addQuotes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function addQuotes( $s ) {
        if ( $s instanceof RawSQLValue ) {
            return $s->toSql();
        }
        if ( $s instanceof Blob ) {
Severity: Minor
Found in includes/libs/rdbms/database/Database.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 doFetchRow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doFetchRow() {
        // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
        $row = @pg_fetch_array( $this->result );
        // Map boolean values (T352229)
        if ( is_array( $row ) ) {
Severity: Minor
Found in includes/libs/rdbms/database/resultwrapper/PostgresResultWrapper.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 setField has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setField( $key, $field, $value, $initRank = self::RANK_TOP ) {
        if ( $this->has( $key ) ) {
            $this->ping( $key );

            if ( !is_array( $this->cache[$key] ) ) {
Severity: Minor
Found in includes/libs/MapCacheLRU.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( array $conf ) {
        parent::__construct( $conf );

        $this->mainServers = $conf['servers'] ?? [];
        foreach ( ( $conf['externalClusters'] ?? [] ) as $cluster => $servers ) {
Severity: Minor
Found in includes/libs/rdbms/lbfactory/LBFactorySimple.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 modifyCallbacksForCancel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function modifyCallbacksForCancel(
        array $excisedSectionsId,
        AtomicSectionIdentifier $newSectionId = null
    ) {
        // Cancel the "on commit" callbacks owned by this savepoint
Severity: Minor
Found in includes/libs/rdbms/database/TransactionManager.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 setLBInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setLBInfo( $nameOrArray, $value = null ) {
        if ( is_array( $nameOrArray ) ) {
            $this->lbInfo = $nameOrArray;
        } elseif ( is_string( $nameOrArray ) ) {
            if ( $value !== null ) {
Severity: Minor
Found in includes/libs/rdbms/database/Database.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 doFetchObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doFetchObject() {
        // pg_fetch_object may raise a warning after a seek to an invalid offset
        // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
        $row = @pg_fetch_object( $this->result );
        // Map boolean values (T352229)
Severity: Minor
Found in includes/libs/rdbms/database/resultwrapper/PostgresResultWrapper.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 ensureConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function ensureConnection() {
        if ( $this->modCountFix !== $this->modCountRef ) {
            // Discard existing connection, unless we are in an ongoing transaction.
            // This is triggered by LoadBalancer::reconfigure(), to allow changed settings
            // to take effect. The primary use case are replica servers being taken out of
Severity: Minor
Found in includes/libs/rdbms/database/DBConnRef.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 extractSingleFieldFromList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public function extractSingleFieldFromList( $var ) {
        if ( is_array( $var ) ) {
            if ( !$var ) {
                $column = null;
            } elseif ( count( $var ) == 1 ) {
Severity: Minor
Found in includes/libs/rdbms/platform/SQLPlatform.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 logIfMultiDbTransaction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function logIfMultiDbTransaction() {
        $callersByDB = [];
        foreach ( $this->getLBsForOwner() as $lb ) {
            $primaryName = $lb->getServerName( ServerInfo::WRITER_INDEX );
            $callers = $lb->pendingPrimaryChangeCallers();
Severity: Minor
Found in includes/libs/rdbms/lbfactory/LBFactory.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 deleteSqlText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function deleteSqlText( $table, $conds ) {
        $isCondValid = ( is_string( $conds ) || is_array( $conds ) ) && $conds;
        if ( !$isCondValid ) {
            throw new DBLanguageError( __METHOD__ . ' called with empty conditions' );
        }
Severity: Minor
Found in includes/libs/rdbms/platform/SQLPlatform.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 extractTableNameComponents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function extractTableNameComponents( string $name ) {
        $quoteChar = $this->getIdentifierQuoteChar();
        $components = [];
        foreach ( explode( '.', $name ) as $component ) {
            if ( $this->isQuotedIdentifier( $component ) ) {
Severity: Minor
Found in includes/libs/rdbms/platform/SQLPlatform.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 determineCoreSchema has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function determineCoreSchema( $desiredSchema ) {
        if ( $this->trxLevel() ) {
            // We do not want the schema selection to change on ROLLBACK or INSERT SELECT.
            // See https://www.postgresql.org/docs/8.3/sql-set.html
            throw new DBUnexpectedError(
Severity: Minor
Found in includes/libs/rdbms/database/DatabasePostgres.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 orderBy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function orderBy( $fields, $direction = null ) {
        if ( !$this->db->unionSupportsOrderAndLimit() ) {
            return $this;
        }
        if ( $direction === null ) {
Severity: Minor
Found in includes/libs/rdbms/querybuilder/UnionQueryBuilder.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 pg_array_parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function pg_array_parse( $text, &$output, $limit = false, $offset = 1 ) {
        if ( $limit === false ) {
            $limit = strlen( $text ) - 1;
            $output = [];
        }
Severity: Minor
Found in includes/libs/rdbms/database/DatabasePostgres.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 flushSession has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function flushSession( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
        if (
            $flush !== self::FLUSHING_INTERNAL &&
            $flush !== self::FLUSHING_ALL_PEERS &&
            $this->flagsHolder->hasImplicitTrxFlag()
Severity: Minor
Found in includes/libs/rdbms/database/Database.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 normalizeServerMaps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function normalizeServerMaps( array $servers, array &$indexBySrvName = null ) {
        if ( !$servers ) {
            throw new InvalidArgumentException( 'Missing or empty "servers" parameter' );
        }

Severity: Minor
Found in includes/libs/rdbms/ServerInfo.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

Severity
Category
Status
Source
Language