wikimedia/mediawiki-core

View on GitHub
includes/mail/EmailNotification.php

Summary

Maintainability
F
3 days
Test Coverage

File EmailNotification.php has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Classes used to send e-mails
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in includes/mail/EmailNotification.php - About 5 hrs to fix

    Method composeCommonMailtext has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function composeCommonMailtext( MessageCache $messageCache ) {
            $services = MediaWikiServices::getInstance();
            $config = $services->getMainConfig();
            $userOptionsLookup = $services->getUserOptionsLookup();
    
    
    Severity: Major
    Found in includes/mail/EmailNotification.php - About 3 hrs to fix

      Function actuallyNotifyOnPageChange has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function actuallyNotifyOnPageChange(
              Authority $editor,
              $title,
              $timestamp,
              $summary,
      Severity: Minor
      Found in includes/mail/EmailNotification.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

      Method actuallyNotifyOnPageChange has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actuallyNotifyOnPageChange(
              Authority $editor,
              $title,
              $timestamp,
              $summary,
      Severity: Major
      Found in includes/mail/EmailNotification.php - About 2 hrs to fix

        Method notifyOnPageChange has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function notifyOnPageChange(
                Authority $editor,
                $title,
                $timestamp,
                $summary,
        Severity: Minor
        Found in includes/mail/EmailNotification.php - About 1 hr to fix

          Function notifyOnPageChange has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function notifyOnPageChange(
                  Authority $editor,
                  $title,
                  $timestamp,
                  $summary,
          Severity: Minor
          Found in includes/mail/EmailNotification.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 canSendUserTalkEmail has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              private function canSendUserTalkEmail( UserIdentity $editor, $title, $minorEdit ) {
                  $services = MediaWikiServices::getInstance();
                  $config = $services->getMainConfig();
          
                  if ( !$config->get( MainConfigNames::EnotifUserTalk ) || $title->getNamespace() !== NS_USER_TALK ) {
          Severity: Minor
          Found in includes/mail/EmailNotification.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

          Consider simplifying this complex logical expression.
          Open

                              if ( $userOptionsLookup->getOption( $watchingUser, 'enotifwatchlistpages' )
                                  && ( !$minorEdit || $userOptionsLookup->getOption( $watchingUser, 'enotifminoredits' ) )
                                  && $watchingUser->isEmailConfirmed()
                                  && $watchingUser->getId() != $userTalkId
                                  && !in_array( $watchingUser->getName(),
          Severity: Critical
          Found in includes/mail/EmailNotification.php - About 1 hr to fix

            Method sendPersonalised has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function sendPersonalised( UserEmailContact $watchingUser, $source ): StatusValue {
                    // From the PHP manual:
                    //   Note: The to parameter cannot be an address in the form of
                    //   "Something <someone@example.com>". The mail command will not parse
                    //   this properly while talking with the MTA.
            Severity: Minor
            Found in includes/mail/EmailNotification.php - About 1 hr to fix

              Function composeCommonMailtext has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function composeCommonMailtext( MessageCache $messageCache ) {
                      $services = MediaWikiServices::getInstance();
                      $config = $services->getMainConfig();
                      $userOptionsLookup = $services->getUserOptionsLookup();
              
              
              Severity: Minor
              Found in includes/mail/EmailNotification.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 canSendUserTalkEmail has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function canSendUserTalkEmail( UserIdentity $editor, $title, $minorEdit ) {
                      $services = MediaWikiServices::getInstance();
                      $config = $services->getMainConfig();
              
                      if ( !$config->get( MainConfigNames::EnotifUserTalk ) || $title->getNamespace() !== NS_USER_TALK ) {
              Severity: Minor
              Found in includes/mail/EmailNotification.php - About 1 hr to fix

                Method sendImpersonal has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function sendImpersonal( array $addresses ): ?StatusValue {
                        if ( count( $addresses ) === 0 ) {
                            return null;
                        }
                        $services = MediaWikiServices::getInstance();
                Severity: Minor
                Found in includes/mail/EmailNotification.php - About 1 hr to fix

                  Method actuallyNotifyOnPageChange has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          Authority $editor,
                          $title,
                          $timestamp,
                          $summary,
                          $minorEdit,
                  Severity: Major
                  Found in includes/mail/EmailNotification.php - About 1 hr to fix

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

                            Authority $editor,
                            $title,
                            $timestamp,
                            $summary,
                            $minorEdit,
                    Severity: Major
                    Found in includes/mail/EmailNotification.php - About 50 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status