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');
}
- Create a ticketCreate a ticket
DX_Auth
has 54 functions (exceeds 20 allowed). Consider refactoring. Open
class DX_Auth
{
// Private
var $_banned;
- Create a ticketCreate a ticket
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');
- Read upRead up
- Create a ticketCreate a ticket
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');
- Read upRead up
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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');
- Read upRead up
- Create a ticketCreate a ticket
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()) {
- Read upRead up
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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) {
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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') != '') {
- Read upRead up
- Create a ticketCreate a ticket
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');
- Read upRead up
- Create a ticketCreate a ticket
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) {
- Create a ticketCreate a ticket
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) {
- Read upRead up
- Create a ticketCreate a ticket
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) {
- Read upRead up
- Create a ticketCreate a ticket
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'))) {
- Read upRead up
- Create a ticketCreate a ticket
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');
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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');
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76