imagecms/ImageCMS

View on GitHub
application/modules/admin/components.php

Summary

Maintainability
F
3 days
Test Coverage

File components.php has 449 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use CMSFactory\Events;

if (!defined('BASEPATH')) {
Severity: Minor
Found in application/modules/admin/components.php - About 6 hrs to fix

Components has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class Components extends BaseAdminController
{

    /**
     * array of installed modules
Severity: Minor
Found in application/modules/admin/components.php - About 2 hrs to fix

Method modules_table has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function modules_table() {
        $not_installed = [];

        $fs_modules = $this->find_components();
        $db_modules = $this->db->order_by('position', 'asc')->not_like('identif', 'payment_method_')->get('components')->result_array();
Severity: Major
Found in application/modules/admin/components.php - About 2 hrs to fix

Function find_components has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function find_components($in_menu = FALSE) {
        $components = [];
        if ($in_menu == TRUE) {
            $this->db->where('in_menu', 1);
        }
Severity: Minor
Found in application/modules/admin/components.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

Function find_components_for_menu_list has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function find_components_for_menu_list() {
        /** Get all components which show in menu */
        $components = $this->db->where('in_menu', 1);

        if (MAINSITE) {
Severity: Minor
Found in application/modules/admin/components.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

Function deinstall has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function deinstall($moduleName) {
        $modules = $this->input->post('ids') ?: [$moduleName];

        foreach ($modules as $module) {
            $module = strtolower($module);
Severity: Minor
Found in application/modules/admin/components.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 find_components has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function find_components($in_menu = FALSE) {
        $components = [];
        if ($in_menu == TRUE) {
            $this->db->where('in_menu', 1);
        }
Severity: Minor
Found in application/modules/admin/components.php - About 1 hr to fix

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

    public function modules_table() {
        $not_installed = [];

        $fs_modules = $this->find_components();
        $db_modules = $this->db->order_by('position', 'asc')->not_like('identif', 'payment_method_')->get('components')->result_array();
Severity: Minor
Found in application/modules/admin/components.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

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

    public function install($module = '') {
        //cp_check_perm('module_install');

        $module = strtolower($module);

Severity: Minor
Found in application/modules/admin/components.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 install has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function install($module = '') {
        //cp_check_perm('module_install');

        $module = strtolower($module);

Severity: Minor
Found in application/modules/admin/components.php - About 1 hr to fix

Method find_components_for_menu_list has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function find_components_for_menu_list() {
        /** Get all components which show in menu */
        $components = $this->db->where('in_menu', 1);

        if (MAINSITE) {
Severity: Minor
Found in application/modules/admin/components.php - About 1 hr to fix

Method deinstall has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function deinstall($moduleName) {
        $modules = $this->input->post('ids') ?: [$moduleName];

        foreach ($modules as $module) {
            $module = strtolower($module);
Severity: Minor
Found in application/modules/admin/components.php - About 1 hr to fix

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

    public function save_components_positions() {
        $positions = $this->input->post('positions');
        if (is_array($positions)) {
            foreach ($positions as $key => $value) {
                if ($this->db->where('name', $value)->set('position', $key)->update('components')) {
Severity: Minor
Found in application/modules/admin/components.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

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

    public function change_autoload() {
        if ($this->input->post('mid')) {
            $mid = $this->input->post('mid');
            $row = $this->db->where('id', $mid)->get('components')->row();
            if (count($row) > 0) {
Severity: Minor
Found in application/modules/admin/components.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 change_url_access has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function change_url_access() {
        if ($this->input->post('mid')) {
            $mid = $this->input->post('mid');
            $row = $this->db->where('id', $mid)->get('components')->row();

Severity: Minor
Found in application/modules/admin/components.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

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

    private function isPermitedModules($db_modules, $not_installed) {
        foreach ($db_modules as $key => $db_module) {
            if ($this->isNotPermited($db_module['name'])) {
                unset($db_modules[$key]);
            }
Severity: Minor
Found in application/modules/admin/components.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

There are no issues that match your filters.

Category
Status