imagecms/ImageCMS

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

Summary

Maintainability
F
1 wk
Test Coverage

File admin.php has 918 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use CMSFactory\assetManager;
use core\src\CoreFactory;

Severity: Major
Found in application/modules/menu/admin.php - About 2 days to fix

Function edit_item has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
Open

    public function edit_item($item_id) {

        if (!$this->input->post()) {
            $item = $this->db
                ->where('menus_data.id', $item_id)
Severity: Minor
Found in application/modules/menu/admin.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 create_item has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    public function create_item($id = null) {

        if (!$this->input->post()) {
            $parents = $this->db
                ->where('menu_id', $id)
Severity: Minor
Found in application/modules/menu/admin.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

Method edit_item has 178 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function edit_item($item_id) {

        if (!$this->input->post()) {
            $item = $this->db
                ->where('menus_data.id', $item_id)
Severity: Major
Found in application/modules/menu/admin.php - About 7 hrs to fix

Method create_item has 133 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create_item($id = null) {

        if (!$this->input->post()) {
            $parents = $this->db
                ->where('menu_id', $id)
Severity: Major
Found in application/modules/menu/admin.php - About 5 hrs to fix

Function insert_menu_item has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public function insert_menu_item() {

        $roles = $this->input->post('roles');
        if ($roles == NULL) {
            $roles = '';
Severity: Minor
Found in application/modules/menu/admin.php - About 5 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

Admin has 34 functions (exceeds 20 allowed). Consider refactoring.
Open

class Admin extends BaseAdminController
{

    /**
     *
Severity: Minor
Found in application/modules/menu/admin.php - About 4 hrs to fix

Method insert_menu_item has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function insert_menu_item() {

        $roles = $this->input->post('roles');
        if ($roles == NULL) {
            $roles = '';
Severity: Major
Found in application/modules/menu/admin.php - About 3 hrs to fix

Function search_pages has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function search_pages($cur_page = 0) {

        $data['nav_count'] = [];
        $data['links'] = 0;

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

Method search_pages has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function search_pages($cur_page = 0) {

        $data['nav_count'] = [];
        $data['links'] = 0;

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

Function delete_menu has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete_menu($name = null) {

        if ($name == null) {
            $name = $this->input->post('ids');
            foreach ($name as $n) {
Severity: Minor
Found in application/modules/menu/admin.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 delete_item has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete_item($id = null) {

        if ($this->input->post('ids')) {
            $id = $this->input->post('ids');
            foreach ($id as $i) {
Severity: Minor
Found in application/modules/menu/admin.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 get_pages has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_pages($cat_id = 0, $cur_page = 0, $referer = null) {

        $data['nav_count'] = [];
        $data['links'] = 0;
        $per_page = 10;
Severity: Minor
Found in application/modules/menu/admin.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 display_selector has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function display_selector($id, $type = 'page') {

        $this->template->assign('insert_id', $id);

        $this->menu->prepare_menu_array($this->get_name_by_id($id));
Severity: Minor
Found in application/modules/menu/admin.php - About 1 hr to fix

Method get_pages has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get_pages($cat_id = 0, $cur_page = 0, $referer = null) {

        $data['nav_count'] = [];
        $data['links'] = 0;
        $per_page = 10;
Severity: Minor
Found in application/modules/menu/admin.php - About 1 hr to fix

Method delete_menu has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function delete_menu($name = null) {

        if ($name == null) {
            $name = $this->input->post('ids');
            foreach ($name as $n) {
Severity: Minor
Found in application/modules/menu/admin.php - About 1 hr to fix

Method create_menu has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create_menu() {

        //cp_check_perm('menu_create');
        if ($this->input->post('menu_name') == NULL) {
            showMessage(lang('Name field sieve', 'menu'), '', 'r');
Severity: Minor
Found in application/modules/menu/admin.php - About 1 hr to fix

Method delete_item has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function delete_item($id = null) {

        if ($this->input->post('ids')) {
            $id = $this->input->post('ids');
            foreach ($id as $i) {
Severity: Minor
Found in application/modules/menu/admin.php - About 1 hr to fix

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

    public function create_menu() {

        //cp_check_perm('menu_create');
        if ($this->input->post('menu_name') == NULL) {
            showMessage(lang('Name field sieve', 'menu'), '', 'r');
Severity: Minor
Found in application/modules/menu/admin.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 display_selector has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function display_selector($id, $type = 'page') {

        $this->template->assign('insert_id', $id);

        $this->menu->prepare_menu_array($this->get_name_by_id($id));
Severity: Minor
Found in application/modules/menu/admin.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 get_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_item() {

        $item_id = (int) $this->input->post('item_id');

        $this->db->where('id', $item_id);
Severity: Minor
Found in application/modules/menu/admin.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 7 locations. Consider refactoring.
Open

                if ($this->input->post('page_item_image')) {
                    $image = $this->input->post('page_item_image');
                } elseif ($this->input->post('cat_item_image')) {
                    $image = $this->input->post('cat_item_image');
                } elseif ($this->input->post('module_item_image')) {
Severity: Major
Found in application/modules/menu/admin.php and 6 other locations - About 1 hr to fix
application/modules/menu/admin.php on lines 187..195
application/modules/menu/admin.php on lines 209..217
application/modules/menu/admin.php on lines 537..545
application/modules/menu/admin.php on lines 574..582
application/modules/menu/admin.php on lines 592..600
application/modules/menu/admin.php on lines 601..609

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

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 7 locations. Consider refactoring.
Open

                if ($this->input->post('page_newpage')) {
                    $newpage = $this->input->post('page_newpage');
                } elseif ($this->input->post('cat_newpage')) {
                    $newpage = $this->input->post('cat_newpage');
                } elseif ($this->input->post('module_newpage')) {
Severity: Major
Found in application/modules/menu/admin.php and 6 other locations - About 1 hr to fix
application/modules/menu/admin.php on lines 187..195
application/modules/menu/admin.php on lines 209..217
application/modules/menu/admin.php on lines 537..545
application/modules/menu/admin.php on lines 574..582
application/modules/menu/admin.php on lines 583..591
application/modules/menu/admin.php on lines 592..600

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

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 7 locations. Consider refactoring.
Open

                if ($this->input->post('page_newpage')) {
                    $newpage = $this->input->post('page_newpage');
                } elseif ($this->input->post('cat_newpage')) {
                    $newpage = $this->input->post('cat_newpage');
                } elseif ($this->input->post('module_newpage')) {
Severity: Major
Found in application/modules/menu/admin.php and 6 other locations - About 1 hr to fix
application/modules/menu/admin.php on lines 187..195
application/modules/menu/admin.php on lines 537..545
application/modules/menu/admin.php on lines 574..582
application/modules/menu/admin.php on lines 583..591
application/modules/menu/admin.php on lines 592..600
application/modules/menu/admin.php on lines 601..609

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

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 7 locations. Consider refactoring.
Open

                if ($this->input->post('page_parent_id')) {
                    $parent_id = $this->input->post('page_parent_id');
                } elseif ($this->input->post('cat_parent_id')) {
                    $parent_id = $this->input->post('cat_parent_id');
                } elseif ($this->input->post('module_parent_id')) {
Severity: Major
Found in application/modules/menu/admin.php and 6 other locations - About 1 hr to fix
application/modules/menu/admin.php on lines 187..195
application/modules/menu/admin.php on lines 209..217
application/modules/menu/admin.php on lines 537..545
application/modules/menu/admin.php on lines 574..582
application/modules/menu/admin.php on lines 583..591
application/modules/menu/admin.php on lines 601..609

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

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 7 locations. Consider refactoring.
Open

                if ($this->input->post('page_hidden')) {
                    $hidden = $this->input->post('page_hidden');
                } elseif ($this->input->post('cat_hidden')) {
                    $hidden = $this->input->post('cat_hidden');
                } elseif ($this->input->post('module_hidden')) {
Severity: Major
Found in application/modules/menu/admin.php and 6 other locations - About 1 hr to fix
application/modules/menu/admin.php on lines 209..217
application/modules/menu/admin.php on lines 537..545
application/modules/menu/admin.php on lines 574..582
application/modules/menu/admin.php on lines 583..591
application/modules/menu/admin.php on lines 592..600
application/modules/menu/admin.php on lines 601..609

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

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 7 locations. Consider refactoring.
Open

            if ($this->input->post('page_item_type')) {
                $item_type = $this->input->post('page_item_type');
            } elseif ($this->input->post('cat_item_type')) {
                $item_type = $this->input->post('cat_item_type');
            } elseif ($this->input->post('module_item_type')) {
Severity: Major
Found in application/modules/menu/admin.php and 6 other locations - About 1 hr to fix
application/modules/menu/admin.php on lines 187..195
application/modules/menu/admin.php on lines 209..217
application/modules/menu/admin.php on lines 574..582
application/modules/menu/admin.php on lines 583..591
application/modules/menu/admin.php on lines 592..600
application/modules/menu/admin.php on lines 601..609

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

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 7 locations. Consider refactoring.
Open

                if ($this->input->post('page_hidden')) {
                    $hidden = $this->input->post('page_hidden');
                } elseif ($this->input->post('cat_hidden')) {
                    $hidden = $this->input->post('cat_hidden');
                } elseif ($this->input->post('module_hidden')) {
Severity: Major
Found in application/modules/menu/admin.php and 6 other locations - About 1 hr to fix
application/modules/menu/admin.php on lines 187..195
application/modules/menu/admin.php on lines 209..217
application/modules/menu/admin.php on lines 537..545
application/modules/menu/admin.php on lines 583..591
application/modules/menu/admin.php on lines 592..600
application/modules/menu/admin.php on lines 601..609

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

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