OmarElGabry/miniPHP

View on GitHub

Showing 81 of 119 total issues

Method alphaID has 42 lines of code (exceeds 25 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 1 hr to fix

    Function update has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            update: function(){
                $("#list-newsfeed .header .edit").off('click').on('click', function() {
    
                    var newsfeedBody = $(this).parent().parent().parent().parent();
                    var newsfeedId   = newsfeedBody.attr("id");
    Severity: Minor
    Found in public/js/main.js - About 1 hr to fix

      Function update has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              update: function(){
      
                  $("#list-comments .header .edit").off('click').on('click', function() {
      
                      var commentBody = $(this).parent().parent().parent().parent();
      Severity: Minor
      Found in public/js/main.js - About 1 hr to fix

        Method sendEmail has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

             public static function sendEmail($type, $email, $userData, $data){
        
                 $mail             = new PHPMailer();
                 $mail->IsSMTP();
        
        
        Severity: Minor
        Found in app/core/Email.php - About 1 hr to fix

          Method updateEmail has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function updateEmail($userId, $emailToken){
          
                  if (empty($userId) || empty($emailToken)) {
                      return false;
                  }
          Severity: Minor
          Found in app/models/User.php - About 1 hr to fix

            Function upload has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                upload: function(url, fileData, callback){
            
                    $.ajax({
                        url: config.root + url,
                        type: "POST",
            Severity: Minor
            Found in public/js/main.js - About 1 hr to fix

              Function addError has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function addError($rule, $placeholder, $value, $args = []){
              
                      if(isset($this->ruleMessages[$rule])){
                          $this->errors[] = $this->ruleMessages[$rule];
                      }
              Severity: Minor
              Found in app/models/Validation.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function register($name, $email, $password, $confirmPassword, $captcha){
              
                      $isValid = true;
                      $validation = new Validation();
              
              
              Severity: Minor
              Found in app/models/Login.php - About 1 hr to fix

                Function validateData has 34 lines of code (exceeds 25 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

                  Method validate has 33 lines of code (exceeds 25 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 1 hr to fix

                    Function host has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function host(){
                    
                            if (!$host = Environment::get('HTTP_HOST')) {
                                if (!$host = $this->name()) {
                                    $host = Enviroment::get('SERVER_ADDR');
                    Severity: Minor
                    Found in app/core/Request.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 requestRequired has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function requestRequired(){
                            foreach (['Post', 'Ajax', 'Get'] as $method) {
                                $key = 'require' . $method;
                                if (!empty($this->config[$key])) {
                                    if (in_array($this->request->param('action'), $this->config[$key], true) || $this->config[$key] === ['*']) {
                    Severity: Minor
                    Found in app/core/components/SecurityComponent.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 upload has a Cognitive Complexity of 11 (exceeds 5 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

                    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 getUsers has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getUsers($name = null, $email = null, $role = null, $pageNum = 1){
                    
                            // validate user inputs
                            $validation = new Validation();
                            if(!$validation->validate([
                    Severity: Minor
                    Found in app/models/Admin.php - About 1 hr to fix

                      Function send has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          send: function(url, postData, callback, spinnerBlock){
                      
                              var spinnerEle = null;
                      
                              $.ajax({
                      Severity: Minor
                      Found in public/js/main.js - About 1 hr to fix

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

                            public function updateEmail($userId, $emailToken){
                        
                                if (empty($userId) || empty($emailToken)) {
                                    return false;
                                }
                        Severity: Minor
                        Found in app/models/User.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 startup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function startup(){
                        
                                if(!$this->requestRequired()){
                                    return $this->invalidRequest();
                                }
                        Severity: Minor
                        Found in app/core/components/SecurityComponent.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 triggerComponents has 27 lines of code (exceeds 25 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 1 hr to fix

                          Method isCookieValid has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function isCookieValid(){
                          
                                  // "auth" or "remember me" cookie
                                  if(empty($_COOKIE['auth'])) {
                                      return false;
                          Severity: Minor
                          Found in app/core/Cookie.php - About 1 hr to fix

                            Method isEmailVerificationTokenValid has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function isEmailVerificationTokenValid($userId, $emailToken){
                            
                                    if (empty($userId) || empty($emailToken)) {
                                        return false;
                                    }
                            Severity: Minor
                            Found in app/models/Login.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language