CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php

Summary

Maintainability
F
5 days
Test Coverage

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

    public function feed_or_html()
    {
        $len = strlen($this->file->body);
        $pos = strspn($this->file->body, "\x09\x0A\x0D\x20");

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_type has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_type()
    {
        if (isset($this->file->headers['content-type']))
        {
            if (!isset($this->file->headers['content-encoding'])

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 feed_or_html has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function feed_or_html()
    {
        $len = strlen($this->file->body);
        $pos = strspn($this->file->body, "\x09\x0A\x0D\x20");

    Method get_type has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function get_type()
        {
            if (isset($this->file->headers['content-type']))
            {
                if (!isset($this->file->headers['content-encoding'])

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

          public function unknown()
          {
              $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
              if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
                  || strtolower(substr($this->file->body, $ws, 5)) === '<html'

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

            public function unknown()
            {
                $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
                if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
                    || strtolower(substr($this->file->body, $ws, 5)) === '<html'

        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 image has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function image()
            {
                if (substr($this->file->body, 0, 6) === 'GIF87a'
                    || substr($this->file->body, 0, 6) === 'GIF89a')
                {
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.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 'image/bmp';
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return 'application/rss+xml';
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return 'text/html';
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return 'image/vnd.microsoft.icon';
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

                                  return $this->feed_or_html();
                  Severity: Major
                  Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $this->unknown();
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return $this->text_or_binary();
                      Severity: Major
                      Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

                                          return 'application/atom+xml';
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return 'text/html';
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return 'image/png';
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return 'image/jpeg';
                                Severity: Major
                                Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return 'image/vnd.microsoft.icon';
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return false;
                                    Severity: Major
                                    Found in Web.Admin/2014/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php - About 30 mins to fix

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

                                          public function feed_or_html()
                                          {
                                              $len = strlen($this->file->body);
                                              $pos = strspn($this->file->body, "\x09\x0A\x0D\x20");
                                      
                                      
                                      Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 13657..13731

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

                                      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 text_or_binary()
                                          {
                                              if (substr($this->file->body, 0, 2) === "\xFE\xFF"
                                                  || substr($this->file->body, 0, 2) === "\xFF\xFE"
                                                  || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF"
                                      Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 13555..13572

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

                                      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 ($official === 'unknown/unknown'
                                                      || $official === 'application/unknown')
                                                  {
                                                      return $this->unknown();
                                                  }
                                      Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 13512..13541

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

                                      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 (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
                                                  || strtolower(substr($this->file->body, $ws, 5)) === '<html'
                                                  || strtolower(substr($this->file->body, $ws, 7)) === '<script')
                                              {
                                                  return 'text/html';
                                      Web.Admin/2014/wordpress/wp-includes/class-simplepie.php on lines 13583..13617

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

                                      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