imagecms/ImageCMS

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

Summary

Maintainability
F
3 days
Test Coverage

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

<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
Severity: Minor
Found in application/modules/user_manager/admin.php - About 6 hrs to fix

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

    public function search() {
        if ($this->input->get()) {
            $locale = MY_Controller::defaultLocale();
            @$s_data = $this->input->get('s_data');
            @$s_email = $this->input->get('s_email');
Severity: Minor
Found in application/modules/user_manager/admin.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

Function create_user has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function create_user() {

        if ($this->input->post()) {

            $this->load->model('dx_auth/users', 'user2');
Severity: Minor
Found in application/modules/user_manager/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 update_user has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function update_user($user_id) {

        //cp_check_perm('edit_user');

        $this->load->model('dx_auth/users', 'user2');
Severity: Major
Found in application/modules/user_manager/admin.php - About 2 hrs to fix

Method create_user has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create_user() {

        if ($this->input->post()) {

            $this->load->model('dx_auth/users', 'user2');
Severity: Major
Found in application/modules/user_manager/admin.php - About 2 hrs to fix

Method search has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function search() {
        if ($this->input->get()) {
            $locale = MY_Controller::defaultLocale();
            @$s_data = $this->input->get('s_data');
            @$s_email = $this->input->get('s_email');
Severity: Major
Found in application/modules/user_manager/admin.php - About 2 hrs to fix

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

class Admin extends BaseAdminController
{

    public function __construct() {
        parent::__construct();
Severity: Minor
Found in application/modules/user_manager/admin.php - About 2 hrs to fix

Function update_user has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function update_user($user_id) {

        //cp_check_perm('edit_user');

        $this->load->model('dx_auth/users', 'user2');
Severity: Minor
Found in application/modules/user_manager/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 genre_user_table has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function genre_user_table() {

        //cp_check_perm('user_view_data');

        $this->load->model('dx_auth/users', 'users');
Severity: Minor
Found in application/modules/user_manager/admin.php - About 1 hr to fix

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

    public function _create() {

        if (!$this->ajaxRequest) {
            $this->display_tpl('create_group');
        }
Severity: Minor
Found in application/modules/user_manager/admin.php - About 1 hr to fix

Function _create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function _create() {

        if (!$this->ajaxRequest) {
            $this->display_tpl('create_group');
        }
Severity: Minor
Found in application/modules/user_manager/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

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

    public function auto_complit($type) {

        $s_limit = $this->input->get('limit');
        $s_coef = $this->input->get('term');

Severity: Minor
Found in application/modules/user_manager/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 2 locations. Consider refactoring.
Open

            } else {

                //cp_check_perm('user_edit');
                ($hook = get_hook('users_unban')) ? eval($hook) : NULL;
                $this->users->unban_user($user_id);
Severity: Minor
Found in application/modules/user_manager/admin.php and 1 other location - About 30 mins to fix
application/modules/user_manager/admin.php on lines 268..286

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

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

            if ($row->banned == 0) {

                //cp_check_perm('user_edit');
                ($hook = get_hook('users_ban')) ? eval($hook) : NULL;
                $this->users->ban_user($user_id);
Severity: Minor
Found in application/modules/user_manager/admin.php and 1 other location - About 30 mins to fix
application/modules/user_manager/admin.php on lines 277..286

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

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