CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php

Summary

Maintainability
F
6 days
Test Coverage

Function sanitize has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
Open

    public function sanitize($data, $type, $base = '')
    {
        $data = trim($data);
        if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI)
        {
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.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

File Sanitize.php has 418 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * SimplePie
 *
 * A PHP-Based RSS and Atom Feed Framework.
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php - About 6 hrs to fix

    Function strip_tag has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function strip_tag($tag, $document, $type)
        {
            $xpath = new DOMXPath($document);
            $elements = $xpath->query('body//' . $tag);
            if ($this->encode_instead_of_strip)
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.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 sanitize has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function sanitize($data, $type, $base = '')
        {
            $data = trim($data);
            if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI)
            {
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php - About 5 hrs to fix

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

          protected function strip_tag($tag, $document, $type)
          {
              $xpath = new DOMXPath($document);
              $elements = $xpath->query('body//' . $tag);
              if ($this->encode_instead_of_strip)
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php - About 2 hrs to fix

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

            public function replace_urls($document, $tag, $attributes)
            {
                if (!is_array($attributes))
                {
                    $attributes = array($attributes);
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.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

        Avoid deeply nested control flow statements.
        Open

                                        if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
                                        {
                                            if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
                                            {
                                                $img->setAttribute('src', $this->image_handler . $image_url);
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php - About 45 mins to fix

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

              public function do_strip_htmltags($match)
              {
                  if ($this->encode_instead_of_strip)
                  {
                      if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.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

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

              public function do_strip_htmltags($match)
              {
                  if ($this->encode_instead_of_strip)
                  {
                      if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php and 1 other location - About 7 hrs to fix
          Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 14975..14998

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

          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

              public function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'))
              {
                  if ($tags)
                  {
                      if (is_array($tags))
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php and 1 other location - About 2 hrs to fix
          Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 14746..14763

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

          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

              public function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))
              {
                  if ($attribs)
                  {
                      if (is_array($attribs))
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php and 1 other location - About 1 hr to fix
          Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 14770..14787

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

          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

                          if ($this->remove_div)
                          {
                              $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
                              $data = preg_replace('/<\/div>$/', '', $data);
                          }
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Sanitize.php and 1 other location - About 35 mins to fix
          Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 14836..14844

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

          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