Function getColumns
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getColumns($tableName) {
//echo PHP_EOL . 'table: ' . $tableName . PHP_EOL;
$res = $this->database
->select()
->select('c.column_name, c.is_nullable, c.data_type, c.column_default, tc.constraint_type')
- 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 getColumns
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getColumns($tableName) {
//echo PHP_EOL . 'table: ' . $tableName . PHP_EOL;
$res = $this->database
->select()
->select('c.column_name, c.is_nullable, c.data_type, c.column_default, tc.constraint_type')
Method readIndexes
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readIndexes(Table $def) {
$res = $this->database->select()
->select('t.relname as table_name, i.relname as index_name, a.attname as column_name')
->select('ix.indisunique::int as is_unique,ix.indisprimary::int as is_primary')
->from('pg_class t, pg_class i, pg_index ix, pg_attribute a')
Method readForeignKeys
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readForeignKeys(Table $def) {
$res = $this->database
->select()
->select('tc.constraint_name, kcu.column_name')
->select('ccu.table_name AS foreign_table_name, ccu.column_name AS foreign_column_name')
Method getColumnFlagsByString
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getColumnFlagsByString($typeString) {
$phpType = Column::AUTO_TYPE;
switch (true) {
case 'integer' === substr($typeString, 0, 7):
Function readIndexes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function readIndexes(Table $def) {
$res = $this->database->select()
->select('t.relname as table_name, i.relname as index_name, a.attname as column_name')
->select('ix.indisunique::int as is_unique,ix.indisprimary::int as is_primary')
->from('pg_class t, pg_class i, pg_index ix, pg_attribute a')
- 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 deeply nested control flow statements. Open
if ("'" === $default[0]) {
$pos = strrpos($default, "'::");
if ($pos !== false) {
$default = substr($default, 1, $pos - 1);
}
Function getColumnFlagsByString
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getColumnFlagsByString($typeString) {
$phpType = Column::AUTO_TYPE;
switch (true) {
case 'integer' === substr($typeString, 0, 7):
- 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"