wikimedia/mediawiki-core

View on GitHub
includes/libs/rdbms/platform/SQLPlatform.php

Summary

Maintainability
F
1 wk
Test Coverage

File SQLPlatform.php has 1252 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: Major
Found in includes/libs/rdbms/platform/SQLPlatform.php - About 3 days to fix

    SQLPlatform has 99 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SQLPlatform implements ISQLPlatform {
        /** @var array[] Current map of (table => (dbname, schema, prefix) map) */
        protected $tableAliases = [];
        /** @var string[] Current map of (index alias => index) */
        protected $indexAliases = [];
    Severity: Major
    Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 day to fix

      Function makeList has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
      Open

          public function makeList( array $a, $mode = self::LIST_COMMA ) {
              $first = true;
              $list = '';
      
              foreach ( $a as $field => $value ) {
      Severity: Minor
      Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 day 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 tableNamesWithIndexClauseOrJOIN has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function tableNamesWithIndexClauseOrJOIN(
              $tables,
              $use_index = [],
              $ignore_index = [],
              $join_conds = []
      Severity: Minor
      Found in includes/libs/rdbms/platform/SQLPlatform.php - About 4 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

      Function selectSQLText has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          public function selectSQLText(
              $table, $vars, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
          ) {
              if ( is_array( $table ) ) {
                  $tables = $table;
      Severity: Minor
      Found in includes/libs/rdbms/platform/SQLPlatform.php - About 4 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 selectSQLText has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function selectSQLText(
              $table, $vars, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
          ) {
              if ( is_array( $table ) ) {
                  $tables = $table;
      Severity: Major
      Found in includes/libs/rdbms/platform/SQLPlatform.php - About 3 hrs to fix

        Method tableNamesWithIndexClauseOrJOIN has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function tableNamesWithIndexClauseOrJOIN(
                $tables,
                $use_index = [],
                $ignore_index = [],
                $join_conds = []
        Severity: Major
        Found in includes/libs/rdbms/platform/SQLPlatform.php - About 2 hrs to fix

          Method makeList has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function makeList( array $a, $mode = self::LIST_COMMA ) {
                  $first = true;
                  $list = '';
          
                  foreach ( $a as $field => $value ) {
          Severity: Major
          Found in includes/libs/rdbms/platform/SQLPlatform.php - About 2 hrs to fix

            Function assertValidUpsertSetArray has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                final public function assertValidUpsertSetArray(
                    array $set,
                    array $uniqueKey,
                    array $rows
                ) {
            Severity: Minor
            Found in includes/libs/rdbms/platform/SQLPlatform.php - About 2 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

            Function factorCondsWithCommonFields has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                private function factorCondsWithCommonFields( $condsArray ) {
                    $first = $condsArray[array_key_first( $condsArray )];
                    if ( count( $first ) === 1 ) {
                        // IN clause
                        $field = array_key_first( $first );
            Severity: Minor
            Found in includes/libs/rdbms/platform/SQLPlatform.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 factorCondsWithCommonFields has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function factorCondsWithCommonFields( $condsArray ) {
                    $first = $condsArray[array_key_first( $condsArray )];
                    if ( count( $first ) === 1 ) {
                        // IN clause
                        $field = array_key_first( $first );
            Severity: Minor
            Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 hr to fix

              Function selectFieldsOrOptionsAggregate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function selectFieldsOrOptionsAggregate( $fields, $options ) {
                      foreach ( (array)$options as $key => $value ) {
                          if ( is_string( $key ) ) {
                              if ( preg_match( '/^(?:GROUP BY|HAVING)$/i', $key ) ) {
                                  return true;
              Severity: Minor
              Found in includes/libs/rdbms/platform/SQLPlatform.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 qualifiedTableComponents has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function qualifiedTableComponents( $name ) {
                      $identifiers = $this->extractTableNameComponents( $name );
                      if ( count( $identifiers ) > 3 ) {
                          throw new DBLanguageError( "Too many components in table name '$name'" );
                      }
              Severity: Minor
              Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 hr to fix

                Function makeSelectOptions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function makeSelectOptions( array $options ) {
                        $preLimitTail = $postLimitTail = '';
                        $startOpts = '';
                
                        $noKeyOptions = [];
                Severity: Minor
                Found in includes/libs/rdbms/platform/SQLPlatform.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 makeSelectOptions has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function makeSelectOptions( array $options ) {
                        $preLimitTail = $postLimitTail = '';
                        $startOpts = '';
                
                        $noKeyOptions = [];
                Severity: Minor
                Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                                  if ( isset( $m[1] ) && $m[1] !== '' ) {
                                      if ( $m[1] === 'i' ) {
                                          return $this->indexName( $m[2] );
                                      } else {
                                          return $this->tableName( $m[2] );
                  Severity: Critical
                  Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 hr to fix

                    Function buildSuperlative has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function buildSuperlative( $sqlfunc, $fields, $values ) {
                            $fields = is_array( $fields ) ? $fields : [ $fields ];
                            $values = is_array( $values ) ? $values : [ $values ];
                    
                            $encValues = [];
                    Severity: Minor
                    Found in includes/libs/rdbms/platform/SQLPlatform.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 assertValidUpsertSetArray has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        final public function assertValidUpsertSetArray(
                            array $set,
                            array $uniqueKey,
                            array $rows
                        ) {
                    Severity: Minor
                    Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 hr to fix

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

                          private function normalizeUpsertKeys( $uniqueKeys ) {
                              if ( is_string( $uniqueKeys ) ) {
                                  return [ $uniqueKeys ];
                              } elseif ( !is_array( $uniqueKeys ) ) {
                                  throw new DBLanguageError( 'Invalid unique key array' );
                      Severity: Minor
                      Found in includes/libs/rdbms/platform/SQLPlatform.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 qualifiedTableComponents has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function qualifiedTableComponents( $name ) {
                              $identifiers = $this->extractTableNameComponents( $name );
                              if ( count( $identifiers ) > 3 ) {
                                  throw new DBLanguageError( "Too many components in table name '$name'" );
                              }
                      Severity: Minor
                      Found in includes/libs/rdbms/platform/SQLPlatform.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 makeKeyCollisionCondition has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function makeKeyCollisionCondition( array $rows, array $uniqueKey ) {
                              if ( !$rows ) {
                                  throw new DBLanguageError( "Empty row array" );
                              } elseif ( !$uniqueKey ) {
                                  throw new DBLanguageError( "Empty unique key array" );
                      Severity: Minor
                      Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 hr to fix

                        Method insertSelectNativeSqlText has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                $destTable,
                                $srcTable,
                                array $varMap,
                                $conds,
                                $fname,
                        Severity: Major
                        Found in includes/libs/rdbms/platform/SQLPlatform.php - About 1 hr to fix

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

                              public function makeKeyCollisionCondition( array $rows, array $uniqueKey ) {
                                  if ( !$rows ) {
                                      throw new DBLanguageError( "Empty row array" );
                                  } elseif ( !$uniqueKey ) {
                                      throw new DBLanguageError( "Empty unique key array" );
                          Severity: Minor
                          Found in includes/libs/rdbms/platform/SQLPlatform.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

                          Method selectSQLText has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  $table, $vars, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
                          Severity: Minor
                          Found in includes/libs/rdbms/platform/SQLPlatform.php - About 45 mins to fix

                            Method buildSelectSubquery has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    $table, $vars, $conds = '', $fname = __METHOD__,
                                    $options = [], $join_conds = []
                            Severity: Minor
                            Found in includes/libs/rdbms/platform/SQLPlatform.php - About 45 mins to fix

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

                                  protected function tableNameWithAlias( $table, $alias = false ) {
                                      if ( is_string( $table ) ) {
                                          $quotedTable = $this->tableName( $table );
                                      } elseif ( $table instanceof Subquery ) {
                                          $quotedTable = (string)$table;
                              Severity: Minor
                              Found in includes/libs/rdbms/platform/SQLPlatform.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 buildComparison has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function buildComparison( string $op, array $conds ): string {
                                      if ( !in_array( $op, [ '>', '>=', '<', '<=' ] ) ) {
                                          throw new InvalidArgumentException( "Comparison operator must be one of '>', '>=', '<', '<='" );
                                      }
                                      if ( count( $conds ) === 0 ) {
                              Severity: Minor
                              Found in includes/libs/rdbms/platform/SQLPlatform.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 ( ( $mode == self::LIST_AND || $mode == self::LIST_OR ) && is_numeric( $field ) ) {
                                              if ( $value instanceof IExpression ) {
                                                  $list .= "(" . $value->toSql( $this->quoter ) . ")";
                                              } else {
                                                  $list .= "($value)";
                              Severity: Major
                              Found in includes/libs/rdbms/platform/SQLPlatform.php - About 40 mins to fix

                                Method buildGroupConcatField has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        $delim, $table, $field, $conds = '', $join_conds = []
                                Severity: Minor
                                Found in includes/libs/rdbms/platform/SQLPlatform.php - About 35 mins to fix

                                  Method deleteJoinSqlText has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      public function deleteJoinSqlText( $delTable, $joinTable, $delVar, $joinVar, $conds ) {
                                  Severity: Minor
                                  Found in includes/libs/rdbms/platform/SQLPlatform.php - About 35 mins to fix

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

                                        private function scrubArray( $array, $listType = self::LIST_AND ) {
                                            if ( is_array( $array ) ) {
                                                $scrubbedArray = [];
                                                foreach ( $array as $key => $value ) {
                                                    if ( $value instanceof IExpression ) {
                                    Severity: Minor
                                    Found in includes/libs/rdbms/platform/SQLPlatform.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 factorConds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function factorConds( $condsArray ) {
                                            if ( count( $condsArray ) === 0 ) {
                                                throw new InvalidArgumentException(
                                                    __METHOD__ . ": empty condition array" );
                                            }
                                    Severity: Minor
                                    Found in includes/libs/rdbms/platform/SQLPlatform.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 normalizeRowArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        final protected function normalizeRowArray( array $rowOrRows ) {
                                            if ( !$rowOrRows ) {
                                                $rows = [];
                                            } elseif ( isset( $rowOrRows[0] ) ) {
                                                $rows = $rowOrRows;
                                    Severity: Minor
                                    Found in includes/libs/rdbms/platform/SQLPlatform.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 updateSqlText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function updateSqlText( $table, $set, $conds, $options ) {
                                            $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 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 assertBuildSubstringParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        protected function assertBuildSubstringParams( $startPosition, $length ) {
                                            if ( $startPosition === 0 ) {
                                                // The DBMSs we support use 1-based indexing here.
                                                throw new InvalidArgumentException( 'Use 1 as $startPosition for the beginning of the string' );
                                            }
                                    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 makeInsertLists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function makeInsertLists( array $rows, $aliasPrefix = '', array $typeByColumn = [] ) {
                                            $firstRow = $rows[0];
                                            if ( !is_array( $firstRow ) || !$firstRow ) {
                                                throw new DBLanguageError( 'Got an empty row list or empty row' );
                                            }
                                    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 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 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 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

                                    There are no issues that match your filters.

                                    Category
                                    Status