File DatabasePostgres.php
has 789 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
DatabasePostgres
has 56 functions (exceeds 20 allowed). Consider refactoring. Open
class DatabasePostgres extends Database {
/** @var int */
private $port;
/** @var string */
private $tempSchema;
Method indexAttributes
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexAttributes( $index, $schema = false ) {
if ( $schema === false ) {
$schemas = $this->getCoreSchemas();
} else {
$schemas = [ $schema ];
Method open
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function open( $server, $user, $password, $db, $schema, $tablePrefix ) {
if ( !function_exists( 'pg_connect' ) ) {
throw $this->newExceptionAfterConnectError(
"Postgres functions missing, have you compiled PHP with the --with-pgsql\n" .
"option? (Note: if you recently installed PHP, you may need to restart your\n" .
Method duplicateTableStructure
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function duplicateTableStructure(
$oldName, $newName, $temporary = false, $fname = __METHOD__
) {
$newNameE = $this->platform->addIdentifierQuotes( $newName );
$oldNameE = $this->platform->addIdentifierQuotes( $oldName );
Function getInsertIdColumnForUpsert
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function getInsertIdColumnForUpsert( $table ) {
$column = null;
$flags = self::QUERY_IGNORE_DBO_TRX | self::QUERY_CHANGE_NONE;
$encTable = $this->addQuotes( $this->tableName( $table, 'raw' ) );
- 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 open
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function open( $server, $user, $password, $db, $schema, $tablePrefix ) {
if ( !function_exists( 'pg_connect' ) ) {
throw $this->newExceptionAfterConnectError(
"Postgres functions missing, have you compiled PHP with the --with-pgsql\n" .
"option? (Note: if you recently installed PHP, you may need to restart your\n" .
- 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 getInsertIdColumnForUpsert
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getInsertIdColumnForUpsert( $table ) {
$column = null;
$flags = self::QUERY_IGNORE_DBO_TRX | self::QUERY_CHANGE_NONE;
$encTable = $this->addQuotes( $this->tableName( $table, 'raw' ) );
Method relationExists
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function relationExists( $table, $types, $schema = false ) {
if ( !is_array( $types ) ) {
$types = [ $types ];
}
if ( $schema === false ) {
Method doInsertSelectNative
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$destTable,
$srcTable,
array $varMap,
$conds,
$fname,
Function indexAttributes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function indexAttributes( $index, $schema = false ) {
if ( $schema === false ) {
$schemas = $this->getCoreSchemas();
} else {
$schemas = [ $schema ];
- 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 addQuotes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function addQuotes( $s ) {
$conn = $this->getBindingHandle();
if ( $s === null ) {
return 'NULL';
- 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 estimateRowCount
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function estimateRowCount( $table, $var = '*', $conds = '',
$fname = __METHOD__, $options = [], $join_conds = []
Method open
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function open( $server, $user, $password, $db, $schema, $tablePrefix ) {
Function getValueTypesForWithClause
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getValueTypesForWithClause( $table ) {
$typesByColumn = [];
$flags = self::QUERY_IGNORE_DBO_TRX | self::QUERY_CHANGE_NONE;
$encTable = $this->addQuotes( $table );
- 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 relationExists
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function relationExists( $table, $types, $schema = false ) {
if ( !is_array( $types ) ) {
$types = [ $types ];
}
if ( $schema === 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
Avoid too many return
statements within this method. Open
return 'DEFAULT';
Avoid too many return
statements within this method. Open
return "'" . pg_escape_string( $conn, (string)$s ) . "'";
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 = [];
}
- 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 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(
- 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"