CaffGeek/MBACNationals

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

Summary

Maintainability
F
3 days
Test Coverage

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

    protected function search_elements_by_tag($name, &$done, $feeds)
    {
        if ($this->dom === null)
        {
            throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.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 get_links has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_links()
    {
        if ($this->dom === null)
        {
            throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.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

File Locator.php has 289 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/Locator.php - About 2 hrs to fix

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

        public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
        {
            if ($this->is_feed($this->file))
            {
                return $this->file;
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.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 get_links has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function get_links()
        {
            if ($this->dom === null)
            {
                throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 1 hr to fix

      Method search_elements_by_tag has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function search_elements_by_tag($name, &$done, $feeds)
          {
              if ($this->dom === null)
              {
                  throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 1 hr to fix

        Method find has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
            {
                if ($this->is_feed($this->file))
                {
                    return $this->file;
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 1 hr to fix

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

              public function body(&$array)
              {
                  foreach ($array as $key => $value)
                  {
                      if ($this->checked_feeds === $this->max_checked_feeds)
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.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 extension has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function extension(&$array)
              {
                  foreach ($array as $key => $value)
                  {
                      if ($this->checked_feeds === $this->max_checked_feeds)
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.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

          Consider simplifying this complex logical expression.
          Open

                          if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href]))
                          {
                              $this->checked_feeds++;
                              $headers = array(
                                  'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 1 hr to fix

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

                public function get_base()
                {
                    if ($this->dom === null)
                    {
                        throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.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

            Consider simplifying this complex logical expression.
            Open

                            if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
                            {
                                return $feed;
                            }
                            else
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                              if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
                              {
                                  return $feed;
                              }
                              else
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                                    if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
                                    {
                                        $feeds[$href] = $feed;
                                    }
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 40 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return $working;
                  Severity: Major
                  Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $working;
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return null;
                      Severity: Major
                      Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $working;
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php - About 30 mins to fix

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

                              public function is_feed($file)
                              {
                                  if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
                                  {
                                      $sniffer = $this->registry->create('Content_Type_Sniffer', array($file));
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.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

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

                                  if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
                                  {
                                      if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local))
                                      {
                                          return $working;
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Locator.php and 1 other location - About 4 hrs to fix
                          Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 14103..14124

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

                          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