modxcms/revolution

View on GitHub
core/model/modx/xmlrss/extlib/snoopy.class.php

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php

/*************************************************
 *
 * Snoopy - the PHP net client
Severity: Major
Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 1 day to fix

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

        function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "")
        {
            $cookie_headers = '';
            if ($this->passcookies && $this->_redirectaddr)
                $this->setcookies();
    Severity: Minor
    Found in core/model/modx/xmlrss/extlib/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 submit has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        function submit($URI, $formvars = "", $formfiles = "")
        {
            unset($postdata);
    
            $postdata = $this->_prepare_post_body($formvars, $formfiles);
    Severity: Minor
    Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 7 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 fetch has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        function fetch($URI)
        {
    
            $URI_PARTS = parse_url($URI);
            if (!empty($URI_PARTS["user"]))
    Severity: Minor
    Found in core/model/modx/xmlrss/extlib/snoopy.class.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 _httprequest has 125 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "")
        {
            $cookie_headers = '';
            if ($this->passcookies && $this->_redirectaddr)
                $this->setcookies();
    Severity: Major
    Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 5 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");
              $postdata = '';
      Severity: Minor
      Found in core/model/modx/xmlrss/extlib/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

      Function _connect has a Cognitive Complexity of 22 (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 core/model/modx/xmlrss/extlib/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 submit has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function submit($URI, $formvars = "", $formfiles = "")
          {
              unset($postdata);
      
              $postdata = $this->_prepare_post_body($formvars, $formfiles);
      Severity: Major
      Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 2 hrs to fix

        Method _connect has 64 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: Major
        Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 2 hrs to fix

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

              function fetch($URI)
              {
          
                  $URI_PARTS = parse_url($URI);
                  if (!empty($URI_PARTS["user"]))
          Severity: Major
          Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 2 hrs to fix

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

                function submittext($URI, $formvars = "", $formfiles = "")
                {
                    if ($this->submit($URI, $formvars, $formfiles) !== false) {
                        if ($this->lastredirectaddr)
                            $URI = $this->lastredirectaddr;
            Severity: Minor
            Found in core/model/modx/xmlrss/extlib/snoopy.class.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

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

                function submitlinks($URI, $formvars = "", $formfiles = "")
                {
                    if ($this->submit($URI, $formvars, $formfiles) !== false) {
                        if ($this->lastredirectaddr)
                            $URI = $this->lastredirectaddr;
            Severity: Minor
            Found in core/model/modx/xmlrss/extlib/snoopy.class.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 _striptext has 50 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 core/model/modx/xmlrss/extlib/snoopy.class.php - About 2 hrs to fix

              Method _prepare_post_body has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function _prepare_post_body($formvars, $formfiles)
                  {
                      settype($formvars, "array");
                      settype($formfiles, "array");
                      $postdata = '';
              Severity: Minor
              Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 1 hr to fix

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

                    function fetchlinks($URI)
                    {
                        if ($this->fetch($URI) !== false) {
                            if ($this->lastredirectaddr)
                                $URI = $this->lastredirectaddr;
                Severity: Minor
                Found in core/model/modx/xmlrss/extlib/snoopy.class.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 fetchtext has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    function fetchtext($URI)
                    {
                        if ($this->fetch($URI) !== false) {
                            if (is_array($this->results)) {
                                for ($x = 0; $x < count($this->results); $x++)
                Severity: Minor
                Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 45 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

                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 core/model/modx/xmlrss/extlib/snoopy.class.php - About 45 mins to fix

                  Function fetchform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function fetchform($URI)
                      {
                  
                          if ($this->fetch($URI) !== false) {
                  
                  
                  Severity: Minor
                  Found in core/model/modx/xmlrss/extlib/snoopy.class.php - About 45 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 core/model/modx/xmlrss/extlib/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

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

                      function submitlinks($URI, $formvars = "", $formfiles = "")
                      {
                          if ($this->submit($URI, $formvars, $formfiles) !== false) {
                              if ($this->lastredirectaddr)
                                  $URI = $this->lastredirectaddr;
                  Severity: Major
                  Found in core/model/modx/xmlrss/extlib/snoopy.class.php and 1 other location - About 6 hrs to fix
                  core/model/modx/xmlrss/extlib/snoopy.class.php on lines 399..418

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

                  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

                      function submittext($URI, $formvars = "", $formfiles = "")
                      {
                          if ($this->submit($URI, $formvars, $formfiles) !== false) {
                              if ($this->lastredirectaddr)
                                  $URI = $this->lastredirectaddr;
                  Severity: Major
                  Found in core/model/modx/xmlrss/extlib/snoopy.class.php and 1 other location - About 6 hrs to fix
                  core/model/modx/xmlrss/extlib/snoopy.class.php on lines 371..390

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

                  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

                      function fetchtext($URI)
                      {
                          if ($this->fetch($URI) !== false) {
                              if (is_array($this->results)) {
                                  for ($x = 0; $x < count($this->results); $x++)
                  Severity: Major
                  Found in core/model/modx/xmlrss/extlib/snoopy.class.php and 1 other location - About 2 hrs to fix
                  core/model/modx/xmlrss/extlib/snoopy.class.php on lines 327..341

                  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

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

                      function fetchform($URI)
                      {
                  
                          if ($this->fetch($URI) !== false) {
                  
                  
                  Severity: Major
                  Found in core/model/modx/xmlrss/extlib/snoopy.class.php and 1 other location - About 2 hrs to fix
                  core/model/modx/xmlrss/extlib/snoopy.class.php on lines 351..362

                  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

                  There are no issues that match your filters.

                  Category
                  Status