OmarElGabry/miniPHP

View on GitHub

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
Severity: Major
Found in public/js/main.js - About 1 day to fix

    Validation has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Validation {
    
        /**
         * validation errors
         *
    Severity: Minor
    Found in app/models/Validation.php - About 4 hrs to fix

      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){
      Severity: Minor
      Found in app/models/Validation.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

      Database has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Database {
      
          /**
           * @access public
           * @var PDO PDO Object
      Severity: Minor
      Found in app/models/Database.php - About 3 hrs to fix

        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);
        Severity: Minor
        Found in app/models/Permission.php - About 3 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

        File Login.php has 298 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        /**
         * Login Class
         *
        Severity: Minor
        Found in app/models/Login.php - About 3 hrs to fix

          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);
          
          
          Severity: Minor
          Found in app/core/Encryption.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

          Request has 25 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Request{
          
              /**
               * Set a list of trusted hosts patterns.
               * 
          Severity: Minor
          Found in app/core/Request.php - About 2 hrs to fix

            File Validation.php has 276 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            /**
             * Validation class
             *
            Severity: Minor
            Found in app/models/Validation.php - About 2 hrs to fix

              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.
              
              
              Severity: Minor
              Found in app/core/Controller.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 isEmpty has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function isEmpty($value){
              
                      if(is_null($value)) {
                          return true;
                      }
              Severity: Minor
              Found in app/models/Validation.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 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);
              
              
              Severity: Minor
              Found in app/models/User.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 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);
              
              
              Severity: Major
              Found in app/models/User.php - About 2 hrs to fix

                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);
                
                
                Severity: Minor
                Found in public/js/main.js - 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 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){
                Severity: Minor
                Found in app/models/Permission.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 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;
                Severity: Minor
                Found in app/models/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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function run(){
                
                        // split the requested URL
                        $this->splitUrl();
                
                
                Severity: Minor
                Found in app/core/App.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 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";
                Severity: Minor
                Found in app/models/Login.php - About 1 hr to fix

                  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();
                  Severity: Minor
                  Found in app/models/Uploader.php - About 1 hr to fix

                    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;
                    Severity: Minor
                    Found in app/models/Admin.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language