imagecms/ImageCMS

View on GitHub
application/libraries/DX_Auth.php

Summary

Maintainability
F
1 wk
Test Coverage

File DX_Auth.php has 750 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
Severity: Major
Found in application/libraries/DX_Auth.php - About 1 day to fix

DX_Auth has 54 functions (exceeds 20 allowed). Consider refactoring.
Open

class DX_Auth
{

    // Private
    var $_banned;
Severity: Major
Found in application/libraries/DX_Auth.php - About 7 hrs to fix

Function login has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function login($login, $password, $remember = TRUE) {
        // Load Models
        $this->ci->load->model('dx_auth/users', 'users');
        $this->ci->load->model('dx_auth/user_temp', 'user_temp');
        $this->ci->load->model('dx_auth/login_attempts', 'login_attempts');
Severity: Minor
Found in application/libraries/DX_Auth.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 register has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function register($username, $password, $email, $address = '', $key, $phone = '', $login_user = TRUE) {

        // Load Models
        $this->ci->load->model('dx_auth/users', 'users');
        $this->ci->load->model('dx_auth/user_temp', 'user_temp');
Severity: Minor
Found in application/libraries/DX_Auth.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 register has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function register($username, $password, $email, $address = '', $key, $phone = '', $login_user = TRUE) {

        // Load Models
        $this->ci->load->model('dx_auth/users', 'users');
        $this->ci->load->model('dx_auth/user_temp', 'user_temp');
Severity: Major
Found in application/libraries/DX_Auth.php - About 2 hrs to fix

Function _get_role_data has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function _get_role_data($role_id) {
        // Load models
        $this->ci->load->model('dx_auth/roles', 'roles');
        $this->ci->load->model('dx_auth/permissions', 'permissions');

Severity: Minor
Found in application/libraries/DX_Auth.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 check_uri_permissions has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function check_uri_permissions() {
        // First check if user already logged in or not
        if ($this->is_logged_in()) {
            // If user is not admin
            if (!$this->is_admin()) {
Severity: Minor
Found in application/libraries/DX_Auth.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 _get_role_data has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function _get_role_data($role_id) {
        // Load models
        $this->ci->load->model('dx_auth/roles', 'roles');
        $this->ci->load->model('dx_auth/permissions', 'permissions');

Severity: Minor
Found in application/libraries/DX_Auth.php - About 1 hr to fix

Method login has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function login($login, $password, $remember = TRUE) {
        // Load Models
        $this->ci->load->model('dx_auth/users', 'users');
        $this->ci->load->model('dx_auth/user_temp', 'user_temp');
        $this->ci->load->model('dx_auth/login_attempts', 'login_attempts');
Severity: Minor
Found in application/libraries/DX_Auth.php - About 1 hr to fix

Function is_role has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function is_role($roles = [], $use_role_name = TRUE, $check_parent = TRUE) {
        // Default return value
        $result = FALSE;

        // Build checking array
Severity: Minor
Found in application/libraries/DX_Auth.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_permission_value has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_permission_value($key, $check_parent = TRUE) {
        // Default return value
        $result = NULL;

        // Get current user permission
Severity: Minor
Found in application/libraries/DX_Auth.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 _init has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function _init() {
        // When we load this library, auto Login any returning users
        $this->autologin();

        // Init helper config variable
Severity: Minor
Found in application/libraries/DX_Auth.php - About 1 hr to fix

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

    public function get_permissions_value($key, $array_key = 'default') {
        $result = [];

        $role_id = $this->ci->session->userdata('DX_role_id');
        $role_name = $this->ci->session->userdata('DX_role_name');
Severity: Minor
Found in application/libraries/DX_Auth.php - About 1 hr to fix

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

    public function forgot_password($login) {
        // Default return value
        $result = FALSE;

        if ($login) {
Severity: Minor
Found in application/libraries/DX_Auth.php - About 1 hr to fix

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

    public function is_role($roles = [], $use_role_name = TRUE, $check_parent = TRUE) {
        // Default return value
        $result = FALSE;

        // Build checking array
Severity: Minor
Found in application/libraries/DX_Auth.php - About 1 hr to fix

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

    public function _encode($password) {
        $majorsalt = '';

        // if you set your encryption key let's use it
        if ($this->ci->config->item('encryption_key') != '') {
Severity: Minor
Found in application/libraries/DX_Auth.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_permissions_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_permissions_value($key, $array_key = 'default') {
        $result = [];

        $role_id = $this->ci->session->userdata('DX_role_id');
        $role_name = $this->ci->session->userdata('DX_role_name');
Severity: Minor
Found in application/libraries/DX_Auth.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 register has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function register($username, $password, $email, $address = '', $key, $phone = '', $login_user = TRUE) {
Severity: Major
Found in application/libraries/DX_Auth.php - About 50 mins to fix

Function forgot_password has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function forgot_password($login) {
        // Default return value
        $result = FALSE;

        if ($login) {
Severity: Minor
Found in application/libraries/DX_Auth.php - About 45 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 captcha_check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function captcha_check($code) {
        $CI = get_instance();
        $result = TRUE;

        if ($this->use_recaptcha) {
Severity: Minor
Found in application/libraries/DX_Auth.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

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

    public function autologin() {
        $result = FALSE;

        //if ($auto = $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name')) AND ! $this->ci->session->userdata('DX_logged_in'))
        if ($auto = $this->ci->input->cookie($this->ci->config->item('DX_autologin_cookie_name'))) {
Severity: Minor
Found in application/libraries/DX_Auth.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

    public function is_email_available($email) {
        // Load Models
        $this->ci->load->model('dx_auth/users', 'users');
        $this->ci->load->model('dx_auth/user_temp', 'user_temp');

Severity: Minor
Found in application/libraries/DX_Auth.php and 1 other location - About 30 mins to fix
application/libraries/DX_Auth.php on lines 736..745

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

    public function is_username_available($username) {
        // Load Models
        $this->ci->load->model('dx_auth/users', 'users');
        $this->ci->load->model('dx_auth/user_temp', 'user_temp');

Severity: Minor
Found in application/libraries/DX_Auth.php and 1 other location - About 30 mins to fix
application/libraries/DX_Auth.php on lines 749..758

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