plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php

Summary

Maintainability
F
1 wk
Test Coverage

Function _get_grid has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public function _get_grid($data = [])
    {
        $rows = [];
        foreach ((array) $data as $row_id => $row_items) {
            $cols = '';
Severity: Minor
Found in plugins/dashboards/admin_modules/yf_manage_dashboards2.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_manage_dashboards2.class.php has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Dashboards2 management.
 *
Severity: Minor
Found in plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php - About 3 hrs to fix

    Method _get_grid has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function _get_grid($data = [])
        {
            $rows = [];
            foreach ((array) $data as $row_id => $row_items) {
                $cols = '';
    Severity: Major
    Found in plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php - About 2 hrs to fix

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

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

        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_dashboards2.class.php - About 1 hr to fix

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

              public function view()
              {
                  $ds = $this->_get_dashboard_data($_GET['id']);
          
                  if ( ! $ds['id']) {
          Severity: Minor
          Found in plugins/dashboards/admin_modules/yf_manage_dashboards2.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 _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_dashboards2.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_dashboards.class.php on lines 444..475

          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

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

              public function active()
              {
                  $_GET['id'] = (int) ($_GET['id']);
                  if ( ! empty($_GET['id'])) {
                      $ds_info = db()->get('SELECT * FROM ' . db('dashboards2') . ' WHERE id=' . (int) ($_GET['id']));
          plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php on lines 139..155

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

          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 lock()
              {
                  $_GET['id'] = (int) ($_GET['id']);
                  if ( ! empty($_GET['id'])) {
                      $ds_info = db()->get('SELECT * FROM ' . db('dashboards2') . ' WHERE id=' . (int) ($_GET['id']));
          plugins/dashboards/admin_modules/yf_manage_dashboards2.class.php on lines 120..136

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

          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_dashboards.class.php on lines 480..497

          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('dashboards2', db()->es([
                              'name' => $_POST['name'],
                              'type' => $_POST['type'],
          plugins/dashboards/admin_modules/yf_manage_dashboards.class.php on lines 128..139

          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('dashboards2', db()->es([
                              'data' => json_encode($_POST['ds_data']),
                          ]), 'id=' . (int) ($ds['id']));
          plugins/dashboards/admin_modules/yf_manage_dashboards.class.php on lines 158..166

          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

          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_dashboards.class.php on lines 198..214

          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('dashboards2') . ' WHERE id=' . (int) ($_GET['id']) . ' LIMIT 1');
                      common()->admin_wall_add(['dashboard deleted: ' . $ds_info['name'] . '', $_GET['id']]);
                  }
          plugins/dashboards/admin_modules/yf_manage_dashboards.class.php on lines 77..80
          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