app/resto/core/dbfunctions/UsersFunctions.php

Summary

Maintainability
D
2 days
Test Coverage

File UsersFunctions.php has 334 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * Copyright 2018 Jérôme Gasperi
 *
Severity: Minor
Found in app/resto/core/dbfunctions/UsersFunctions.php - About 4 hrs to fix

    Method formatUserProfile has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function formatUserProfile($rawProfile)
        {
            // Empty profile
            $profile = array();
    
    
    Severity: Major
    Found in app/resto/core/dbfunctions/UsersFunctions.php - About 2 hrs to fix

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

          public function updateUserProfile($profile, $storageInfo)
          {
              if (!is_array($profile) || !isset($profile['email'])) {
                  RestoLogUtil::httpError(400);
              }
      Severity: Minor
      Found in app/resto/core/dbfunctions/UsersFunctions.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 formatPartialUserProfile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function formatPartialUserProfile($rawProfile)
          {
              
              $profile = array(
                  'id' => $rawProfile['id'],
      Severity: Minor
      Found in app/resto/core/dbfunctions/UsersFunctions.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 formatUserProfile has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function formatUserProfile($rawProfile)
          {
              // Empty profile
              $profile = array();
      
      
      Severity: Minor
      Found in app/resto/core/dbfunctions/UsersFunctions.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 updateUserProfile has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function updateUserProfile($profile, $storageInfo)
          {
              if (!is_array($profile) || !isset($profile['email'])) {
                  RestoLogUtil::httpError(400);
              }
      Severity: Minor
      Found in app/resto/core/dbfunctions/UsersFunctions.php - About 1 hr to fix

        Method formatPartialUserProfile has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function formatPartialUserProfile($rawProfile)
            {
                
                $profile = array(
                    'id' => $rawProfile['id'],
        Severity: Minor
        Found in app/resto/core/dbfunctions/UsersFunctions.php - About 1 hr to fix

          Method storeUserProfile has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function storeUserProfile($profile, $storageInfo)
              {
                  if (!is_array($profile) || !isset($profile['email'])) {
                      RestoLogUtil::httpError(400, 'Cannot save user profile - invalid user identifier');
                  }
          Severity: Minor
          Found in app/resto/core/dbfunctions/UsersFunctions.php - About 1 hr to fix

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

                public function getUsersProfiles($params, $userid)
                {
                    // Only returns activated profiles
                    $where = array(
                        'activated=1'
            Severity: Minor
            Found in app/resto/core/dbfunctions/UsersFunctions.php - About 1 hr to fix

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

                  private function getPicture($profile, $storageInfo = null)
                  {
                      // Create picture url from email
                      if (!isset($profile['picture'])) {
                          return 'https://robohash.org/' . md5($profile['email']) . '?gravatar=hashed&bgset=any&size=400x400';
              Severity: Minor
              Found in app/resto/core/dbfunctions/UsersFunctions.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 getUsersProfiles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getUsersProfiles($params, $userid)
                  {
                      // Only returns activated profiles
                      $where = array(
                          'activated=1'
              Severity: Minor
              Found in app/resto/core/dbfunctions/UsersFunctions.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 getUserProfile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getUserProfile($fieldName, $fieldValue, $params = array())
                  {
                      // Add followed and followme booleans
                      $fields = $this->userFields;
                      if (isset($params['from'])) {
              Severity: Minor
              Found in app/resto/core/dbfunctions/UsersFunctions.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 storeUserProfile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function storeUserProfile($profile, $storageInfo)
                  {
                      if (!is_array($profile) || !isset($profile['email'])) {
                          RestoLogUtil::httpError(400, 'Cannot save user profile - invalid user identifier');
                      }
              Severity: Minor
              Found in app/resto/core/dbfunctions/UsersFunctions.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

              There are no issues that match your filters.

              Category
              Status