modxcms/revolution

View on GitHub
core/model/modx/mail/phpmailer/src/PHPMailer.php

Summary

Maintainability
F
1 mo
Test Coverage

File PHPMailer.php has 2804 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * PHPMailer - PHP email creation and transport class.
 * PHP Version 5.5.
Severity: Major
Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 wk to fix

    PHPMailer has 113 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PHPMailer
    {
        const CHARSET_ASCII = 'us-ascii';
        const CHARSET_ISO88591 = 'iso-8859-1';
        const CHARSET_UTF8 = 'utf-8';
    Severity: Major
    Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 2 days to fix

      Method createBody has 252 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function createBody()
          {
              $body = '';
              //Create unique IDs and preset boundaries
              $this->uniqueid = $this->generateId();
      Severity: Major
      Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 day to fix

        Function wrapText has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
        Open

            public function wrapText($message, $length, $qp_mode = false)
            {
                if ($qp_mode) {
                    $soft_break = sprintf(' =%s', static::$LE);
                } else {
        Severity: Minor
        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 day 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 smtpConnect has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
        Open

            public function smtpConnect($options = null)
            {
                if (null === $this->smtp) {
                    $this->smtp = $this->getSMTPInstance();
                }
        Severity: Minor
        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 7 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 createBody has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

            public function createBody()
            {
                $body = '';
                //Create unique IDs and preset boundaries
                $this->uniqueid = $this->generateId();
        Severity: Minor
        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 7 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 DKIM_Add has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
        Open

            public function DKIM_Add($headers_line, $subject, $body)
            {
                $DKIMsignatureType = 'rsa-sha256'; //Signature & hash algorithms
                $DKIMcanonicalization = 'relaxed/simple'; //Canonicalization methods of header & body
                $DKIMquery = 'dns/txt'; //Query method
        Severity: Minor
        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 6 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 attachAll has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function attachAll($disposition_type, $boundary)
            {
                //Return text of body
                $mime = [];
                $cidUniq = [];
        Severity: Minor
        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 6 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 msgHTML has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

            public function msgHTML($message, $basedir = '', $advanced = false)
            {
                preg_match_all('/(?<!-)(src|background)=["\'](.*)["\']/Ui', $message, $images);
                if (array_key_exists(2, $images)) {
                    if (strlen($basedir) > 1 && '/' !== substr($basedir, -1)) {
        Severity: Minor
        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 6 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 _mime_types has 119 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function _mime_types($ext = '')
            {
                $mimes = [
                    'xl' => 'application/excel',
                    'js' => 'application/javascript',
        Severity: Major
        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 4 hrs to fix

          Function preSend has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

              public function preSend()
              {
                  if (
                      'smtp' === $this->Mailer
                      || ('mail' === $this->Mailer && (\PHP_VERSION_ID >= 80000 || stripos(PHP_OS, 'WIN') === 0))
          Severity: Minor
          Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 DKIM_Add has 115 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function DKIM_Add($headers_line, $subject, $body)
              {
                  $DKIMsignatureType = 'rsa-sha256'; //Signature & hash algorithms
                  $DKIMcanonicalization = 'relaxed/simple'; //Canonicalization methods of header & body
                  $DKIMquery = 'dns/txt'; //Query method
          Severity: Major
          Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 4 hrs to fix

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

                public static function parseAddresses($addrstr, $useimap = true, $charset = self::CHARSET_ISO88591)
                {
                    $addresses = [];
                    if ($useimap && function_exists('imap_rfc822_parse_adrlist')) {
                        //Use this built-in parser if it's available
            Severity: Minor
            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 preSend has 98 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function preSend()
                {
                    if (
                        'smtp' === $this->Mailer
                        || ('mail' === $this->Mailer && (\PHP_VERSION_ID >= 80000 || stripos(PHP_OS, 'WIN') === 0))
            Severity: Major
            Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 3 hrs to fix

              Method smtpConnect has 98 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function smtpConnect($options = null)
                  {
                      if (null === $this->smtp) {
                          $this->smtp = $this->getSMTPInstance();
                      }
              Severity: Major
              Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 3 hrs to fix

                Function setLanguage has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function setLanguage($langcode = 'en', $lang_path = '')
                    {
                        //Backwards compatibility for renamed language codes
                        $renamed_langcodes = [
                            'br' => 'pt_br',
                Severity: Minor
                Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 setLanguage has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function setLanguage($langcode = 'en', $lang_path = '')
                    {
                        //Backwards compatibility for renamed language codes
                        $renamed_langcodes = [
                            'br' => 'pt_br',
                Severity: Major
                Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 3 hrs to fix

                  Function createHeader has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function createHeader()
                      {
                          $result = '';
                  
                          $result .= $this->headerLine('Date', '' === $this->MessageDate ? self::rfcDate() : $this->MessageDate);
                  Severity: Minor
                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

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

                      protected function sendmailSend($header, $body)
                      {
                          if ($this->Mailer === 'qmail') {
                              $this->edebug('Sending with qmail');
                          } else {
                  Severity: Minor
                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 attachAll has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function attachAll($disposition_type, $boundary)
                      {
                          //Return text of body
                          $mime = [];
                          $cidUniq = [];
                  Severity: Major
                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 3 hrs to fix

                    Method wrapText has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function wrapText($message, $length, $qp_mode = false)
                        {
                            if ($qp_mode) {
                                $soft_break = sprintf(' =%s', static::$LE);
                            } else {
                    Severity: Major
                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 3 hrs to fix

                      Method msgHTML has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function msgHTML($message, $basedir = '', $advanced = false)
                          {
                              preg_match_all('/(?<!-)(src|background)=["\'](.*)["\']/Ui', $message, $images);
                              if (array_key_exists(2, $images)) {
                                  if (strlen($basedir) > 1 && '/' !== substr($basedir, -1)) {
                      Severity: Major
                      Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 3 hrs to fix

                        Method createHeader has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function createHeader()
                            {
                                $result = '';
                        
                                $result .= $this->headerLine('Date', '' === $this->MessageDate ? self::rfcDate() : $this->MessageDate);
                        Severity: Major
                        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 3 hrs to fix

                          Method sendmailSend has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function sendmailSend($header, $body)
                              {
                                  if ($this->Mailer === 'qmail') {
                                      $this->edebug('Sending with qmail');
                                  } else {
                          Severity: Major
                          Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 2 hrs to fix

                            Function encodeHeader has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function encodeHeader($str, $position = 'text')
                                {
                                    $matchcount = 0;
                                    switch (strtolower($position)) {
                                        case 'phrase':
                            Severity: Minor
                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 smtpSend has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                            Open

                                protected function smtpSend($header, $body)
                                {
                                    $header = static::stripTrailingWSP($header) . static::$LE . static::$LE;
                                    $bad_rcpt = [];
                                    if (!$this->smtpConnect($this->SMTPOptions)) {
                            Severity: Minor
                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 encodeHeader has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function encodeHeader($str, $position = 'text')
                                {
                                    $matchcount = 0;
                                    switch (strtolower($position)) {
                                        case 'phrase':
                            Severity: Major
                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 2 hrs to fix

                              Method parseAddresses has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function parseAddresses($addrstr, $useimap = true, $charset = self::CHARSET_ISO88591)
                                  {
                                      $addresses = [];
                                      if ($useimap && function_exists('imap_rfc822_parse_adrlist')) {
                                          //Use this built-in parser if it's available
                              Severity: Major
                              Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 2 hrs to fix

                                Method smtpSend has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function smtpSend($header, $body)
                                    {
                                        $header = static::stripTrailingWSP($header) . static::$LE . static::$LE;
                                        $bad_rcpt = [];
                                        if (!$this->smtpConnect($this->SMTPOptions)) {
                                Severity: Major
                                Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 2 hrs to fix

                                  Method mailSend has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      protected function mailSend($header, $body)
                                      {
                                          $header = static::stripTrailingWSP($header) . static::$LE . static::$LE;
                                  
                                          $toArr = [];
                                  Severity: Minor
                                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

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

                                        protected function setError($msg)
                                        {
                                            ++$this->error_count;
                                            if ('smtp' === $this->Mailer && null !== $this->smtp) {
                                                $lasterror = $this->smtp->getError();
                                    Severity: Minor
                                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 utf8CharBoundary has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function utf8CharBoundary($encodedText, $maxLength)
                                        {
                                            $foundSplitPos = false;
                                            $lookBack = 3;
                                            while (!$foundSplitPos) {
                                    Severity: Minor
                                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 addAnAddress has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        protected function addAnAddress($kind, $address, $name = '')
                                        {
                                            if (!in_array($kind, ['to', 'cc', 'bcc', 'Reply-To'])) {
                                                $error_message = sprintf(
                                                    '%s: %s',
                                    Severity: Minor
                                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

                                      Method edebug has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          protected function edebug($str)
                                          {
                                              if ($this->SMTPDebug <= 0) {
                                                  return;
                                              }
                                      Severity: Minor
                                      Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

                                        Function punyencodeAddress has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            public function punyencodeAddress($address)
                                            {
                                                //Verify we have required functions, CharSet, and at-sign.
                                                $pos = strrpos($address, '@');
                                                if (
                                        Severity: Minor
                                        Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 getMailMIME has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            public function getMailMIME()
                                            {
                                                $result = '';
                                                $ismultipart = true;
                                                switch ($this->message_type) {
                                        Severity: Minor
                                        Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 mailSend has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            protected function mailSend($header, $body)
                                            {
                                                $header = static::stripTrailingWSP($header) . static::$LE . static::$LE;
                                        
                                                $toArr = [];
                                        Severity: Minor
                                        Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 validateAddress has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            public static function validateAddress($address, $patternselect = null)
                                            {
                                                if (null === $patternselect) {
                                                    $patternselect = static::$validator;
                                                }
                                        Severity: Minor
                                        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

                                          Method getMailMIME has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              public function getMailMIME()
                                              {
                                                  $result = '';
                                                  $ismultipart = true;
                                                  switch ($this->message_type) {
                                          Severity: Minor
                                          Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

                                            Method addAttachment has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                public function addAttachment(
                                                    $path,
                                                    $name = '',
                                                    $encoding = self::ENCODING_BASE64,
                                                    $type = '',
                                            Severity: Minor
                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

                                              Method addEmbeddedImage has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  public function addEmbeddedImage(
                                                      $path,
                                                      $cid,
                                                      $name = '',
                                                      $encoding = self::ENCODING_BASE64,
                                              Severity: Minor
                                              Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

                                                Method mb_pathinfo has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    public static function mb_pathinfo($path, $options = null)
                                                    {
                                                        $ret = ['dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''];
                                                        $pathinfo = [];
                                                        if (preg_match('#^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^.\\\\/]+?)|))[\\\\/.]*$#m', $path, $pathinfo)) {
                                                Severity: Minor
                                                Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

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

                                                      protected function addOrEnqueueAnAddress($kind, $address, $name)
                                                      {
                                                          $address = trim($address);
                                                          $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
                                                          $pos = strrpos($address, '@');
                                                  Severity: Minor
                                                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 addOrEnqueueAnAddress has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      protected function addOrEnqueueAnAddress($kind, $address, $name)
                                                      {
                                                          $address = trim($address);
                                                          $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
                                                          $pos = strrpos($address, '@');
                                                  Severity: Minor
                                                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

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

                                                        public function encodeString($str, $encoding = self::ENCODING_BASE64)
                                                        {
                                                            $encoded = '';
                                                            switch (strtolower($encoding)) {
                                                                case static::ENCODING_BASE64:
                                                    Severity: Minor
                                                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

                                                      Function addAnAddress has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                          protected function addAnAddress($kind, $address, $name = '')
                                                          {
                                                              if (!in_array($kind, ['to', 'cc', 'bcc', 'Reply-To'])) {
                                                                  $error_message = sprintf(
                                                                      '%s: %s',
                                                      Severity: Minor
                                                      Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 mb_pathinfo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                          public static function mb_pathinfo($path, $options = null)
                                                          {
                                                              $ret = ['dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''];
                                                              $pathinfo = [];
                                                              if (preg_match('#^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^.\\\\/]+?)|))[\\\\/.]*$#m', $path, $pathinfo)) {
                                                      Severity: Minor
                                                      Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 postSend has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                      Open

                                                          public function postSend()
                                                          {
                                                              try {
                                                                  //Choose the mailer and send through it
                                                                  switch ($this->Mailer) {
                                                      Severity: Minor
                                                      Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

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

                                                            public function setFrom($address, $name = '', $auto = true)
                                                            {
                                                                $address = trim($address);
                                                                $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
                                                                //Don't validate now addresses with IDN. Will be done in send().
                                                        Severity: Minor
                                                        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

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

                                                              public function addStringAttachment(
                                                                  $string,
                                                                  $filename,
                                                                  $encoding = self::ENCODING_BASE64,
                                                                  $type = '',
                                                          Severity: Minor
                                                          Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

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

                                                                public function addStringEmbeddedImage(
                                                                    $string,
                                                                    $cid,
                                                                    $name = '',
                                                                    $encoding = self::ENCODING_BASE64,
                                                            Severity: Minor
                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

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

                                                                  protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from, $extra)
                                                              Severity: Major
                                                              Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

                                                                Consider simplifying this complex logical expression.
                                                                Open

                                                                        if (
                                                                            'mail' === $this->Mailer
                                                                            && ((\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70017)
                                                                                || (\PHP_VERSION_ID >= 70100 && \PHP_VERSION_ID < 70103))
                                                                            && ini_get('mail.add_x_header') === '1'
                                                                Severity: Major
                                                                Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 1 hr to fix

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

                                                                      public function DKIM_Sign($signHeader)
                                                                      {
                                                                          if (!defined('PKCS7_TEXT')) {
                                                                              if ($this->exceptions) {
                                                                                  throw new Exception($this->lang('extension_missing') . 'openssl');
                                                                  Severity: Minor
                                                                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 addEmbeddedImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                                  Open

                                                                          $path,
                                                                          $cid,
                                                                          $name = '',
                                                                          $encoding = self::ENCODING_BASE64,
                                                                          $type = '',
                                                                  Severity: Minor
                                                                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 45 mins to fix

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

                                                                        public function encodeString($str, $encoding = self::ENCODING_BASE64)
                                                                        {
                                                                            $encoded = '';
                                                                            switch (strtolower($encoding)) {
                                                                                case static::ENCODING_BASE64:
                                                                    Severity: Minor
                                                                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.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 postSend has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                                    Open

                                                                        public function postSend()
                                                                        {
                                                                            try {
                                                                                //Choose the mailer and send through it
                                                                                switch ($this->Mailer) {
                                                                    Severity: Minor
                                                                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

                                                                    Method addStringEmbeddedImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                                    Open

                                                                            $string,
                                                                            $cid,
                                                                            $name = '',
                                                                            $encoding = self::ENCODING_BASE64,
                                                                            $type = '',
                                                                    Severity: Minor
                                                                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 45 mins to fix

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

                                                                          public function encodeQ($str, $position = 'text')
                                                                          {
                                                                              //There should not be any EOL in the string
                                                                              $pattern = '';
                                                                              $encoded = str_replace(["\r", "\n"], '', $str);
                                                                      Severity: Minor
                                                                      Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

                                                                      Consider simplifying this complex logical expression.
                                                                      Open

                                                                                  if (
                                                                                      !empty($this->DKIM_domain)
                                                                                      && !empty($this->DKIM_selector)
                                                                                      && (!empty($this->DKIM_private_string)
                                                                                          || (!empty($this->DKIM_private)
                                                                      Severity: Major
                                                                      Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 40 mins to fix

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

                                                                            private function mailPassthru($to, $subject, $body, $header, $params)
                                                                        Severity: Minor
                                                                        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 35 mins to fix

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

                                                                                  $path,
                                                                                  $name = '',
                                                                                  $encoding = self::ENCODING_BASE64,
                                                                                  $type = '',
                                                                                  $disposition = 'attachment'
                                                                          Severity: Minor
                                                                          Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 35 mins to fix

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

                                                                                    $string,
                                                                                    $filename,
                                                                                    $encoding = self::ENCODING_BASE64,
                                                                                    $type = '',
                                                                                    $disposition = 'attachment'
                                                                            Severity: Minor
                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 35 mins to fix

                                                                              Function addEmbeddedImage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                  public function addEmbeddedImage(
                                                                                      $path,
                                                                                      $cid,
                                                                                      $name = '',
                                                                                      $encoding = self::ENCODING_BASE64,
                                                                              Severity: Minor
                                                                              Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

                                                                              Function addAttachment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                  public function addAttachment(
                                                                                      $path,
                                                                                      $name = '',
                                                                                      $encoding = self::ENCODING_BASE64,
                                                                                      $type = '',
                                                                              Severity: Minor
                                                                              Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

                                                                              Function DKIM_QP has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                  public function DKIM_QP($txt)
                                                                                  {
                                                                                      $line = '';
                                                                                      $len = strlen($txt);
                                                                                      for ($i = 0; $i < $len; ++$i) {
                                                                              Severity: Minor
                                                                              Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

                                                                              Function edebug has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                  protected function edebug($str)
                                                                                  {
                                                                                      if ($this->SMTPDebug <= 0) {
                                                                                          return;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                      return call_user_func_array([$this, 'addAnAddress'], $params);
                                                                              Severity: Major
                                                                              Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
                                                                                Severity: Major
                                                                                Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                          return false;
                                                                                  Severity: Major
                                                                                  Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                                    return filter_var($address, FILTER_VALIDATE_EMAIL) !== false;
                                                                                    Severity: Major
                                                                                    Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 30 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                              return false;
                                                                                      Severity: Major
                                                                                      Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 30 mins to fix

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                return false;
                                                                                        Severity: Major
                                                                                        Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 30 mins to fix

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                          return $ret;
                                                                                          Severity: Major
                                                                                          Found in core/model/modx/mail/phpmailer/src/PHPMailer.php - About 30 mins to fix

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

                                                                                                protected static function isShellSafe($string)
                                                                                                {
                                                                                                    //Future-proof
                                                                                                    if (
                                                                                                        escapeshellcmd($string) !== $string
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

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

                                                                                                public function addCustomHeader($name, $value = null)
                                                                                                {
                                                                                                    if (null === $value && strpos($name, ':') !== false) {
                                                                                                        //Value passed in as name:value
                                                                                                        list($name, $value) = explode(':', $name, 2);
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

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

                                                                                                protected function serverHostname()
                                                                                                {
                                                                                                    $result = '';
                                                                                                    if (!empty($this->Hostname)) {
                                                                                                        $result = $this->Hostname;
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

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

                                                                                                public function addStringEmbeddedImage(
                                                                                                    $string,
                                                                                                    $cid,
                                                                                                    $name = '',
                                                                                                    $encoding = self::ENCODING_BASE64,
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

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

                                                                                                public static function validateAddress($address, $patternselect = null)
                                                                                                {
                                                                                                    if (null === $patternselect) {
                                                                                                        $patternselect = static::$validator;
                                                                                                    }
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

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

                                                                                                public static function isValidHost($host)
                                                                                                {
                                                                                                    //Simple syntax limits
                                                                                                    if (
                                                                                                        empty($host)
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

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

                                                                                                public function setFrom($address, $name = '', $auto = true)
                                                                                                {
                                                                                                    $address = trim($address);
                                                                                                    $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
                                                                                                    //Don't validate now addresses with IDN. Will be done in send().
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.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

                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                            Open

                                                                                                        case 'attach':
                                                                                                            $body .= $mimepre;
                                                                                                            $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
                                                                                                            $body .= $this->encodeString($this->Body, $bodyEncoding);
                                                                                                            $body .= static::$LE;
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.php and 1 other location - About 30 mins to fix
                                                                                            core/model/modx/mail/phpmailer/src/PHPMailer.php on lines 2797..2803

                                                                                            Duplicated Code

                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                            Tuning

                                                                                            This issue has a mass of 90.

                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                            Refactorings

                                                                                            Further Reading

                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                            Open

                                                                                                        case 'inline':
                                                                                                            $body .= $mimepre;
                                                                                                            $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
                                                                                                            $body .= $this->encodeString($this->Body, $bodyEncoding);
                                                                                                            $body .= static::$LE;
                                                                                            Severity: Minor
                                                                                            Found in core/model/modx/mail/phpmailer/src/PHPMailer.php and 1 other location - About 30 mins to fix
                                                                                            core/model/modx/mail/phpmailer/src/PHPMailer.php on lines 2804..2810

                                                                                            Duplicated Code

                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                            Tuning

                                                                                            This issue has a mass of 90.

                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                            Refactorings

                                                                                            Further Reading

                                                                                            There are no issues that match your filters.

                                                                                            Category
                                                                                            Status