imagecms/ImageCMS

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

Summary

Maintainability
F
4 days
Test Coverage

File categories.php has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use CMSFactory\Events;
use core\models\Route;
use core\models\RouteQuery;
Severity: Major
Found in application/modules/admin/categories.php - About 1 day to fix

Function delete has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete() {

        foreach ($this->input->post('ids') as $p) {

            $cat_id = $p;
Severity: Minor
Found in application/modules/admin/categories.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 create has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create($action, $cat_id = 0) {
        $url = $this->formUrl();

        $this->form_validation->set_rules('name', lang('Title', 'admin'), 'trim|required|min_length[1]|max_length[160]|xss_clean');

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

Function create has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function create($action, $cat_id = 0) {
        $url = $this->formUrl();

        $this->form_validation->set_rules('name', lang('Title', 'admin'), 'trim|required|min_length[1]|max_length[160]|xss_clean');

Severity: Minor
Found in application/modules/admin/categories.php - About 3 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 translate has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function translate($id, $lang) {
        $cat = $this->cms_admin->get_category($id);

        ($hook = get_hook('admin_on_translate_cat')) ? eval($hook) : NULL;

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

Categories has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class Categories extends BaseAdminController
{

    /**
     * @var array
Severity: Minor
Found in application/modules/admin/categories.php - About 2 hrs to fix

Method delete has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function delete() {

        foreach ($this->input->post('ids') as $p) {

            $cat_id = $p;
Severity: Major
Found in application/modules/admin/categories.php - About 2 hrs to fix

Method fast_add has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function fast_add($action = '') {

        $this->template->add_array(
            [
             'tree' => $this->lib_category->build(),
Severity: Major
Found in application/modules/admin/categories.php - About 2 hrs to fix

Function translate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function translate($id, $lang) {
        $cat = $this->cms_admin->get_category($id);

        ($hook = get_hook('admin_on_translate_cat')) ? eval($hook) : NULL;

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

    public function fast_add($action = '') {

        $this->template->add_array(
            [
             'tree' => $this->lib_category->build(),
Severity: Minor
Found in application/modules/admin/categories.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 create_tpl has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create_tpl() {
        $file = trim($this->input->post('filename'));

        $this->form_validation->set_rules('filename', lang('Template name', 'admin'), 'required|alpha_numeric|min_length[1]|max_length[250]');

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

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

    public function create_tpl() {
        $file = trim($this->input->post('filename'));

        $this->form_validation->set_rules('filename', lang('Template name', 'admin'), 'required|alpha_numeric|min_length[1]|max_length[250]');

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