OmarElGabry/miniPHP

View on GitHub

Showing 119 of 119 total issues

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

    private function emailUnique($email){

        $database = Database::openConnection();

        // email is unique in the database, So, we can't have more than 2 same emails
Severity: Minor
Found in app/models/Validation.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 isForgottenPasswordTokenValid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function isForgottenPasswordTokenValid($userId, $passwordToken){

        if (empty($userId) || empty($passwordToken)) {
            return false;
        }
Severity: Minor
Found in app/models/Login.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

Method handleError has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static function handleError($errno, $errmsg, $filename, $linenum, $vars){
Severity: Minor
Found in app/core/Handler.php - About 35 mins to fix

    Method register has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function register($name, $email, $password, $confirmPassword, $captcha){
    Severity: Minor
    Found in app/models/Login.php - About 35 mins to fix

      Method doLogIn has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function doLogIn($email, $password, $rememberMe, $userIp, $userAgent){
      Severity: Minor
      Found in app/models/Login.php - About 35 mins to fix

        Function validateData has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            validateData: function (result, targetBlock, errorFunc, errorType, returnVal){
        Severity: Minor
        Found in public/js/main.js - About 35 mins to fix

          Method pagination has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static function pagination($table, $options, $values, $pageNum, $extraOffset = 0){
          Severity: Minor
          Found in app/models/Pagination.php - About 35 mins to fix

            Method updateProfileInfo has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function updateProfileInfo($userId, $name, $password, $email, $confirmEmail){
            Severity: Minor
            Found in app/models/User.php - About 35 mins to fix

              Method updateUserInfo has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function updateUserInfo($userId, $adminId, $name, $password, $role){
              Severity: Minor
              Found in app/models/Admin.php - About 35 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                         }else{
                             exec('mysql --user='.escapeshellcmd(Config::get('DB_USER')).' --password='.escapeshellcmd(Config::get('DB_PASS')).' '.escapeshellcmd(Config::get('DB_NAME')).' < '. APP . 'backups/' . $basename);
                         }
                Severity: Minor
                Found in app/models/Admin.php and 1 other location - About 35 mins to fix
                app/models/Admin.php on lines 261..265

                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 92.

                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

                         if($windows){
                             exec('C:\wamp\bin\mysql\mysql5.6.17\bin\mysql --user=' . escapeshellcmd(Config::get('DB_USER')) . ' --password=' . escapeshellcmd(Config::get('DB_PASS')) . ' ' . escapeshellcmd(Config::get('DB_NAME')) . ' < '.APP.'\backups\\' . $basename);
                         }else{
                             exec('mysql --user='.escapeshellcmd(Config::get('DB_USER')).' --password='.escapeshellcmd(Config::get('DB_PASS')).' '.escapeshellcmd(Config::get('DB_NAME')).' < '. APP . 'backups/' . $basename);
                         }
                Severity: Minor
                Found in app/models/Admin.php and 1 other location - About 35 mins to fix
                app/models/Admin.php on lines 263..265

                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 92.

                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

                Function doLogIn has a Cognitive Complexity of 7 (exceeds 5 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 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 send has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function send(){
                
                        $this->sendHeaders();
                
                        if ($this->file) {
                Severity: Minor
                Found in app/core/Response.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 _get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static function _get($key, $source){
                
                        if (!isset(self::$config[$source])) {
                
                            $config_file = APP . 'config/' . $source . '.php';
                Severity: Minor
                Found in app/core/Config.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 secureRequired has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function secureRequired(){
                        $key = "requireSecure";
                        if(!empty($this->config[$key])){
                            if (in_array($this->request->param('action'), $this->config[$key], true) || $this->config[$key] === ['*']) {
                                if (!$this->request->isSSL()) {
                Severity: Minor
                Found in app/core/components/SecurityComponent.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 sendEmail has a Cognitive Complexity of 7 (exceeds 5 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 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 updateEmail has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function updateEmail(){
                
                        $userId  = $this->request->query("id");
                        $userId  = empty($userId)? null: Encryption::decryptId($this->request->query("id"));
                        $token   = $this->request->query("token");
                Severity: Minor
                Found in app/controllers/UserController.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 init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    init: function (){
                
                        // initialize todo application event
                        events.todo.init();
                        
                Severity: Minor
                Found in public/js/main.js - 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

                Avoid too many return statements within this function.
                Open

                                return false;
                Severity: Major
                Found in public/js/main.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return true;
                  Severity: Major
                  Found in public/js/main.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language