imagecms/ImageCMS

View on GitHub
application/modules/menu/menu.php

Summary

Maintainability
F
6 days
Test Coverage

Function _get_real_tpl has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
Open

    private function _get_real_tpl($index = 0, $mode = 'item') {
        if ($mode == 'item') {
            $is_active = $this->arranged_menu_array[$index]['is_active'];
            $edge = $this->arranged_menu_array[$index]['edge'];

Severity: Minor
Found in application/modules/menu/menu.php - About 1 day 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 display_menu has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    public function display_menu($menu_array) {

        $array_keys = array_keys($menu_array);
        $start_index = $array_keys[0];
        $end_index = $array_keys[count($array_keys) - 1];
Severity: Minor
Found in application/modules/menu/menu.php - About 1 day 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 prepare_menu_array has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    public function prepare_menu_array($menu) {
        $menu_cache_key = $this->cache_key . $menu . self::getCurrentLocale();
        if (($menu_data = $this->cache->fetch($menu_cache_key, 'menus')) !== FALSE) {
            $this->menu_array = $menu_data['menu_array'];
            $this->sub_menu_array = $menu_data['sub_menu_array'];
Severity: Minor
Found in application/modules/menu/menu.php - About 1 day 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 menu.php has 521 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
Severity: Major
Found in application/modules/menu/menu.php - About 1 day to fix

Method prepare_menu_array has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function prepare_menu_array($menu) {
        $menu_cache_key = $this->cache_key . $menu . self::getCurrentLocale();
        if (($menu_data = $this->cache->fetch($menu_cache_key, 'menus')) !== FALSE) {
            $this->menu_array = $menu_data['menu_array'];
            $this->sub_menu_array = $menu_data['sub_menu_array'];
Severity: Major
Found in application/modules/menu/menu.php - About 4 hrs to fix

Method display_menu has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function display_menu($menu_array) {

        $array_keys = array_keys($menu_array);
        $start_index = $array_keys[0];
        $end_index = $array_keys[count($array_keys) - 1];
Severity: Major
Found in application/modules/menu/menu.php - About 3 hrs to fix

Method _get_real_tpl has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function _get_real_tpl($index = 0, $mode = 'item') {
        if ($mode == 'item') {
            $is_active = $this->arranged_menu_array[$index]['is_active'];
            $edge = $this->arranged_menu_array[$index]['edge'];

Severity: Major
Found in application/modules/menu/menu.php - About 3 hrs to fix

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

class Menu extends MY_Controller
{

    /*     * ***** Это можно редактировать *********** */
    private $tpl_folder_prefix = 'level_';
Severity: Minor
Found in application/modules/menu/menu.php - About 2 hrs to fix

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

    public function _get_sub_menus($id) {
        $sub_menus = [];

        foreach ($this->sub_menu_array as $sub_menu) {
            if ($sub_menu['parent_id'] == $id) {
Severity: Minor
Found in application/modules/menu/menu.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

Avoid deeply nested control flow statements.
Open

                                if ($n_title['title']) {
                                    $menus[$i]['title'] = $n_title['title'];
                                }
Severity: Major
Found in application/modules/menu/menu.php - About 45 mins to fix

Function _check_roles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function _check_roles($roles = []) {
        $access = FALSE;

        foreach ($roles as $role_id) {
            $my_role = $this->dx_auth->get_role_id();
Severity: Minor
Found in application/modules/menu/menu.php - About 35 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

There are no issues that match your filters.

Category
Status