imagecms/ImageCMS

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

Summary

Maintainability
F
3 days
Test Coverage

Method edit_trash has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function edit_trash($id) {
        $query = $this->db->get_where('trash', ['id' => $id]);
        $this->template->add_array(['trash' => $query->row()]);

        $this->_addShopData();
Severity: Major
Found in application/modules/trash/admin.php - About 3 hrs to fix

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

<?php

use CMSFactory\assetManager;
use core\models\Route;
use core\models\RouteQuery;
Severity: Minor
Found in application/modules/trash/admin.php - About 3 hrs to fix

Method create_trash has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create_trash() {
        $this->form_validation->set_rules('url', 'Url', 'required');

        $this->db->where('name', 'shop')->get('components');

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

Function create_trash has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function create_trash() {
        $this->form_validation->set_rules('url', 'Url', 'required');

        $this->db->where('name', 'shop')->get('components');

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

    public function index() {
        $countTotalRows = (int) $this->db->get('trash')->num_rows();
        $perPage = (int) $this->input->get('per_page');
        if (empty($perPage)) {
            $perPage = 0;
Severity: Minor
Found in application/modules/trash/admin.php - About 1 hr to fix

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

    public function edit_trash($id) {
        $query = $this->db->get_where('trash', ['id' => $id]);
        $this->template->add_array(['trash' => $query->row()]);

        $this->_addShopData();
Severity: Minor
Found in application/modules/trash/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 search_url has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function search_url($type_search = 'old') {
        $type_search = $type_search == 'old' ? 'old' : 'new';
        // old = старый урл, new - новый урл
        if ($this->input->get()) {
            $get = $this->input->get();
Severity: Minor
Found in application/modules/trash/admin.php - About 1 hr to fix

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

    public function search_url($type_search = 'old') {
        $type_search = $type_search == 'old' ? 'old' : 'new';
        // old = старый урл, new - новый урл
        if ($this->input->get()) {
            $get = $this->input->get();
Severity: Minor
Found in application/modules/trash/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 trash_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function trash_list() {
        if ($this->input->post('urls')) {
            $data = nl2br($this->input->post('urls'));
            $data = explode('<br />', $data);
            $data = array_map('trim', $data);
Severity: Minor
Found in application/modules/trash/admin.php - About 55 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 2 locations. Consider refactoring.
Open

                case 'product':
                    $route = RouteQuery::create()
                        ->filterByEntityId($this->input->post('products'))
                        ->filterByType(Route::TYPE_PRODUCT)
                        ->findOne();
Severity: Major
Found in application/modules/trash/admin.php and 1 other location - About 2 hrs to fix
application/modules/trash/admin.php on lines 294..308

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

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

                case 'category':
                    $route = RouteQuery::create()
                        ->filterByEntityId($this->input->post('category'))
                        ->filterByType(Route::TYPE_SHOP_CATEGORY)
                        ->findOne();
Severity: Major
Found in application/modules/trash/admin.php and 1 other location - About 2 hrs to fix
application/modules/trash/admin.php on lines 277..292

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

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

                    case 'product':
                        $route = RouteQuery::create()
                            ->filterByEntityId($this->input->post('products'))
                            ->filterByType(Route::TYPE_PRODUCT)
                            ->findOne();
Severity: Major
Found in application/modules/trash/admin.php and 1 other location - About 2 hrs to fix
application/modules/trash/admin.php on lines 183..196

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

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

                    case 'category':
                        $route = RouteQuery::create()
                            ->filterByEntityId($this->input->post('category'))
                            ->filterByType(Route::TYPE_SHOP_CATEGORY)
                            ->findOne();
Severity: Major
Found in application/modules/trash/admin.php and 1 other location - About 2 hrs to fix
application/modules/trash/admin.php on lines 168..181

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

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