imagecms/ImageCMS

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

Summary

Maintainability
F
3 days
Test Coverage

File widgets_manager.php has 426 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use CMSFactory\Events;
use translator\classes\Replacer;

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

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

    public function create() {
        if (!$this->_is_writable()) {
            showMessage(lang('Set the directory access rights to continue the work with widgets', 'admin') . '<b>' . $this->widgets_path . '</b>', '', 'r');
            exit;
        }
Severity: Minor
Found in application/modules/admin/widgets_manager.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 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create() {
        if (!$this->_is_writable()) {
            showMessage(lang('Set the directory access rights to continue the work with widgets', 'admin') . '<b>' . $this->widgets_path . '</b>', '', 'r');
            exit;
        }
Severity: Major
Found in application/modules/admin/widgets_manager.php - About 3 hrs to fix

Function update_widget has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function update_widget($id, $update_info = FALSE, $locale = NULL) {
        //cp_check_perm('widget_access_settings');
        $locale = $locale ?: MY_Controller::defaultLocale();
        $widget = $this->get($id);

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

    public function update_widget($id, $update_info = FALSE, $locale = NULL) {
        //cp_check_perm('widget_access_settings');
        $locale = $locale ?: MY_Controller::defaultLocale();
        $widget = $this->get($id);

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

Method update_html_widget has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function update_html_widget($id, $locale) {
        $locale = $locale ?: MY_Controller::defaultLocale();
        $widget = $this->get($id);
        if ($widget->num_rows() == 1) {
            $widget = $widget->row_array();
Severity: Minor
Found in application/modules/admin/widgets_manager.php - About 1 hr to fix

Method display_create_tpl has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function display_create_tpl($type = FALSE) {
        if ($type == 'tmodule') {
            $case = true;
            $type = 'module';
        }
Severity: Minor
Found in application/modules/admin/widgets_manager.php - About 1 hr to fix

Function display_create_tpl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function display_create_tpl($type = FALSE) {
        if ($type == 'tmodule') {
            $case = true;
            $type = 'module';
        }
Severity: Minor
Found in application/modules/admin/widgets_manager.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 index has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function index() {

        if (!$this->_is_writable()) {
            $this->template->assign('error', lang('Set the directory access rights to continue the work with widgets', 'admin') . '<b>' . $this->widgets_path . '</b>');
            $this->template->show('widgets_list', FALSE);
Severity: Minor
Found in application/modules/admin/widgets_manager.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 index has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function index() {

        if (!$this->_is_writable()) {
            $this->template->assign('error', lang('Set the directory access rights to continue the work with widgets', 'admin') . '<b>' . $this->widgets_path . '</b>');
            $this->template->show('widgets_list', FALSE);
Severity: Minor
Found in application/modules/admin/widgets_manager.php - About 1 hr to fix

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

    public function update_html_widget($id, $locale) {
        $locale = $locale ?: MY_Controller::defaultLocale();
        $widget = $this->get($id);
        if ($widget->num_rows() == 1) {
            $widget = $widget->row_array();
Severity: Minor
Found in application/modules/admin/widgets_manager.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 edit_module_widget has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function edit_module_widget($id, $update_info = FALSE, $locale = NULL) {
        //cp_check_perm('widget_access_settings');
        $locale = $locale ?: MY_Controller::defaultLocale();

        if ($this->input->post()) {
Severity: Minor
Found in application/modules/admin/widgets_manager.php - About 1 hr to fix

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

    private function getWidgetsArray($pathToFile) {
        include_once $pathToFile;

        /* @var $widgets array - Widget settings array */
        if ($widgets) {
Severity: Minor
Found in application/modules/admin/widgets_manager.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