File functions.inc.php
has 913 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
// Purpose collection of little helpers etc.
// Author Lutz Brueckner <irie@gmx.de>
// Copyright (c) 2000-2006 by Lutz Brueckner,
// published under the terms of the GNU General Public Licence v.2,
Function build_coldef
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function build_coldef($idx, $mode = 'create')
{
global $s_coldefs;
if (!isset($s_coldefs[$idx]['name']))
- 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 set_customize_cookie
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function set_customize_cookie($customize)
{
// don't save rubbish if the session is gone
if (empty($customize['color'])) {
- 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 build_coldef
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function build_coldef($idx, $mode = 'create')
{
global $s_coldefs;
if (!isset($s_coldefs[$idx]['name']))
Function build_datatype
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function build_datatype($defs, $type = 'column', $mode = 'create')
{
$datatype = $defs['type'];
$sql = '';
- 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 set_customize_cookie
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function set_customize_cookie($customize)
{
// don't save rubbish if the session is gone
if (empty($customize['color'])) {
Function is_allowed_db
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function is_allowed_db($filename)
{
global $ALLOWED_FILES, $ALLOWED_DIRS;
$cmp_func = (stristr(php_uname(), 'wind') !== false) ? 'strcasecmp' : 'strcmp';
- 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 build_datatype
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function build_datatype($defs, $type = 'column', $mode = 'create')
{
$datatype = $defs['type'];
$sql = '';
Function have_panel_permissions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function have_panel_permissions($user, $pname, $connected = false)
{
if ($connected && !$GLOBALS['s_connected']) {
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 set_customize_settings
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function set_customize_settings($cookie_string)
{
$settings = explode("\n", $cookie_string);
Method get_dependencies
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_dependencies($type, $name, $fname = null)
{
global $dbhandle;
switch ($type) {
Function get_request_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function get_request_data($name, $source = 'POST')
{
if (isset($GLOBALS['_' . $source][$name])) {
if (is_array($GLOBALS['_' . $source][$name])) {
- 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 set_customize_settings
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function set_customize_settings($cookie_string)
{
$settings = explode("\n", $cookie_string);
- 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 get_type_string
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function get_type_string($field)
{
if (in_array($field['type'], array_keys($GLOBALS['s_domains']))) {
$field = $GLOBALS['s_domains'][$field['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
Function column_fk_is_modified
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function column_fk_is_modified($olddef, $coldef)
{
$varnames = array('fk_name', 'on_update', 'on_delete', 'fk_table', 'fk_column');
foreach ($varnames as $name) {
- 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 datatype_is_modified
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function datatype_is_modified($olddef, $coldef)
{
$varnames = array('type', 'size', 'charset', 'prec', 'scale', 'stype', 'segsize');
- 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 ((isset($olddef[$name]) && $olddef[$name] != $coldef[$name])
|| (!isset($coldef[$name]) && !empty($olddef[$name]))
|| (!isset($olddef[$name]) && !empty($coldef[$name]))
) {
Consider simplifying this complex logical expression. Open
if ((isset($olddef[$name]) && $olddef[$name] != $coldef[$name])
|| (!isset($coldef[$name]) && !empty($olddef[$name]))
|| (!isset($olddef[$name]) && !empty($coldef[$name]))
) {
Method isql_execute
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function isql_execute($sql, $user = null, $pw = null, $db = null, $host = null)
Method error_handler
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function error_handler($errno, $errmsg, $file, $line, $errstack)
Function get_language_file
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function get_language_file($path) {
if ($path == null) {
$path = '.' . DIRECTORY_SEPARATOR . 'lang';
}
$fileLang = $path. DIRECTORY_SEPARATOR . (isset($_SESSION['s_cust']['language']) && !empty($_SESSION['s_cust']['language']) && ($_SESSION['s_cust']['language'] != 1) ? $_SESSION['s_cust']['language'] : LANGUAGE).'.inc.php';
- 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 fix_language
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function fix_language()
{
global $ptitle_strings;
foreach (panel_array_names() as $key => $parray) {
- 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 exec_command
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function exec_command($cmd, $parameters, $stderr = false)
{
$is_windows = (stristr(php_uname(), 'wind') == true) ? true : false;
if (($is_windows && !is_file(BINPATH . $cmd . '.exe')) && !is_file(BINPATH . $cmd)) {
- 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 'unknown';
Avoid too many return
statements within this method. Open
return true;
Function get_datatype
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function get_datatype($type, $subtype)
{
$datatypes = get_datatypes(SERVER_FAMILY, SERVER_VERSION);
- 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 set_panel_title
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function set_panel_title($name, $title)
{
foreach (panel_array_names() as $key => $parray) {
global $$parray;
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
function get_tabmenu_top_fixed($page)
{
$menuentries = array('Database' => url_session('database.php'),
'Tables' => url_session('tables.php'),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 225.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
function get_tabmenu($page)
{
$menuentries = array('Database' => url_session('database.php'),
'Tables' => url_session('tables.php'),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 225.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76