Function getDefinitionFromTable
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
public function getDefinitionFromTable($table, $resolve_fk = true)
{
$collumns_a = $this->getTableRawDescription($table);
if (!$collumns_a) {
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
Method getDefinitionFromTable
has 103 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDefinitionFromTable($table, $resolve_fk = true)
{
$collumns_a = $this->getTableRawDescription($table);
if (!$collumns_a) {
return false;
File TableUtility.php
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* PepisCMS
*
Function getManyToManyRelationshipsRelatedToTable
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function getManyToManyRelationshipsRelatedToTable($table)
{
$related_foreign_keys = $this->getForeignKeysRelatedToTable($table);
$many_to_many_fks = array();
- 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
Consider simplifying this complex logical expression. Open
if (strpos($field_name, 'color') !== false || strpos($field_name, 'colour') !== false) {
$input_type = FormBuilder::COLORPICKER;
} elseif (strpos($field_name, 'path') !== false || strpos($field_name, 'image') !== false || strpos($field_name, 'file') !== false || strpos($field_name, 'icon') !== false || strpos($field_name, 'logo') !== false || strpos($field_name, 'baner') !== false || strpos($field_name, 'thumb') !== false || strpos($field_name, 'img') !== false) {
$input_type = FormBuilder::FILE;
$definition[$field_name]['upload_path'] = 'uploads/';
Function getTableLabelFieldName
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getTableLabelFieldName($table, $exclude_field_names = array())
{
// Try from set of possible labels
$allowed_labels = array('name', 'label', 'username', 'login', 'fitst_name', 'last_name', 'code', 'id');
$fk_table_definition = $this->getDefinitionFromTable($table, 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
Method getManyToManyRelationshipsRelatedToTable
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getManyToManyRelationshipsRelatedToTable($table)
{
$related_foreign_keys = $this->getForeignKeysRelatedToTable($table);
$many_to_many_fks = array();
Method orderFieldsByImportance
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function orderFieldsByImportance($definition)
{
$order = array(
FormBuilder::TEXTFIELD,
FormBuilder::PASSWORD,
Function getInputType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getInputType($type, $field_name)
{
if ($type == 'smallint') {
return FormBuilder::CHECKBOX;
} elseif (self::isDbTypeNumeric($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
Avoid too many return
statements within this method. Open
return FormBuilder::TIMESTAMP;
Avoid too many return
statements within this method. Open
return FormBuilder::PASSWORD;
Avoid too many return
statements within this method. Open
return FormBuilder::TEXTFIELD;
Function getForeignKeys
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getForeignKeys()
{
if ($this->foreign_keys_cache === null) {
$query = $this->db_instance->query('SELECT table_name, column_name, referenced_table_name, referenced_column_name from information_schema.key_column_usage where referenced_table_name is not null');
$foreign_keys_a = $query->result_array();
- 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 getForeignKeysRelatedToTable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getForeignKeysRelatedToTable($table)
{
$related_foreign_keys = array();
$fks = $this->getForeignKeys();
- 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"