Showing 81 of 119 total issues
File main.js
has 595 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Document : main.js
* Author : Omar El Gabry <omar.elgabry.93@gmail.com>
* Description: Main Javascript file for the application.
* It handles all Ajax calls, Events, and DOM Manipulations
Validation
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class Validation {
/**
* validation errors
*
Function validate
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function validate($data, $skip = false){
$passed = true;
foreach($data as $placeholder => $rules){
- Read upRead up
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
Database
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class Database {
/**
* @access public
* @var PDO PDO Object
Function check
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function check($role, $resource, $action = "*", array $config = []){
// checks if action was allowed at least once
$allowed = false;
$action = strtolower($action);
- Read upRead up
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
File Login.php
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Login Class
*
Function alphaID
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public static function alphaID($in, $to_num = false, $pad_up = false, $pass_key = null) {
$out = '';
$index = 'abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$base = strlen($index);
- Read upRead up
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
Request
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class Request{
/**
* Set a list of trusted hosts patterns.
*
File Validation.php
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Validation class
*
Function triggerComponents
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private function triggerComponents(){
// You need to Fire the Components and Controller callbacks in the correct orde
// For example, Authorization depends on form element, so you need to trigger Security first.
- Read upRead up
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 isEmpty
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function isEmpty($value){
if(is_null($value)) {
return true;
}
- Read upRead up
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 updateProfileInfo
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function updateProfileInfo($userId, $name, $password, $email, $confirmEmail){
$database = Database::openConnection();
$curUser = $this->getProfileInfo($userId);
- Read upRead up
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 updateProfileInfo
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateProfileInfo($userId, $name, $password, $email, $confirmEmail){
$database = Database::openConnection();
$curUser = $this->getProfileInfo($userId);
Function validateData
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
validateData: function (result, targetBlock, errorFunc, errorType, returnVal){
// 1. clear all existing error or success messages
helpers.clearMessages(targetBlock);
- Read upRead up
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 deny
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function deny($role, $resource, $actions = "*"){
$actions = array_map("strtolower", (array)$actions);
foreach(self::$perms as $key => &$perm){
- Read upRead up
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 updateUserInfo
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function updateUserInfo($userId, $adminId, $name, $password, $role){
$user = $this->getProfileInfo($userId);
$name = (!empty($name) && $name !== $user["name"])? $name: null;
- Read upRead up
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 run
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function run(){
// split the requested URL
$this->splitUrl();
- Read upRead up
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 doLogIn
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doLogIn($email, $password, $rememberMe, $userIp, $userAgent){
// 1. check if user is blocked
if($this->isIpBlocked($userIp)) {
$this->errors[] = "Your IP Address has been blocked";
Method upload
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function upload($file, $dir, $id, $type = "file"){
$mimeTypes = self::getAllowedMime($type);
$validation = new Validation();
Method updateUserInfo
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateUserInfo($userId, $adminId, $name, $password, $role){
$user = $this->getProfileInfo($userId);
$name = (!empty($name) && $name !== $user["name"])? $name: null;