elcodedocle/phpass

View on GitHub

Showing 21 of 21 total issues

Function set_hash_method has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    function set_hash_method($hash_method = null){
        if ($hash_method === null){
            if (function_exists('password_hash') && !$this->full_compat){
                $this->hash_method = 'password_hash';
            } else if (CRYPT_BLOWFISH){
Severity: Minor
Found in PasswordHash.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 PasswordHash.php has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/** 
 * Portable PHP password hashing framework.
 *
 * Version 0.3 / SynappV2 (by elcodedocle, 2014).
Severity: Minor
Found in PasswordHash.php - About 2 hrs to fix

    Function HashPassword has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        function HashPassword($password, $hash_method = null)
        {
            if ($hash_method === null){
                $hash_method = $this->hash_method;
            } else if (!$this->is_valid_hash_method($hash_method)){
    Severity: Minor
    Found in PasswordHash.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 crypt_private has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function crypt_private($password, $setting)
        {
            $output = '*0';
            if (substr($setting, 0, 2) == $output)
                $output = '*1';
    Severity: Minor
    Found in PasswordHash.php - About 1 hr to fix

      Function gensalt_private has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          function gensalt_private($input, $hash_method = null)
          {
              if ($hash_method === null){
                  $hash_method = $this->hash_method;
              }
      Severity: Minor
      Found in PasswordHash.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 crypt_private has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          function crypt_private($password, $setting)
          {
              $output = '*0';
              if (substr($setting, 0, 2) == $output)
                  $output = '*1';
      Severity: Minor
      Found in PasswordHash.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 is_valid_hash_method has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          function is_valid_hash_method($hash_method, $portable_hashes = false){
              switch ($hash_method){
                  case 'password_hash':
                      if (function_exists('password_hash') && !$portable_hashes){
                          return true;
      Severity: Minor
      Found in PasswordHash.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 HashPassword has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function HashPassword($password, $hash_method = null)
          {
              if ($hash_method === null){
                  $hash_method = $this->hash_method;
              } else if (!$this->is_valid_hash_method($hash_method)){
      Severity: Minor
      Found in PasswordHash.php - About 1 hr to fix

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

            function is_valid_hash_method($hash_method, $portable_hashes = false){
                switch ($hash_method){
                    case 'password_hash':
                        if (function_exists('password_hash') && !$portable_hashes){
                            return true;
        Severity: Minor
        Found in PasswordHash.php - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                          } else { return false; }
          Severity: Major
          Found in PasswordHash.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            } else { return false; }
            Severity: Major
            Found in PasswordHash.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $output;
              Severity: Major
              Found in PasswordHash.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return true;
                Severity: Major
                Found in PasswordHash.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return false;
                  Severity: Major
                  Found in PasswordHash.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    } else { return false; }
                    Severity: Major
                    Found in PasswordHash.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return true;
                      Severity: Major
                      Found in PasswordHash.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return $hash;
                        Severity: Major
                        Found in PasswordHash.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return true;
                          Severity: Major
                          Found in PasswordHash.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    } else { return '*'; } // This is bad, and Solar Designer should feel bad.
                            Severity: Major
                            Found in PasswordHash.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return true;
                              Severity: Major
                              Found in PasswordHash.php - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language