wikimedia/mediawiki-core

View on GitHub
includes/mail/UserMailer.php

Summary

Maintainability
F
3 days
Test Coverage

Method sendInternal has 145 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected static function sendInternal(
        array $to,
        MailAddress $from,
        $subject,
        $body,
Severity: Major
Found in includes/mail/UserMailer.php - About 5 hrs to fix

    Function sendInternal has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function sendInternal(
            array $to,
            MailAddress $from,
            $subject,
            $body,
    Severity: Minor
    Found in includes/mail/UserMailer.php - About 5 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 UserMailer.php has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2 of the License, or
    Severity: Minor
    Found in includes/mail/UserMailer.php - About 2 hrs to fix

      Function send has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function send( $to, $from, $subject, $body, $options = [] ) {
              $services = MediaWikiServices::getInstance();
              $allowHTMLEmail = $services->getMainConfig()->get(
                  MainConfigNames::AllowHTMLEmail );
      
      
      Severity: Minor
      Found in includes/mail/UserMailer.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 send has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function send( $to, $from, $subject, $body, $options = [] ) {
              $services = MediaWikiServices::getInstance();
              $allowHTMLEmail = $services->getMainConfig()->get(
                  MainConfigNames::AllowHTMLEmail );
      
      
      Severity: Major
      Found in includes/mail/UserMailer.php - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                if (
                    !(
                        !is_array( $body ) &&
                        strlen( $body ) >= $minBodyLen
                    )
        Severity: Major
        Found in includes/mail/UserMailer.php - About 1 hr to fix

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

              public static function send( $to, $from, $subject, $body, $options = [] ) {
          Severity: Minor
          Found in includes/mail/UserMailer.php - About 35 mins to fix

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

                    array $to,
                    MailAddress $from,
                    $subject,
                    $body,
                    $options = []
            Severity: Minor
            Found in includes/mail/UserMailer.php - About 35 mins to fix

              Avoid too many return statements within this method.
              Open

                              return Status::newFatal( 'php-mail-error', self::$mErrorString );
              Severity: Major
              Found in includes/mail/UserMailer.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return Status::newGood();
                Severity: Major
                Found in includes/mail/UserMailer.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return Status::newFatal( 'pear-mail-error', $mail_object->getMessage() );
                  Severity: Major
                  Found in includes/mail/UserMailer.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return Status::newGood();
                    Severity: Major
                    Found in includes/mail/UserMailer.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return Status::newFatal( 'php-mail-error-unknown' );
                      Severity: Major
                      Found in includes/mail/UserMailer.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return $status;
                        Severity: Major
                        Found in includes/mail/UserMailer.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return Status::newGood();
                          Severity: Major
                          Found in includes/mail/UserMailer.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return Status::newFatal( 'php-mail-error', $ret );
                            Severity: Major
                            Found in includes/mail/UserMailer.php - About 30 mins to fix

                              There are no issues that match your filters.

                              Category
                              Status