File yf_common.class.php
has 1115 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Class where most common used functions are stored.
*
yf_common
has 143 functions (exceeds 20 allowed). Consider refactoring. Open
class yf_common
{
/** @var bool Store user-level errors */
public $TRACK_USER_ERRORS = false;
/** @var bool Display debug info for the empty page */
Function _get_time_diff_human
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function _get_time_diff_human($seconds, $delimiter = ' ', $need_return = false, $only_text = false, $need_closing_tag = false)
{
$d = [];
$tr = [
'years' => ['лет', 'год', 'года'],
- 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_time_diff_human
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _get_time_diff_human($seconds, $delimiter = ' ', $need_return = false, $only_text = false, $need_closing_tag = false)
{
$d = [];
$tr = [
'years' => ['лет', 'год', 'года'],
Function add_get_vars
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function add_get_vars($add_skip = [])
{
// Cache it
if (isset($this->_get_vars_cache)) {
return $this->_get_vars_cache;
- 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 send_mail
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
public function send_mail($email_from, $name_from = '', $email_to = '', $name_to = '', $subject = '', $text = '', $html = '', $attaches = [], $charset = '', $old_param1 = '', $force_mta_opts = [], $priority = null, $smtp = [])
Function _show_error_message
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function _show_error_message($cur_error_msg = '', $clear_error = true)
{
// Prevent recursive display
if (strlen($cur_error_msg) && false !== strpos($cur_error_msg, '<!--YF_ERROR_MESSAGE_START-->')) {
return t($cur_error_msg);
- 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 bs_get_avail_themes
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function bs_get_avail_themes($css_fw = '')
{
if ( ! $css_fw) {
$css_fw = conf('css_framework');
}
Method _show_error_message
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _show_error_message($cur_error_msg = '', $clear_error = true)
{
// Prevent recursive display
if (strlen($cur_error_msg) && false !== strpos($cur_error_msg, '<!--YF_ERROR_MESSAGE_START-->')) {
return t($cur_error_msg);
Function bs_current_theme
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function bs_current_theme($main_type = '', $force = false)
{
if ( ! $main_type) {
$main_type = MAIN_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 bs_current_theme
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function bs_current_theme($main_type = '', $force = false)
{
if ( ! $main_type) {
$main_type = MAIN_TYPE;
}
Method multi_select
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
public function multi_select($name, $values = [], $selected = '', $show_text = false, $type = 2, $add_str = '', $translate = 0, $level = 0, $disabled = false)
Method multi_select_box
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
public function multi_select_box($name, $values = [], $selected = '', $show_text = false, $type = 2, $add_str = '', $translate = 0, $level = 0, $disabled = false)
Method css_class_body
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function css_class_body($extra = [])
{
if ( ! is_array($extra)) {
$extra = [];
}
Method select_box
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public function select_box($name, $values = [], $selected = '', $show_text = true, $type = 2, $add_str = '', $translate = 0, $level = 0)
Method multi_check_box
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public function multi_check_box($box_name, $values = [], $selected = [], $horizontal = true, $type = 2, $add_str = '', $translate = 0, $name_as_array = false)
Method divide_pages
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public function divide_pages($sql = '', $url_path = '', $render_type = '', $records_on_page = 0, $num_records = 0, $tpls_path = '', $add_get_vars = 1, $extra = [])
Function divide_pages
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function divide_pages($sql = '', $url_path = '', $render_type = '', $records_on_page = 0, $num_records = 0, $tpls_path = '', $add_get_vars = 1, $extra = [])
{
if (is_array($sql)) {
$sql_is_array = true;
} elseif (is_callable($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
Function _ip_is_banned
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function _ip_is_banned($CUR_IP = '')
{
if ( ! $CUR_IP) {
$CUR_IP = common()->get_ip();
}
- 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 date_box2
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function date_box2($name = '', $selected = '', $range = '', $add_str = '', $show_what = 'ymd', $show_text = 1, $translate = 1)
Method datetime_box2
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function datetime_box2($name = '', $selected = '', $range = '', $add_str = '', $show_what = 'ymdhis', $show_text = 1, $translate = 1)
Method date_box
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function date_box($selected_date = '', $years = '', $name_postfix = '', $add_str = '', $order = 'ymd', $show_text = 1, $translate = 1)
Method radio_box
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function radio_box($box_name, $values = [], $selected = '', $horizontal = true, $type = 2, $add_str = '', $translate = 0)
Method crop_image
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function crop_image($source_file_path, $dest_file_path, $LIMIT_X, $LIMIT_Y, $pos_left, $pos_top)
Method make_thumb
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function make_thumb($source_file_path = '', $dest_file_path = '', $LIMIT_X = -1, $LIMIT_Y = -1, $watermark_path = '', $ext = '')
Method redirect
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function redirect($location, $rewrite = true, $redirect_type = 'js', $text = '', $ttl = 3)
Method http_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function http_request($url, $headers = [], $method = 'GET', $data = null, $retry = 3)
Method time_box
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function time_box($selected_time = '', $name_postfix = '', $add_str = '', $show_text = 1, $translate = 1)
Method time_box2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function time_box2($name = '', $selected = '', $add_str = '', $show_text = 1, $translate = 1)
Method multi_upload_image
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function multi_upload_image($new_file_path, $k, $name_in_form = 'image', $max_image_size = 0, $is_local = false)
Method _get_time_diff_human
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function _get_time_diff_human($seconds, $delimiter = ' ', $need_return = false, $only_text = false, $need_closing_tag = false)
Function format_time
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function format_time($timestamp, $accuracy = 'second')
{
$timestamp = (int) $timestamp;
if ($timestamp == 0) {
return 0;
- 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 error_404
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function error_404($msg = '')
{
if ((MAIN_TYPE_ADMIN && is_logged_in()) || DEBUG_MODE) {
// Do not override status header for logged in admin, just display error inlined
! $msg && $msg = t('404 Not Found');
- 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 show_messages
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function show_messages()
{
if ( ! $this->is_messages()) {
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 error_403
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function error_403($msg = '')
{
if ((MAIN_TYPE_ADMIN && is_logged_in()) || DEBUG_MODE) {
// Do not override status header for logged in admin, just display error inlined
! $msg && $msg = t('403 Forbidden');
- 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 bs_get_avail_themes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function bs_get_avail_themes($css_fw = '')
{
if ( ! $css_fw) {
$css_fw = conf('css_framework');
}
- 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 error_404($msg = '')
{
if ((MAIN_TYPE_ADMIN && is_logged_in()) || DEBUG_MODE) {
// Do not override status header for logged in admin, just display error inlined
! $msg && $msg = t('404 Not Found');
- 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 209.
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
public function error_403($msg = '')
{
if ((MAIN_TYPE_ADMIN && is_logged_in()) || DEBUG_MODE) {
// Do not override status header for logged in admin, just display error inlined
! $msg && $msg = t('403 Forbidden');
- 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 209.
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
public function multi_select_box($name, $values = [], $selected = '', $show_text = false, $type = 2, $add_str = '', $translate = 0, $level = 0, $disabled = false)
{
return $this->multi_select($name, $values, $selected, $show_text, $type, $add_str, $translate, $level, $disabled);
}
- 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 96.
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