imagecms/ImageCMS

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

Summary

Maintainability
F
1 wk
Test Coverage

File pages.php has 732 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use CMSFactory\Events;
use core\models\Route;

Severity: Major
Found in application/modules/admin/pages.php - About 1 day to fix

Function update has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    public function update($page_id) {

        $pagesPagination = $this->session->userdata('pages_pag_url');
        $pagesPagination = $pagesPagination ?: null;

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

Method update has 124 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function update($page_id) {

        $pagesPagination = $this->session->userdata('pages_pag_url');
        $pagesPagination = $pagesPagination ?: null;

Severity: Major
Found in application/modules/admin/pages.php - About 4 hrs to fix

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

    public function edit($page_id, $lang = 0) {
        $this->cms_base->setLocaleId($lang);

        if ($this->cms_admin->get_page($page_id) == FALSE) {
            showMessage(lang('Page', 'admin') . $page_id . lang('Not found', 'admin'), false, 'r');
Severity: Minor
Found in application/modules/admin/pages.php - About 4 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 GetPagesByCategory has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function GetPagesByCategory($cat_id = 'all', $pagination = null) {

        //////**********  Pagination pages **********\\\\\\\
        if ($pagination) {
            $paginationSession = ['pages_pag_url' => $pagination];
Severity: Major
Found in application/modules/admin/pages.php - About 4 hrs to fix

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

    public function edit($page_id, $lang = 0) {
        $this->cms_base->setLocaleId($lang);

        if ($this->cms_admin->get_page($page_id) == FALSE) {
            showMessage(lang('Page', 'admin') . $page_id . lang('Not found', 'admin'), false, 'r');
Severity: Major
Found in application/modules/admin/pages.php - About 3 hrs to fix

Method add has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function add() {

        $this->form_validation->set_rules('page_title', lang('Title', 'admin'), 'trim|required|min_length[1]|max_length[500]');
        $this->form_validation->set_rules('page_url', lang('URL', 'admin'), 'alpha_dash|least_one_symbol|max_length[255]');
        $this->form_validation->set_rules('prev_text', lang('Preliminary contents', 'admin'), 'trim|required');
Severity: Major
Found in application/modules/admin/pages.php - About 3 hrs to fix

Method move_pages has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function move_pages($action) {

        $ids = $this->input->post('pages');
        $ids_key = array_flip($this->input->post('pages'));

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

Pages has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Pages extends BaseAdminController
{

    public $_Config = ['per_page' => 20];

Severity: Minor
Found in application/modules/admin/pages.php - About 2 hrs to fix

Function move_pages has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function move_pages($action) {

        $ids = $this->input->post('pages');
        $ids_key = array_flip($this->input->post('pages'));

Severity: Minor
Found in application/modules/admin/pages.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 add has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function add() {

        $this->form_validation->set_rules('page_title', lang('Title', 'admin'), 'trim|required|min_length[1]|max_length[500]');
        $this->form_validation->set_rules('page_url', lang('URL', 'admin'), 'alpha_dash|least_one_symbol|max_length[255]');
        $this->form_validation->set_rules('prev_text', lang('Preliminary contents', 'admin'), 'trim|required');
Severity: Minor
Found in application/modules/admin/pages.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 GetPagesByCategory has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function GetPagesByCategory($cat_id = 'all', $pagination = null) {

        //////**********  Pagination pages **********\\\\\\\
        if ($pagination) {
            $paginationSession = ['pages_pag_url' => $pagination];
Severity: Minor
Found in application/modules/admin/pages.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 ajax_create_keywords has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function ajax_create_keywords() {

        $text = $this->input->post('keys');

        if ($text == '') {
Severity: Minor
Found in application/modules/admin/pages.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 delete has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function delete($page_id, $show_messages = TRUE) {

        //cp_check_perm('page_delete');

        $settings = $this->cms_admin->get_settings();
Severity: Minor
Found in application/modules/admin/pages.php - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if ($page_roles[$i2]['role_id'] == $roles[$i]['id']) {
                            $roles[$i]['selected'] = 'selected="true"';
                        }
Severity: Major
Found in application/modules/admin/pages.php - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if ($page_roles[$i2]['role_id'] == '0') {
                            $this->template->assign('all_selected', 'selected="true"');
                        }
Severity: Major
Found in application/modules/admin/pages.php - About 45 mins to fix

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

    public function _set_page_roles($page_id, $roles) {

        if ($roles[0] != '') {
            $page_roles = [];

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