piotrpolak/pepiscms

View on GitHub
pepiscms/application/models/User_model.php

Summary

Maintainability
F
3 days
Test Coverage

File User_model.php has 542 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * PepisCMS
 *
Severity: Major
Found in pepiscms/application/models/User_model.php - About 1 day to fix

    User_model has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class User_model extends Generic_model
    {
    
        /**
         * Minimum minimum allowed length of the password
    Severity: Minor
    Found in pepiscms/application/models/User_model.php - About 4 hrs to fix

      Method register has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function register($display_name, $user_email, $user_login = false, $password = false, $group_ids = array(), $is_root = false, $send_email_notification = true, $data = array(), $account_type = 0)
          {
              // If there is no password specified, lets generate one for the user
              if (!$password) {
                  $password = $this->generateEasyPassword($this->getMinimumAllowedPasswordLenght() + 2);
      Severity: Major
      Found in pepiscms/application/models/User_model.php - About 2 hrs to fix

        Function register has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public function register($display_name, $user_email, $user_login = false, $password = false, $group_ids = array(), $is_root = false, $send_email_notification = true, $data = array(), $account_type = 0)
            {
                // If there is no password specified, lets generate one for the user
                if (!$password) {
                    $password = $this->generateEasyPassword($this->getMinimumAllowedPasswordLenght() + 2);
        Severity: Minor
        Found in pepiscms/application/models/User_model.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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function update($user_id, $display_name, $user_login = false, $group_ids = false, $password = false, $is_root = null, $data = array())
            {
                // Change user password if specified
                if ($password) {
                    $this->changePasswordByUserId($user_id, $password);
        Severity: Minor
        Found in pepiscms/application/models/User_model.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 resetPasswordByUserId has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function resetPasswordByUserId($user_id)
            {
                // Reading user info
                $user = $this->getById($user_id, 'user_email, display_name');
                if (!$user) {
        Severity: Minor
        Found in pepiscms/application/models/User_model.php - About 1 hr to fix

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

              public function register($display_name, $user_email, $user_login = false, $password = false, $group_ids = array(), $is_root = false, $send_email_notification = true, $data = array(), $account_type = 0)
          Severity: Major
          Found in pepiscms/application/models/User_model.php - About 1 hr to fix

            Method validateByUserId has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function validateByUserId($user_id, $password)
                {
                    // Attempt to select user password metadata
                    $row = $this->db->select('user_id, hashing_salt, hashing_algorithm, hashing_iterations')
                        ->from($this->getTable())
            Severity: Minor
            Found in pepiscms/application/models/User_model.php - About 1 hr to fix

              Method validateByEmail has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function validateByEmail($user_email, $password)
                  {
                      // Attempt to select user password metadata
                      $row = $this->db->select('user_id, hashing_salt, hashing_algorithm, hashing_iterations')
                          ->from($this->getTable())
              Severity: Minor
              Found in pepiscms/application/models/User_model.php - About 1 hr to fix

                Method validateByLogin has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function validateByLogin($user_login, $password)
                    {
                        $row = $this->db->select('user_id, hashing_salt, hashing_algorithm, hashing_iterations')
                            ->from($this->getTable())
                            ->where('user_login', $user_login)
                Severity: Minor
                Found in pepiscms/application/models/User_model.php - About 1 hr to fix

                  Method update has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function update($user_id, $display_name, $user_login = false, $group_ids = false, $password = false, $is_root = null, $data = array())
                  Severity: Major
                  Found in pepiscms/application/models/User_model.php - About 50 mins to fix

                    Function resetPasswordByUserId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function resetPasswordByUserId($user_id)
                        {
                            // Reading user info
                            $user = $this->getById($user_id, 'user_email, display_name');
                            if (!$user) {
                    Severity: Minor
                    Found in pepiscms/application/models/User_model.php - About 25 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

                    There are no issues that match your filters.

                    Category
                    Status