qcminecraft/Carbon-Forum-F

View on GitHub
library/PHPMailer.class.php

Summary

Maintainability
F
3 wks
Test Coverage

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

<?php
/**
 * PHPMailer - PHP email creation and transport class.
 * PHP Version 5
 * @package PHPMailer
Severity: Major
Found in library/PHPMailer.class.php - About 6 days to fix

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

    class PHPMailer
    {
        /**
         * The PHPMailer Version number.
         * @var string
    Severity: Major
    Found in library/PHPMailer.class.php - About 1 day to fix

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

          public function wrapText($message, $length, $qp_mode = false)
          {
              if ($qp_mode) {
                  $soft_break = sprintf(' =%s', $this->LE);
              } else {
      Severity: Minor
      Found in library/PHPMailer.class.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 attachAll has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function attachAll($disposition_type, $boundary)
          {
              // Return text of body
              $mime = array();
              $cidUniq = array();
      Severity: Minor
      Found in library/PHPMailer.class.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

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

          public function createBody()
          {
              $body = '';
              //Create unique IDs and preset boundaries
              $this->uniqueid = md5(uniqid(time()));
      Severity: Major
      Found in library/PHPMailer.class.php - About 7 hrs to fix

        Function smtpConnect has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
        Open

            public function smtpConnect($options = null)
            {
                if (is_null($this->smtp)) {
                    $this->smtp = $this->getSMTPInstance();
                }
        Severity: Minor
        Found in library/PHPMailer.class.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 34 (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)) {
                    foreach ($images[2] as $imgindex => $url) {
        Severity: Minor
        Found in library/PHPMailer.class.php - About 5 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

            public function createBody()
            {
                $body = '';
                //Create unique IDs and preset boundaries
                $this->uniqueid = md5(uniqid(time()));
        Severity: Minor
        Found in library/PHPMailer.class.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 _mime_types has 104 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function _mime_types($ext = '')
            {
                $mimes = array(
                    'xl'    => 'application/excel',
                    'js'    => 'application/javascript',
        Severity: Major
        Found in library/PHPMailer.class.php - About 4 hrs to fix

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

              public function createHeader()
              {
                  $result = '';
          
                  if ($this->MessageDate == '') {
          Severity: Minor
          Found in library/PHPMailer.class.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 attachAll has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function attachAll($disposition_type, $boundary)
              {
                  // Return text of body
                  $mime = array();
                  $cidUniq = array();
          Severity: Major
          Found in library/PHPMailer.class.php - About 3 hrs to fix

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

                public function parseAddresses($addrstr, $useimap = true)
                {
                    $addresses = array();
                    if ($useimap and function_exists('imap_rfc822_parse_adrlist')) {
                        //Use this built-in parser if it's available
            Severity: Minor
            Found in library/PHPMailer.class.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 smtpConnect has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function smtpConnect($options = null)
                {
                    if (is_null($this->smtp)) {
                        $this->smtp = $this->getSMTPInstance();
                    }
            Severity: Major
            Found in library/PHPMailer.class.php - About 3 hrs to fix

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

                  protected function sendmailSend($header, $body)
                  {
                      if ($this->Sender != '') {
                          if ($this->Mailer == 'qmail') {
                              $sendmail = sprintf('%s -f%s', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
              Severity: Minor
              Found in library/PHPMailer.class.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 preSend has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function preSend()
                  {
                      try {
                          $this->error_count = 0; // Reset errors
                          $this->mailHeader = '';
              Severity: Minor
              Found in library/PHPMailer.class.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 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', $this->LE);
                      } else {
              Severity: Major
              Found in library/PHPMailer.class.php - About 3 hrs to fix

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

                    public function createHeader()
                    {
                        $result = '';
                
                        if ($this->MessageDate == '') {
                Severity: Major
                Found in library/PHPMailer.class.php - About 2 hrs to fix

                  Method preSend has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function preSend()
                      {
                          try {
                              $this->error_count = 0; // Reset errors
                              $this->mailHeader = '';
                  Severity: Major
                  Found in library/PHPMailer.class.php - About 2 hrs to fix

                    Method DKIM_Add has 68 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 of header/body
                            $DKIMquery = 'dns/txt'; // Query method
                    Severity: Major
                    Found in library/PHPMailer.class.php - About 2 hrs to fix

                      Method validateAddress has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function validateAddress($address, $patternselect = null)
                          {
                              if (is_null($patternselect)) {
                                  $patternselect = self::$validator;
                              }
                      Severity: Major
                      Found in library/PHPMailer.class.php - About 2 hrs to fix

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

                            public static function validateAddress($address, $patternselect = null)
                            {
                                if (is_null($patternselect)) {
                                    $patternselect = self::$validator;
                                }
                        Severity: Minor
                        Found in library/PHPMailer.class.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 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function smtpSend($header, $body)
                            {
                                $bad_rcpt = array();
                                if (!$this->smtpConnect($this->SMTPOptions)) {
                                    throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
                        Severity: Minor
                        Found in library/PHPMailer.class.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 msgHTML has 56 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)) {
                                    foreach ($images[2] as $imgindex => $url) {
                        Severity: Major
                        Found in library/PHPMailer.class.php - About 2 hrs to fix

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

                              protected function sendmailSend($header, $body)
                              {
                                  if ($this->Sender != '') {
                                      if ($this->Mailer == 'qmail') {
                                          $sendmail = sprintf('%s -f%s', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
                          Severity: Major
                          Found in library/PHPMailer.class.php - About 2 hrs to fix

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

                                protected function smtpSend($header, $body)
                                {
                                    $bad_rcpt = array();
                                    if (!$this->smtpConnect($this->SMTPOptions)) {
                                        throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
                            Severity: Minor
                            Found in library/PHPMailer.class.php - About 1 hr to fix

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

                                  public function encodeHeader($str, $position = 'text')
                                  {
                                      $matchcount = 0;
                                      switch (strtolower($position)) {
                                          case 'phrase':
                              Severity: Minor
                              Found in library/PHPMailer.class.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 encodeHeader has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function encodeHeader($str, $position = 'text')
                                  {
                                      $matchcount = 0;
                                      switch (strtolower($position)) {
                                          case 'phrase':
                              Severity: Minor
                              Found in library/PHPMailer.class.php - About 1 hr to fix

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

                                    public function getMailMIME()
                                    {
                                        $result = '';
                                        $ismultipart = true;
                                        switch ($this->message_type) {
                                Severity: Minor
                                Found in library/PHPMailer.class.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 DKIM_Add has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    public function DKIM_Add($headers_line, $subject, $body)
                                    {
                                        $DKIMsignatureType = 'rsa-sha256'; // Signature & hash algorithms
                                        $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
                                        $DKIMquery = 'dns/txt'; // Query method
                                Severity: Minor
                                Found in library/PHPMailer.class.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 library/PHPMailer.class.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 addOrEnqueueAnAddress has a Cognitive Complexity of 13 (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
                                        if (($pos = strrpos($address, '@')) === false) {
                                Severity: Minor
                                Found in library/PHPMailer.class.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 getMailMIME has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

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

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

                                      public function parseAddresses($addrstr, $useimap = true)
                                      {
                                          $addresses = array();
                                          if ($useimap and function_exists('imap_rfc822_parse_adrlist')) {
                                              //Use this built-in parser if it's available
                                  Severity: Minor
                                  Found in library/PHPMailer.class.php - About 1 hr to fix

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

                                        protected function addAnAddress($kind, $address, $name = '')
                                        {
                                            if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) {
                                                $error_message = $this->lang('Invalid recipient kind: ') . $kind;
                                                $this->setError($error_message);
                                    Severity: Minor
                                    Found in library/PHPMailer.class.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 setError has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        protected function setError($msg)
                                        {
                                            $this->error_count++;
                                            if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
                                                $lasterror = $this->smtp->getError();
                                    Severity: Minor
                                    Found in library/PHPMailer.class.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 setLanguage has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function setLanguage($langcode = 'en', $lang_path = '')
                                        {
                                            // Define full set of translatable strings in English
                                            $PHPMAILER_LANG = array(
                                                'authenticate' => 'SMTP Error: Could not authenticate.',
                                    Severity: Minor
                                    Found in library/PHPMailer.class.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 = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
                                              $pathinfo = array();
                                              if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) {
                                      Severity: Minor
                                      Found in library/PHPMailer.class.php - About 1 hr to fix

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

                                            protected function addAnAddress($kind, $address, $name = '')
                                            {
                                                if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) {
                                                    $error_message = $this->lang('Invalid recipient kind: ') . $kind;
                                                    $this->setError($error_message);
                                        Severity: Minor
                                        Found in library/PHPMailer.class.php - About 1 hr to fix

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

                                              public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
                                              {
                                                  try {
                                                      if (!@is_file($path)) {
                                                          throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
                                          Severity: Minor
                                          Found in library/PHPMailer.class.php - About 1 hr to fix

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

                                                protected function mailSend($header, $body)
                                                {
                                                    $toArr = array();
                                                    foreach ($this->to as $toaddr) {
                                                        $toArr[] = $this->addrFormat($toaddr);
                                            Severity: Minor
                                            Found in library/PHPMailer.class.php - About 1 hr to fix

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

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

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

                                                    protected function encodeFile($path, $encoding = 'base64')
                                                    {
                                                        try {
                                                            if (!is_readable($path)) {
                                                                throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
                                                Severity: Minor
                                                Found in library/PHPMailer.class.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 = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
                                                        $pathinfo = array();
                                                        if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) {
                                                Severity: Minor
                                                Found in library/PHPMailer.class.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 27 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
                                                        if (($pos = strrpos($address, '@')) === false) {
                                                Severity: Minor
                                                Found in library/PHPMailer.class.php - About 1 hr to fix

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

                                                      protected function encodeFile($path, $encoding = 'base64')
                                                      {
                                                          try {
                                                              if (!is_readable($path)) {
                                                                  throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
                                                  Severity: Minor
                                                  Found in library/PHPMailer.class.php - About 1 hr to fix

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

                                                        protected function mailSend($header, $body)
                                                        {
                                                            $toArr = array();
                                                            foreach ($this->to as $toaddr) {
                                                                $toArr[] = $this->addrFormat($toaddr);
                                                    Severity: Minor
                                                    Found in library/PHPMailer.class.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 doCallback has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                        protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from)
                                                    Severity: Major
                                                    Found in library/PHPMailer.class.php - About 50 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(array("\r", "\n"), '', $str);
                                                      Severity: Minor
                                                      Found in library/PHPMailer.class.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 addEmbeddedImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                          public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
                                                      Severity: Minor
                                                      Found in library/PHPMailer.class.php - About 45 mins to fix

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

                                                                $string,
                                                                $cid,
                                                                $name = '',
                                                                $encoding = 'base64',
                                                                $type = '',
                                                        Severity: Minor
                                                        Found in library/PHPMailer.class.php - About 45 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 library/PHPMailer.class.php - About 35 mins to fix

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

                                                                public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
                                                            Severity: Minor
                                                            Found in library/PHPMailer.class.php - About 35 mins to fix

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

                                                                      $string,
                                                                      $filename,
                                                                      $encoding = 'base64',
                                                                      $type = '',
                                                                      $disposition = 'attachment'
                                                              Severity: Minor
                                                              Found in library/PHPMailer.class.php - About 35 mins to fix

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

                                                                    public function encodeString($str, $encoding = 'base64')
                                                                    {
                                                                        $encoded = '';
                                                                        switch (strtolower($encoding)) {
                                                                            case 'base64':
                                                                Severity: Minor
                                                                Found in library/PHPMailer.class.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 = '';
                                                                        for ($i = 0; $i < strlen($txt); $i++) {
                                                                            $ord = ord($txt[$i]);
                                                                Severity: Minor
                                                                Found in library/PHPMailer.class.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 (boolean)preg_match(
                                                                                    '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
                                                                                    '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
                                                                                    $address
                                                                                );
                                                                Severity: Major
                                                                Found in library/PHPMailer.class.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                  return (strlen($address) >= 3
                                                                                      and strpos($address, '@') >= 1
                                                                                      and strpos($address, '@') != strlen($address) - 1);
                                                                  Severity: Major
                                                                  Found in library/PHPMailer.class.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                            return false;
                                                                    Severity: Major
                                                                    Found in library/PHPMailer.class.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                              return call_user_func_array(array($this, 'addAnAddress'), $params);
                                                                      Severity: Major
                                                                      Found in library/PHPMailer.class.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                        return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL);
                                                                        Severity: Major
                                                                        Found in library/PHPMailer.class.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                  return false;
                                                                          Severity: Major
                                                                          Found in library/PHPMailer.class.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 library/PHPMailer.class.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                              return $ret;
                                                                              Severity: Major
                                                                              Found in library/PHPMailer.class.php - About 30 mins to fix

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

                                                                                    public function DKIM_Sign($signHeader)
                                                                                    {
                                                                                        if (!defined('PKCS7_TEXT')) {
                                                                                            if ($this->exceptions) {
                                                                                                throw new phpmailerException($this->lang('extension_missing') . 'openssl');
                                                                                Severity: Minor
                                                                                Found in library/PHPMailer.class.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 punyencodeAddress has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                Open

                                                                                    public function punyencodeAddress($address)
                                                                                    {
                                                                                        // Verify we have required functions, CharSet, and at-sign.
                                                                                        if ($this->idnSupported() and
                                                                                            !empty($this->CharSet) and
                                                                                Severity: Minor
                                                                                Found in library/PHPMailer.class.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 library/PHPMailer.class.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 addAttachment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                Open

                                                                                    public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
                                                                                    {
                                                                                        try {
                                                                                            if (!@is_file($path)) {
                                                                                                throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
                                                                                Severity: Minor
                                                                                Found in library/PHPMailer.class.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

                                                                                        switch ($this->Debugoutput) {
                                                                                            case 'error_log':
                                                                                                //Don't output, just log
                                                                                                error_log($str);
                                                                                                break;
                                                                                Severity: Major
                                                                                Found in library/PHPMailer.class.php and 1 other location - About 2 hrs to fix
                                                                                library/PHPMailer.smtp.class.php on lines 212..235

                                                                                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 130.

                                                                                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 'attach':
                                                                                                $body .= $mimepre;
                                                                                                $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
                                                                                                $body .= $this->encodeString($this->Body, $bodyEncoding);
                                                                                                $body .= $this->LE . $this->LE;
                                                                                Severity: Minor
                                                                                Found in library/PHPMailer.class.php and 1 other location - About 45 mins to fix
                                                                                library/PHPMailer.class.php on lines 2160..2166

                                                                                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 95.

                                                                                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 .= $this->LE . $this->LE;
                                                                                Severity: Minor
                                                                                Found in library/PHPMailer.class.php and 1 other location - About 45 mins to fix
                                                                                library/PHPMailer.class.php on lines 2167..2173

                                                                                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 95.

                                                                                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