File yf_db.class.php
has 1493 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Database abstraction layer.
*
yf_db
has 99 functions (exceeds 20 allowed). Consider refactoring. Open
class yf_db
{
/** @var string Type of database (default) */
public $DB_TYPE = 'mysql';
/** @var bool Switch caching on/off */
Function connect
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
public function connect($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
{
if (is_array($db_host)) {
$params = $db_host;
$db_host = '';
- 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_data_safe
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function _fix_data_safe($table, $data = [], $extra = [])
{
if ( ! $this->FIX_DATA_SAFE) {
return $data;
}
- 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 query
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public function &query($sql)
{
if ( ! $this->_connected && ! $this->connect()) {
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
Function query_fetch_all
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function query_fetch_all($sql, $key_name = null, $use_cache = true)
{
if ( ! strlen($sql)) {
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 query
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function &query($sql)
{
if ( ! $this->_connected && ! $this->connect()) {
return false;
}
Method connect
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function connect($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
{
if (is_array($db_host)) {
$params = $db_host;
$db_host = '';
Method _fix_data_safe
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _fix_data_safe($table, $data = [], $extra = [])
{
if ( ! $this->FIX_DATA_SAFE) {
return $data;
}
Function query_fetch
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function query_fetch($sql, $use_cache = true, $assoc = true, $return_sql = false)
{
if ( ! strlen($sql)) {
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 query_fetch_all
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function query_fetch_all($sql, $key_name = null, $use_cache = true)
{
if ( ! strlen($sql)) {
return false;
}
Method query_fetch
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function query_fetch($sql, $use_cache = true, $assoc = true, $return_sql = false)
{
if ( ! strlen($sql)) {
return false;
}
Function es
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function es($string)
{
if ($string === null || $string === '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 get_deep_array
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_deep_array($sql, $max_levels = 0, $use_cache = true)
{
if ( ! strlen($sql)) {
return false;
}
Method _save_query_revision
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _save_query_revision($method, $table, $params = [])
{
if (($allowed_methods = $this->QUERY_REVISIONS_METHODS)) {
if ( ! in_array($method, $allowed_methods)) {
return false;
Method insert
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function insert($table, $data, $only_sql = false, $replace = false, $ignore = false, $on_duplicate_key_update = false, $extra = [])
{
if ($this->DB_REPLICATION_SLAVE && ! $only_sql) {
return false;
}
Function insert
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function insert($table, $data, $only_sql = false, $replace = false, $ignore = false, $on_duplicate_key_update = false, $extra = [])
{
if ($this->DB_REPLICATION_SLAVE && ! $only_sql) {
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
Function update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function update($table, $data, $where, $only_sql = false, $extra = [])
{
if ($this->DB_REPLICATION_SLAVE && ! $only_sql) {
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
Function get_deep_array
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get_deep_array($sql, $max_levels = 0, $use_cache = true)
{
if ( ! strlen($sql)) {
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 _model_load
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _model_load($name)
{
$main = main();
$model_class = $name . '_model';
$custom_storages = &$main->_custom_class_storages;
Method _set_connect_params
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _set_connect_params($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
{
if (is_array($db_host)) {
$params = $db_host;
$db_host = '';
Function _model_load
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function _model_load($name)
{
$main = main();
$model_class = $name . '_model';
$custom_storages = &$main->_custom_class_storages;
- 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 update_batch
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function update_batch($table, $data, $index = null, $only_sql = false)
{
if ($this->DB_REPLICATION_SLAVE && ! $only_sql) {
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 insert_safe
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function insert_safe($table, $data, $only_sql = false, $replace = false, $ignore = false, $on_duplicate_key_update = false, $extra = [])
Method insert
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function insert($table, $data, $only_sql = false, $replace = false, $ignore = false, $on_duplicate_key_update = false, $extra = [])
Function _load_tables_with_sys_prefix
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function _load_tables_with_sys_prefix()
{
if ($this->_need_sys_prefix) {
return $this->_need_sys_prefix;
}
- 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_connect_params
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function _set_connect_params($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
Function __construct
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($db_type = '', $db_prefix = null, $db_replication_slave = null)
{
global $DEBUG;
$this->_load_tables_with_sys_prefix();
- 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_2d
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function get_2d($sql, $use_cache = true)
{
if ( ! strlen($sql)) {
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 connect
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function connect($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
Function _init
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function _init()
{
// Perform auto-connection to db if needed
if (($this->AUTO_CONNECT || MAIN_TYPE == 'admin') && ! $this->NO_AUTO_CONNECT) {
$this->connect();
- 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 insert_on_duplicate_key_update
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function insert_on_duplicate_key_update($table, $data, $only_sql = false, $replace = false, $extra = [])
Method update_safe
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function update_safe($table, $data, $where, $only_sql = false, $extra = [])
Method insert_ignore
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function insert_ignore($table, $data, $only_sql = false, $replace = false, $extra = [])
Method _update_query_log
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function _update_query_log($log_id, $result, $query_time_start = 0, $warnings = null, $info = null)
Method update
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function update($table, $data, $where, $only_sql = false, $extra = [])
Function transaction
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function transaction($callback)
{
if ( ! is_callable($callback)) {
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
Avoid too many return
statements within this method. Open
return $this->query($sql);
Avoid too many return
statements within this method. Open
return $this->query($sql);
Avoid too many return
statements within this method. Open
return $data;
Avoid too many return
statements within this method. Open
return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $string);
Avoid too many return
statements within this method. Open
return (int) $string;
Avoid too many return
statements within this method. Open
return $this->query_builder()->update_batch($table, $data, $index, $only_sql, $params);
Function _save_query_revision
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _save_query_revision($method, $table, $params = [])
{
if (($allowed_methods = $this->QUERY_REVISIONS_METHODS)) {
if ( ! in_array($method, $allowed_methods)) {
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
Function _set_connect_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _set_connect_params($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
{
if (is_array($db_host)) {
$params = $db_host;
$db_host = '';
- 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 _execute_shutdown_queries
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _execute_shutdown_queries()
{
if ( ! $this->USE_SHUTDOWN_QUERIES || isset($this->_shutdown_executed)) {
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
Function multi_query
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function multi_query($sql = [])
{
if ( ! $this->_connected && ! $this->connect()) {
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
Function escape_val
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function escape_val($data)
{
if ($data === null || $data === 'NULL') {
return 'NULL';
} elseif (is_array($data)) {
- 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 _real_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _real_name($name)
{
$name = trim($name);
if ( ! strlen($name)) {
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
Function _fix_table_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _fix_table_name($name = '')
{
$name = trim($name);
if ( ! strlen($name)) {
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
Function _mysql_escape_mimic
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _mysql_escape_mimic($string)
{
if (is_array($string)) {
return array_map([$this, __FUNCTION__], $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
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function _trace()
{
$trace = [];
foreach (debug_backtrace() as $k => $v) {
if ( ! $k) {
- 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 102.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($use_cache && $this->ALLOW_CACHE_QUERIES && ! $this->NO_CACHE && ! isset($storage[$sql])) {
$storage[$sql] = $data;
// Permanently turn off queries cache (and free some memory) if case of limit reached
if ($this->CACHE_QUERIES_LIMIT && count((array) $storage) > $this->CACHE_QUERIES_LIMIT) {
$this->ALLOW_CACHE_QUERIES = false;
- 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 90.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($use_cache && $this->ALLOW_CACHE_QUERIES && ! $this->NO_CACHE && ! isset($storage[$sql])) {
$storage[$sql] = $data;
// Permanently turn off queries cache (and free some memory) if case of limit reached
if ($this->CACHE_QUERIES_LIMIT && count((array) $storage) > $this->CACHE_QUERIES_LIMIT) {
$this->ALLOW_CACHE_QUERIES = false;
- 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 90.
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