Showing 4,217 of 4,217 total issues

Function _show_category_contents has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function _show_category_contents($params = [])
    {
        $ICONS_PATH = 'uploads/icons/';
        $MEDIA_PATH = WEB_PATH;
        $force_stpl_name = isset($params['force_stpl_name']) ? $params['force_stpl_name'] : false;
Severity: Minor
Found in plugins/categories/admin_modules/yf_category_editor.class.php - About 2 hrs to fix

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 copy_dir has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function copy_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
    {
        if ( ! $path1 || ! file_exists($path1)) {
            return false;
        }
Severity: Minor
Found in classes/yf_dir.class.php - About 2 hrs to fix

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 my_array_merge has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function my_array_merge($a1, $a2)
    {
        foreach ((array) $a2 as $k => $v) {
            if (isset($a1[$k]) && is_array($a1[$k])) {
                if (is_array($a2[$k])) {
Severity: Minor
Found in classes/yf_utils.class.php - About 2 hrs to fix

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 check has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function check($field_in_form = 'image_numbers', $input = null)
    {
        if ( ! $this->ENABLED) {
            return true;
        }
Severity: Minor
Found in plugins/content/classes/yf_captcha.class.php - About 2 hrs to fix

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 _helper_add_config has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function _helper_add_config($libs = [], $types = ['js', 'css'])
    {
        _class('assets')->clean_all();
        foreach ($libs as $name => $config) {
            foreach ($types as $type) {
Severity: Minor
Found in .dev/tests/unit/class_assets_test.Test.php - About 2 hrs to fix

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 import_base_db_structure has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function import_base_db_structure()
    {
        $import_tables = [
            'dashboards',
            'static_pages',
Severity: Minor
Found in .dev/install/install.php - About 2 hrs to fix

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 test_25()
    {
        debug([
            'key1' => 'val1',
            'key2::sub1' => 'val21',
Severity: Major
Found in .dev/tests/unit/functions/function_debug_test.php and 1 other location - About 2 hrs to fix
.dev/tests/unit/functions/function_conf_test.Test.php on lines 47..76

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 133.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function test_15()
    {
        conf([
            'key1' => 'val1',
            'key2::sub1' => 'val21',
Severity: Major
Found in .dev/tests/unit/functions/function_conf_test.Test.php and 1 other location - About 2 hrs to fix
.dev/tests/unit/functions/function_debug_test.php on lines 45..74

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 133.

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

Further Reading

File yf_core_api_admin_modules.class.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php


class yf_core_api_admin_modules
{
Severity: Minor
Found in plugins/sys/classes/core_api/yf_core_api_admin_modules.class.php - About 2 hrs to fix

    File yf_pcntl_signal.class.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * pcntl_signal handler
     * static class.
    Severity: Minor
    Found in plugins/sys/classes/yf_pcntl_signal.class.php - About 2 hrs to fix

      File yf_common_num2string.class.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      
      class yf_common_num2string
      {
      Severity: Minor
      Found in plugins/common/classes/common/yf_common_num2string.class.php - About 2 hrs to fix

        Method select_box has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function select_box($name, $values = [], $selected = '', $show_text = false, $type = 2, $add_str = '', $translate = 0, $level = 0)
            {
                // Passing params as array
                if (is_array($name)) {
                    $extra = (array) $extra + $name;
        Severity: Major
        Found in plugins/html/classes/yf_html.class.php - About 2 hrs to fix

          Method balance has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function balance($options)
              {
                  if (empty(main()->USER_ID)) {
                      js_redirect('/login_form', false, 'User id empty');
                  }
          Severity: Major
          Found in plugins/payment/modules/yf_payment/yf_payment__user.class.php - About 2 hrs to fix

            Method authorize_request has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function authorize_request($options = null)
                {
                    if ( ! $this->ENABLE) {
                        return  null;
                    }

              Method _api_authorize has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function _api_authorize()
                  {
                      if ( ! $this->ENABLE) {
                          return  null;
                      }

                Method _update_status has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function _update_status($options = null)
                    {
                        if ( ! $this->ENABLE) {
                            return  null;
                        }
                Severity: Major
                Found in plugins/payment/classes/yf_payment_api__provider_remote.class.php - About 2 hrs to fix

                  Method _replace_std_patterns has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function _replace_std_patterns($string, $name = '', array &$replace, $params = [])
                      {
                          $_this = $this;
                          $tpl = tpl();
                  
                  
                  Severity: Major
                  Found in plugins/tpl/classes/tpl/yf_tpl_driver_yf.class.php - About 2 hrs to fix

                    Method table_get_columns has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function table_get_columns($table, $extra = [], &$error = false)
                        {
                            if (is_array($table)) {
                                $extra = (array) $extra + $table;
                                $table = '';
                    Severity: Major
                    Found in plugins/db/classes/db/yf_db_utils_driver.class.php - About 2 hrs to fix

                      Method allow has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function allow()
                          {
                              if ( ! $this->LOGGING || MAIN_TYPE_ADMIN) {
                                  return false;
                              }
                      Severity: Major
                      Found in plugins/logs/classes/logs/yf_logs_exec_user.class.php - About 2 hrs to fix

                        Method _data has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function _data()
                            {
                                $_class_price = $this->_class_price;
                                // init sql
                                $sql_table = db('shop_products');
                          Severity
                          Category
                          Status
                          Source
                          Language