modxcms/revolution

View on GitHub
core/model/modx/xmlrss/rssfetch.class.php

Summary

Maintainability
D
2 days
Test Coverage

Function fetch_rss has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

function fetch_rss ($url) {
    // initialize constants
    init();

    if ( !isset($url) ) {
Severity: Minor
Found in core/model/modx/xmlrss/rssfetch.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 fetch_rss has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function fetch_rss ($url) {
    // initialize constants
    init();

    if ( !isset($url) ) {
Severity: Major
Found in core/model/modx/xmlrss/rssfetch.class.php - About 3 hrs to fix

    Function _response_to_rss has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    function _response_to_rss ($resp) {
        $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING );
    
        // if RSS parsed successfully
        if ( $rss and !$rss->ERROR) {
    Severity: Minor
    Found in core/model/modx/xmlrss/rssfetch.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 init has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    function init () {
        if ( defined('MAGPIE_INITALIZED') ) {
            return;
        }
        else {
    Severity: Minor
    Found in core/model/modx/xmlrss/rssfetch.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 init has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function init () {
        if ( defined('MAGPIE_INITALIZED') ) {
            return;
        }
        else {
    Severity: Minor
    Found in core/model/modx/xmlrss/rssfetch.class.php - About 1 hr to fix

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

      function _response_to_rss ($resp) {
          $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING );
      
          // if RSS parsed successfully
          if ( $rss and !$rss->ERROR) {
      Severity: Minor
      Found in core/model/modx/xmlrss/rssfetch.class.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                            return false;
        Severity: Major
        Found in core/model/modx/xmlrss/rssfetch.class.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return $rss;
          Severity: Major
          Found in core/model/modx/xmlrss/rssfetch.class.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $rss;
            Severity: Major
            Found in core/model/modx/xmlrss/rssfetch.class.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return false;
              Severity: Major
              Found in core/model/modx/xmlrss/rssfetch.class.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return $rss;
                Severity: Major
                Found in core/model/modx/xmlrss/rssfetch.class.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status