Admidio/admidio

View on GitHub
adm_program/system/classes/ChangeNotification.php

Summary

Maintainability
D
2 days
Test Coverage

Function sendNotifications has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function sendNotifications(int $userID = 0)
    {
        global $gSettingsManager, $gL10n, $gCurrentUser;

        if ($gSettingsManager->has('system_notifications_profile_changes')
Severity: Minor
Found in adm_program/system/classes/ChangeNotification.php - About 4 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 sendNotifications has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function sendNotifications(int $userID = 0)
    {
        global $gSettingsManager, $gL10n, $gCurrentUser;

        if ($gSettingsManager->has('system_notifications_profile_changes')
Severity: Major
Found in adm_program/system/classes/ChangeNotification.php - About 3 hrs to fix

    File ChangeNotification.php has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    use Admidio\Exception;
    
    /**
     * @brief Object to collect change notifications and optionally send a message to the administrator
    Severity: Minor
    Found in adm_program/system/classes/ChangeNotification.php - About 2 hrs to fix

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

          public function logUserDeletion(int $userID, User $user = null)
          {
              global $gProfileFields, $gL10n, $gDb;
      
              // If user wasn't yet created in the DB, no need to log anything
      Severity: Minor
      Found in adm_program/system/classes/ChangeNotification.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 logUserDeletion has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function logUserDeletion(int $userID, User $user = null)
          {
              global $gProfileFields, $gL10n, $gDb;
      
              // If user wasn't yet created in the DB, no need to log anything
      Severity: Minor
      Found in adm_program/system/classes/ChangeNotification.php - About 1 hr to fix

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

            public function logUserCreation(int $userID, User $user = null)
            {
                global $gProfileFields, $gDb;
        
                // If user was never created in the DB, no need to log
        Severity: Minor
        Found in adm_program/system/classes/ChangeNotification.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 logProfileChange has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function logProfileChange(int $userID, int $fieldId, string $fieldName, string $old_value, string $new_value, string $old_value_db = '', string $new_value_db = '', $user = null, bool $deleting = false)
        Severity: Major
        Found in adm_program/system/classes/ChangeNotification.php - About 1 hr to fix

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

              public function logUserCreation(int $userID, User $user = null)
              {
                  global $gProfileFields, $gDb;
          
                  // If user was never created in the DB, no need to log
          Severity: Minor
          Found in adm_program/system/classes/ChangeNotification.php - About 1 hr to fix

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

                public function logRoleChange(int $userID, string $roleName, string $fieldName, string $old_value, string $new_value, User $user = null, bool $deleting = false)
                {
                    global $gSettingsManager, $gL10n;
                    // Don't log anything if no User ID is set yet (e.g. user not yet saved to the database!)
                    if ($userID == 0) {
            Severity: Minor
            Found in adm_program/system/classes/ChangeNotification.php - About 1 hr to fix

              Function logRoleChange has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function logRoleChange(int $userID, string $roleName, string $fieldName, string $old_value, string $new_value, User $user = null, bool $deleting = false)
                  {
                      global $gSettingsManager, $gL10n;
                      // Don't log anything if no User ID is set yet (e.g. user not yet saved to the database!)
                      if ($userID == 0) {
              Severity: Minor
              Found in adm_program/system/classes/ChangeNotification.php - About 55 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 logRoleChange has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function logRoleChange(int $userID, string $roleName, string $fieldName, string $old_value, string $new_value, User $user = null, bool $deleting = false)
              Severity: Major
              Found in adm_program/system/classes/ChangeNotification.php - About 50 mins to fix

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

                    public function logUserChange(int $userID, string $fieldName, string $old_value, string $new_value, User $user = null)
                Severity: Minor
                Found in adm_program/system/classes/ChangeNotification.php - About 35 mins to fix

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

                      public function logUserChange(int $userID, string $fieldName, string $old_value, string $new_value, User $user = null)
                      {
                          global $gSettingsManager, $gL10n;
                  
                          // 1. Create a database log entry if so configured
                  Severity: Minor
                  Found in adm_program/system/classes/ChangeNotification.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