plugins/dashboards/admin_modules/yf_manage_dashboards.class.php

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php

/**
 * Dashboards management.
 *
Severity: Minor
Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 7 hrs to fix

    Function _view_widget_items has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _view_widget_items($name_ids = [], $items_configs = [])
        {
            $list_of_hooks = $this->_get_available_widgets_hooks();
    
            $_orig_object = $_GET['object'];
    Severity: Minor
    Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 5 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 _get_available_widgets_hooks has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _get_available_widgets_hooks($for_section = 'admin')
        {
            if ( ! in_array($for_section, ['user', 'admin'])) {
                $for_section = 'admin';
            }
    Severity: Minor
    Found in plugins/dashboards/admin_modules/yf_manage_dashboards.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 _view_widget_items has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function _view_widget_items($name_ids = [], $items_configs = [])
        {
            $list_of_hooks = $this->_get_available_widgets_hooks();
    
            $_orig_object = $_GET['object'];
    Severity: Major
    Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 2 hrs to fix

      Function view has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function view($params = [])
          {
              if ( ! is_array($params)) {
                  $params = [];
              }
      Severity: Minor
      Found in plugins/dashboards/admin_modules/yf_manage_dashboards.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

      yf_manage_dashboards has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class yf_manage_dashboards
      {
          /**
           * Bootstrap CSS classes used to create configurable grid.
           */
      Severity: Minor
      Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 2 hrs to fix

        Method _get_available_widgets_hooks has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function _get_available_widgets_hooks($for_section = 'admin')
            {
                if ( ! in_array($for_section, ['user', 'admin'])) {
                    $for_section = 'admin';
                }
        Severity: Minor
        Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 1 hr to fix

          Function _show_edit_widget_items has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function _show_edit_widget_items($column_items = [], $ds = [])
              {
                  $items_configs = $ds['data']['items_configs'];
                  $ds_settings = $ds['data']['settings'];
          
          
          Severity: Minor
          Found in plugins/dashboards/admin_modules/yf_manage_dashboards.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 view has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function view($params = [])
              {
                  if ( ! is_array($params)) {
                      $params = [];
                  }
          Severity: Minor
          Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 1 hr to fix

            Method edit has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function edit()
                {
                    $ds = $this->_get_dashboard_data($_GET['id']);
                    if ( ! $ds['id']) {
                        return _e('No such record');
            Severity: Minor
            Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 1 hr to fix

              Method _hook_side_column has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function _hook_side_column()
                  {
                      if ($_GET['object'] != 'manage_dashboards' || ! in_array($_GET['action'], ['edit', 'add'])) {
                          return false;
                      }
              Severity: Minor
              Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 1 hr to fix

                Method _show_edit_widget_items has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function _show_edit_widget_items($column_items = [], $ds = [])
                    {
                        $items_configs = $ds['data']['items_configs'];
                        $ds_settings = $ds['data']['settings'];
                
                
                Severity: Minor
                Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 1 hr to fix

                  Function _hook_side_column has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function _hook_side_column()
                      {
                          if ($_GET['object'] != 'manage_dashboards' || ! in_array($_GET['action'], ['edit', 'add'])) {
                              return false;
                          }
                  Severity: Minor
                  Found in plugins/dashboards/admin_modules/yf_manage_dashboards.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 _options_container has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function _options_container($info = [], $saved = [], $ds = [])
                      {
                          $for_section = $ds['type'] == 'user' ? 'user' : 'admin';
                  
                          $a = [];
                  Severity: Minor
                  Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 1 hr to fix

                    Function edit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function edit()
                        {
                            $ds = $this->_get_dashboard_data($_GET['id']);
                            if ( ! $ds['id']) {
                                return _e('No such record');
                    Severity: Minor
                    Found in plugins/dashboards/admin_modules/yf_manage_dashboards.class.php - About 45 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 _options_container has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function _options_container($info = [], $saved = [], $ds = [])
                        {
                            $for_section = $ds['type'] == 'user' ? 'user' : 'admin';
                    
                            $a = [];
                    Severity: Minor
                    Found in plugins/dashboards/admin_modules/yf_manage_dashboards.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

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

                        public function _options_container($info = [], $saved = [], $ds = [])
                        {
                            $for_section = $ds['type'] == 'user' ? 'user' : 'admin';
                    
                            $a = [];
                    plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php on lines 327..358

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

                    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 2 locations. Consider refactoring.
                    Open

                            foreach ((array) $_widgets as $module_name => $module_widgets) {
                                foreach ((array) $module_widgets as $method_name => $full_name) {
                                    $auto_id = str_replace(array_keys($r), array_values($r), $full_name);
                                    $widgets[$auto_id] = module_safe($module_name)->$method_name(['describe_self' => true]);
                                    if ( ! $widgets[$auto_id]['name']) {
                    plugins/common/classes/common/yf_dashboards.class.php on lines 260..277

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

                    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

                                if ($is_cloneable_item) {
                                    if ($auto_type == 'php_item') {
                                        if (strlen($info['code'])) {
                                            $content = eval('<?' . 'php ' . $info['code']);
                                        } elseif ($info['method_name']) {
                    plugins/common/classes/common/yf_dashboards.class.php on lines 166..184

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

                    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 _get_dashboard_data($id = '')
                        {
                            if ( ! $id) {
                                $id = isset($params['name']) ? $params['name'] : ($this->_name ? $this->_name : $_GET['id']);
                            }
                    plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php on lines 363..380

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

                    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

                            if (main()->is_post()) {
                                if ( ! _ee()) {
                                    db()->insert('dashboards', db()->es([
                                        'name' => $_POST['name'],
                                        'type' => $_POST['type'],
                    plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php on lines 160..171

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

                    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

                            if (main()->is_post()) {
                                if ( ! _ee()) {
                                    db()->update('dashboards', db()->es([
                                        'data' => json_encode($_POST['ds_data']),
                                    ]), 'id=' . (int) ($ds['id']));
                    plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php on lines 216..224

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

                    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 _init()
                        {
                            $this->_auto_info['php_item'] = [
                                'id' => 'php_item',
                                'name' => 'CLONEABLE: php item name',
                    plugins/common/classes/common/yf_dashboards.class.php on lines 27..53

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

                    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

                        public function display($params = [])
                        {
                            if (is_string($params)) {
                                $name = $params;
                            }
                    plugins/common/classes/common/yf_dashboards.class.php on lines 59..75
                    plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php on lines 302..318

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

                    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 3 locations. Consider refactoring.
                    Open

                            if ( ! empty($ds_info['id'])) {
                                db()->query('DELETE FROM ' . db('dashboards') . ' WHERE id=' . (int) ($_GET['id']) . ' LIMIT 1');
                                common()->admin_wall_add(['dashboard deleted: ' . $ds_info['name'] . '', $_GET['id']]);
                            }
                    plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php on lines 90..93
                    plugins/user/admin_modules/yf_user_groups.class.php on lines 84..87

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

                    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