travi/php-framework

View on GitHub
php/thirdparty/Snoopy/Snoopy.class.php

Summary

Maintainability
F
1 wk
Test Coverage

Function _httprequest has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
    {
        if($this->passcookies && $this->_redirectaddr)
            $this->setcookies();
            
Severity: Minor
Found in php/thirdparty/Snoopy/Snoopy.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

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

<?php

/*************************************************

Snoopy - the PHP net client
Severity: Major
Found in php/thirdparty/Snoopy/Snoopy.class.php - About 1 day to fix

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

        function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
        {
            if($this->passcookies && $this->_redirectaddr)
                $this->setcookies();
    
    Severity: Minor
    Found in php/thirdparty/Snoopy/Snoopy.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 fetch has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

        function fetch($URI)
        {
        
            //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
            $URI_PARTS = parse_url($URI);
    Severity: Minor
    Found in php/thirdparty/Snoopy/Snoopy.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 _httprequest has 132 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
        {
            if($this->passcookies && $this->_redirectaddr)
                $this->setcookies();
                
    Severity: Major
    Found in php/thirdparty/Snoopy/Snoopy.class.php - About 5 hrs to fix

      Method fetch has 109 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function fetch($URI)
          {
          
              //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
              $URI_PARTS = parse_url($URI);
      Severity: Major
      Found in php/thirdparty/Snoopy/Snoopy.class.php - About 4 hrs to fix

        Method _httpsrequest has 106 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
            {
                if($this->passcookies && $this->_redirectaddr)
                    $this->setcookies();
        
        Severity: Major
        Found in php/thirdparty/Snoopy/Snoopy.class.php - About 4 hrs to fix

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

              function _prepare_post_body($formvars, $formfiles)
              {
                  settype($formvars, "array");
                  settype($formfiles, "array");
          
          Severity: Minor
          Found in php/thirdparty/Snoopy/Snoopy.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 _prepare_post_body has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function _prepare_post_body($formvars, $formfiles)
              {
                  settype($formvars, "array");
                  settype($formfiles, "array");
          
          Severity: Minor
          Found in php/thirdparty/Snoopy/Snoopy.class.php - About 2 hrs to fix

            Method _connect has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function _connect(&$fp)
                {
                    if(!empty($this->proxy_host) && !empty($this->proxy_port))
                        {
                            $this->_isproxy = true;
            Severity: Minor
            Found in php/thirdparty/Snoopy/Snoopy.class.php - About 1 hr to fix

              Method _striptext has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function _striptext($document)
                  {
                      
                      // I didn't use preg eval (//e) since that is only available in PHP 4.0.
                      // so, list your entities one by one here. I included some of the
              Severity: Minor
              Found in php/thirdparty/Snoopy/Snoopy.class.php - About 1 hr to fix

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

                    function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
                Severity: Minor
                Found in php/thirdparty/Snoopy/Snoopy.class.php - About 45 mins to fix

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

                      function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
                  Severity: Minor
                  Found in php/thirdparty/Snoopy/Snoopy.class.php - About 35 mins to fix

                    Avoid too many return statements within this method.
                    Open

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

                      Avoid too many return statements within this method.
                      Open

                              return true;
                      Severity: Major
                      Found in php/thirdparty/Snoopy/Snoopy.class.php - About 30 mins to fix

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

                            function _connect(&$fp)
                            {
                                if(!empty($this->proxy_host) && !empty($this->proxy_port))
                                    {
                                        $this->_isproxy = true;
                        Severity: Minor
                        Found in php/thirdparty/Snoopy/Snoopy.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 _striplinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            function _striplinks($document)
                            {    
                                preg_match_all("'<\s*a\s+.*href\s*=\s*            # find <a href=
                                                ([\"\'])?                    # find single or double quote
                                                (?(1) (.*?)\\1 | ([^\s\>]+))        # if quote found, match up to next matching
                        Severity: Minor
                        Found in php/thirdparty/Snoopy/Snoopy.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

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

                                if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
                                {
                                    $this->results[] = $results;
                                    for($x=0; $x<count($match[1]); $x++)
                                        $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
                        Severity: Major
                        Found in php/thirdparty/Snoopy/Snoopy.class.php and 1 other location - About 3 hrs to fix
                        php/thirdparty/Snoopy/Snoopy.class.php on lines 714..725

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

                        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->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
                                {
                                    $this->results[] = $results;
                                    for($x=0; $x<count($match[1]); $x++)
                                        $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
                        Severity: Major
                        Found in php/thirdparty/Snoopy/Snoopy.class.php and 1 other location - About 3 hrs to fix
                        php/thirdparty/Snoopy/Snoopy.class.php on lines 565..576

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

                        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(!preg_match("|\:\/\/|",$matches[2]))
                                        {
                                            // no host in the path, so prepend
                                            $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
                                            // eliminate double slash
                        Severity: Major
                        Found in php/thirdparty/Snoopy/Snoopy.class.php and 1 other location - About 2 hrs to fix
                        php/thirdparty/Snoopy/Snoopy.class.php on lines 681..692

                        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(!preg_match("|\:\/\/|",$matches[2]))
                                        {
                                            // no host in the path, so prepend
                                            $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
                                            // eliminate double slash
                        Severity: Major
                        Found in php/thirdparty/Snoopy/Snoopy.class.php and 1 other location - About 2 hrs to fix
                        php/thirdparty/Snoopy/Snoopy.class.php on lines 504..515

                        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($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
                                            {
                                                $frameurls = $this->_frameurls;
                                                $this->_frameurls = array();
                                                
                        Severity: Major
                        Found in php/thirdparty/Snoopy/Snoopy.class.php and 1 other location - About 1 hr to fix
                        php/thirdparty/Snoopy/Snoopy.class.php on lines 232..247

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

                        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->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
                                        {
                                            $frameurls = $this->_frameurls;
                                            $this->_frameurls = array();
                        
                        Severity: Major
                        Found in php/thirdparty/Snoopy/Snoopy.class.php and 1 other location - About 1 hr to fix
                        php/thirdparty/Snoopy/Snoopy.class.php on lines 173..188

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

                        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