mambax7/xnewsletter

View on GitHub
include/phpmailer/extras/htmlfilter.php

Summary

Maintainability
F
1 wk
Test Coverage

Function tln_sanitize has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring.
Open

function tln_sanitize(
    $body,
    $tag_list,
    $rm_tags_with_content,
    $self_closing_tags,
Severity: Minor
Found in include/phpmailer/extras/htmlfilter.php - About 2 days to fix

Cognitive Complexity

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

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

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

Further reading

File htmlfilter.php has 690 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * htmlfilter.inc
 * ---------------
 * This set of functions allows you to filter html in order to remove
Severity: Major
Found in include/phpmailer/extras/htmlfilter.php - About 1 day to fix

    Function tln_getnxtag has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
    Open

    function tln_getnxtag($body, $offset)
    {
        if ($offset > mb_strlen($body)) {
            return false;
        }
    Severity: Minor
    Found in include/phpmailer/extras/htmlfilter.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 tln_fixatts has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

    function tln_fixatts(
        $tagname,
        $attary,
        $rm_attnames,
        $bad_attvals,
    Severity: Minor
    Found in include/phpmailer/extras/htmlfilter.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 tln_fixurl has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    function tln_fixurl($attname, &$attvalue, $trans_image_path, $block_external_images)
    {
        $sQuote   = '"';
        $attvalue = trim($attvalue);
        if ($attvalue && ('"' == $attvalue[0] || "'" == $attvalue[0])) {
    Severity: Minor
    Found in include/phpmailer/extras/htmlfilter.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 tln_fixstyle has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    function tln_fixstyle($body, $pos, $trans_image_path, $block_external_images)
    {
        // workaround for </style> in between comments
        $content = '';
        $sToken  = '';
    Severity: Minor
    Found in include/phpmailer/extras/htmlfilter.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

    Method tln_getnxtag has 136 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function tln_getnxtag($body, $offset)
    {
        if ($offset > mb_strlen($body)) {
            return false;
        }
    Severity: Major
    Found in include/phpmailer/extras/htmlfilter.php - About 5 hrs to fix

      Method tln_sanitize has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function tln_sanitize(
          $body,
          $tag_list,
          $rm_tags_with_content,
          $self_closing_tags,
      Severity: Major
      Found in include/phpmailer/extras/htmlfilter.php - About 3 hrs to fix

        Method HTMLFilter has 96 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function HTMLFilter($body, $trans_image_path, $block_external_images = false)
        {
            $tag_list = [
                false,
                'object',
        Severity: Major
        Found in include/phpmailer/extras/htmlfilter.php - About 3 hrs to fix

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

          function tln_fixstyle($body, $pos, $trans_image_path, $block_external_images)
          {
              // workaround for </style> in between comments
              $content = '';
              $sToken  = '';
          Severity: Major
          Found in include/phpmailer/extras/htmlfilter.php - About 3 hrs to fix

            Method tln_fixurl has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function tln_fixurl($attname, &$attvalue, $trans_image_path, $block_external_images)
            {
                $sQuote   = '"';
                $attvalue = trim($attvalue);
                if ($attvalue && ('"' == $attvalue[0] || "'" == $attvalue[0])) {
            Severity: Major
            Found in include/phpmailer/extras/htmlfilter.php - About 2 hrs to fix

              Method tln_fixatts has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function tln_fixatts(
                  $tagname,
                  $attary,
                  $rm_attnames,
                  $bad_attvals,
              Severity: Major
              Found in include/phpmailer/extras/htmlfilter.php - About 2 hrs to fix

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

                function tln_body2div($attary, $trans_image_path)
                {
                    $divattary   = ['class' => "'bodyclass'"];
                    $text        = '#000000';
                    $has_bgc_stl = $has_txt_stl = false;
                Severity: Minor
                Found in include/phpmailer/extras/htmlfilter.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 tln_sanitize has 10 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    $body,
                    $tag_list,
                    $rm_tags_with_content,
                    $self_closing_tags,
                    $force_tag_closing,
                Severity: Major
                Found in include/phpmailer/extras/htmlfilter.php - About 1 hr to fix

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

                  function tln_body2div($attary, $trans_image_path)
                  {
                      $divattary   = ['class' => "'bodyclass'"];
                      $text        = '#000000';
                      $has_bgc_stl = $has_txt_stl = false;
                  Severity: Minor
                  Found in include/phpmailer/extras/htmlfilter.php - About 1 hr to fix

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

                    function tln_tagprint($tagname, $attary, $tagtype)
                    {
                        if (2 == $tagtype) {
                            $fulltag = '</' . $tagname . '>';
                        } else {
                    Severity: Minor
                    Found in include/phpmailer/extras/htmlfilter.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 tln_fixatts has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        $tagname,
                        $attary,
                        $rm_attnames,
                        $bad_attvals,
                        $add_attr_to_tag,
                    Severity: Major
                    Found in include/phpmailer/extras/htmlfilter.php - About 50 mins to fix

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

                      function tln_deent(&$attvalue, $regex, $hex = false)
                      {
                          preg_match_all($regex, $attvalue, $matches);
                          if (is_array($matches) && count($matches[0]) > 0) {
                              $repl = [];
                      Severity: Minor
                      Found in include/phpmailer/extras/htmlfilter.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 [false, false, false, $lt, $gt];
                      Severity: Major
                      Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return [false, false, false, $lt, $gt];
                        Severity: Major
                        Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return [false, false, false, $lt, $pos];
                          Severity: Major
                          Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                        return [false, false, false, $lt, mb_strlen($body)];
                            Severity: Major
                            Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return [$tagname, false, $tagtype, $lt, $pos];
                              Severity: Major
                              Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return [$tagname, $attary, $tagtype, $lt, $pos];
                                Severity: Major
                                Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                              return [false, false, false, $lt, mb_strlen($body)];
                                  Severity: Major
                                  Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return [$tagname, $attary, $tagtype, $lt, $pos];
                                    Severity: Major
                                    Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return [false, false, false, $lt, $gt];
                                      Severity: Major
                                      Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return [false, false, false, $lt, mb_strlen($body)];
                                        Severity: Major
                                        Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                                      return [false, false, false, $lt, mb_strlen($body)];
                                          Severity: Major
                                          Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                            return $retary;
                                            Severity: Major
                                            Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                                  return $retary;
                                              Severity: Major
                                              Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                    return [false, false, false, $lt, mb_strlen($body)];
                                                Severity: Major
                                                Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return [false, false, false, $lt, mb_strlen($body)];
                                                  Severity: Major
                                                  Found in include/phpmailer/extras/htmlfilter.php - About 30 mins to fix

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

                                                                        } elseif ('"' == $quot) {
                                                                            $regary = tln_findnxreg($body, $pos + 1, '\"');
                                                                            if (false == $regary) {
                                                                                return [false, false, false, $lt, mb_strlen($body)];
                                                                            }
                                                    Severity: Major
                                                    Found in include/phpmailer/extras/htmlfilter.php and 1 other location - About 1 hr to fix
                                                    include/phpmailer/extras/htmlfilter.php on lines 392..422

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

                                                    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

                                                                        if ('\'' == $quot) {
                                                                            $regary = tln_findnxreg($body, $pos + 1, '\'');
                                                                            if (false == $regary) {
                                                                                return [false, false, false, $lt, mb_strlen($body)];
                                                                            }
                                                    Severity: Major
                                                    Found in include/phpmailer/extras/htmlfilter.php and 1 other location - About 1 hr to fix
                                                    include/phpmailer/extras/htmlfilter.php on lines 400..408

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

                                                    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

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

                                                                case '/':
                                                                    /**
                                                                     * This is an xhtml-style tag with a closing / at the
                                                                     * end, like so: <img src="blah"/>. Check if it's followed
                                                                     * by the closing bracket. If not, then this tag is invalid
                                                    Severity: Minor
                                                    Found in include/phpmailer/extras/htmlfilter.php and 1 other location - About 45 mins to fix
                                                    include/phpmailer/extras/htmlfilter.php on lines 241..255

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

                                                    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

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

                                                            case '/':
                                                                /**
                                                                 * This is an xhtml-style tag with a closing / at the
                                                                 * end, like so: <img src="blah"/>. Check if it's followed
                                                                 * by the closing bracket. If not, then this tag is invalid
                                                    Severity: Minor
                                                    Found in include/phpmailer/extras/htmlfilter.php and 1 other location - About 45 mins to fix
                                                    include/phpmailer/extras/htmlfilter.php on lines 346..360

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

                                                    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