plugins/sys/classes/yf_core_menu.class.php

Summary

Maintainability
F
5 days
Test Coverage

Function _recursive_get_menu_items has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

    public function _recursive_get_menu_items($menu_id = 0, $skip_item_id = 0)
    {
        if (empty($menu_id) || empty($this->_menu_items[$menu_id])) {
            return false;
        }
Severity: Minor
Found in plugins/sys/classes/yf_core_menu.class.php - About 7 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 _cleanup_menu_items has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    public function _cleanup_menu_items($menu_items = [])
    {
        $center_block_id = _class('graphics')->_get_center_block_id();

        $out = [];
Severity: Minor
Found in plugins/sys/classes/yf_core_menu.class.php - About 6 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

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

<?php

/**
 * Menu API methods.
 *
Severity: Minor
Found in plugins/sys/classes/yf_core_menu.class.php - About 5 hrs to fix

    Method _show_menu has 107 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function _show_menu($params = [])
        {
            $return_array = isset($params['return_array']) ? $params['return_array'] : false;
            $force_stpl_name = isset($params['force_stpl_name']) ? $params['force_stpl_name'] : false;
            $menu_name = $params['name'];
    Severity: Major
    Found in plugins/sys/classes/yf_core_menu.class.php - About 4 hrs to fix

      Function _show_menu has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _show_menu($params = [])
          {
              $return_array = isset($params['return_array']) ? $params['return_array'] : false;
              $force_stpl_name = isset($params['force_stpl_name']) ? $params['force_stpl_name'] : false;
              $menu_name = $params['name'];
      Severity: Minor
      Found in plugins/sys/classes/yf_core_menu.class.php - About 3 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 _is_current_page has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _is_current_page($item)
          {
              $object = $_GET['object'];
              $action = $_GET['action'];
              $id = $_GET['id'];
      Severity: Minor
      Found in plugins/sys/classes/yf_core_menu.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 _apply_custom_fields has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _apply_custom_fields($cur_menu_info, $menu_items)
          {
              $custom_fields = [];
              if ($cur_menu_info['custom_fields']) {
                  foreach (explode(',', str_replace(';', ',', trim($cur_menu_info['custom_fields']))) as $f) {
      Severity: Minor
      Found in plugins/sys/classes/yf_core_menu.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

      Method _recursive_get_menu_items has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function _recursive_get_menu_items($menu_id = 0, $skip_item_id = 0)
          {
              if (empty($menu_id) || empty($this->_menu_items[$menu_id])) {
                  return false;
              }
      Severity: Major
      Found in plugins/sys/classes/yf_core_menu.class.php - About 2 hrs to fix

        Method _cleanup_menu_items has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function _cleanup_menu_items($menu_items = [])
            {
                $center_block_id = _class('graphics')->_get_center_block_id();
        
                $out = [];
        Severity: Minor
        Found in plugins/sys/classes/yf_core_menu.class.php - About 1 hr to fix

          Function _get_cur_menu_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function _get_cur_menu_info($menu_name)
              {
                  if ( ! isset($this->_menus_infos)) {
                      $this->_menus_infos = main()->get_data('menus');
                  }
          Severity: Minor
          Found in plugins/sys/classes/yf_core_menu.class.php - About 1 hr 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

          Method _get_menu_items has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function _get_menu_items($cur_menu_info)
              {
                  $menu_id = $cur_menu_info['id'];
                  $menu_name = $cur_menu_info['name'];
                  if ( ! isset($this->_menu_items)) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_menu.class.php - About 1 hr to fix

            Avoid too many return statements within this method.
            Open

                    return tpl()->parse($stpl_main, [
                        'items' => implode(PHP_EOL, (array) $items),
                    ]);
            Severity: Major
            Found in plugins/sys/classes/yf_core_menu.class.php - About 30 mins to fix

              Function _count_levels has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function _count_levels($start_id = 0, &$children, $level = 0)
                  {
                      $ids = [];
                      foreach ((array) $children[$start_id] as $id => $_tmp) {
                          $ids[$id] = $level;
              Severity: Minor
              Found in plugins/sys/classes/yf_core_menu.class.php - About 25 mins 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 _get_menu_items has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function _get_menu_items($cur_menu_info)
                  {
                      $menu_id = $cur_menu_info['id'];
                      $menu_name = $cur_menu_info['name'];
                      if ( ! isset($this->_menu_items)) {
              Severity: Minor
              Found in plugins/sys/classes/yf_core_menu.class.php - About 25 mins 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

              Identical blocks of code found in 6 locations. Consider refactoring.
              Open

                  public function _count_levels($start_id = 0, &$children, $level = 0)
                  {
                      $ids = [];
                      foreach ((array) $children[$start_id] as $id => $_tmp) {
                          $ids[$id] = $level;
              Severity: Major
              Found in plugins/sys/classes/yf_core_menu.class.php and 5 other locations - About 1 hr to fix
              plugins/categories/admin_modules/yf_category_editor.class.php on lines 540..552
              plugins/categories/classes/yf_cats.class.php on lines 137..149
              plugins/content/admin_modules/yf_manage_faq.class.php on lines 367..379
              plugins/html/classes/yf_html.class.php on lines 104..116
              plugins/sys/admin_modules/yf_menus_editor.class.php on lines 573..585

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

              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

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

                          if ($icon) {
                              // Icon class from bootstrap icon class names
                              if (preg_match('/^icon\-[a-z0-9_-]+$/i', $icon) || (strpos($icon, '.') === false)) {
                                  $icon_class = $icon;
                              } else {
              Severity: Major
              Found in plugins/sys/classes/yf_core_menu.class.php and 2 other locations - About 45 mins to fix
              plugins/categories/admin_modules/yf_category_editor.class.php on lines 431..441
              plugins/sys/admin_modules/yf_menus_editor.class.php on lines 478..488

              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

              Further Reading

              There are no issues that match your filters.

              Category
              Status