modxcms/revolution

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

Summary

Maintainability
F
3 days
Test Coverage

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

<?php

/**
* Project:     MagpieRSS: a simple RSS integration tool
* File:        rss_parse.inc  - parse an RSS or Atom feed
Severity: Minor
Found in core/model/modx/xmlrss/magpierss.class.php - About 6 hrs to fix

    Function normalize has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        function normalize () {
            // if atom populate rss fields
            if ( $this->is_atom() ) {
                $this->channel['description'] = $this->channel['tagline'];
                for ( $i = 0; $i < count($this->items); $i++) {
    Severity: Minor
    Found in core/model/modx/xmlrss/magpierss.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 feed_start_element has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function feed_start_element($p, $element, $attrs) {
            $el = $element = strtolower($element);
            $attrs = array_change_key_case($attrs, CASE_LOWER);
    
            // check for a namespace, and split if found
    Severity: Major
    Found in core/model/modx/xmlrss/magpierss.class.php - About 3 hrs to fix

      Function feed_start_element has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          function feed_start_element($p, $element, $attrs) {
              $el = $element = strtolower($element);
              $attrs = array_change_key_case($attrs, CASE_LOWER);
      
              // check for a namespace, and split if found
      Severity: Minor
      Found in core/model/modx/xmlrss/magpierss.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 __construct has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function __construct($source, $output_encoding='ISO-8859-1',$input_encoding=null, $detect_encoding=true) {
              # if PHP xml isn't compiled in, die
              #
              if (!function_exists('xml_parser_create')) {
                  $this->error( "Failed to load PHP's XML Extension. " .
      Severity: Minor
      Found in core/model/modx/xmlrss/magpierss.class.php - About 1 hr to fix

        Method normalize has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function normalize () {
                // if atom populate rss fields
                if ( $this->is_atom() ) {
                    $this->channel['description'] = $this->channel['tagline'];
                    for ( $i = 0; $i < count($this->items); $i++) {
        Severity: Minor
        Found in core/model/modx/xmlrss/magpierss.class.php - About 1 hr to fix

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

              function append($el, $text) {
                  if (!$el) {
                      return;
                  }
                  if ( $this->current_namespace )
          Severity: Minor
          Found in core/model/modx/xmlrss/magpierss.class.php - About 1 hr to fix

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

                function append($el, $text) {
                    if (!$el) {
                        return;
                    }
                    if ( $this->current_namespace )
            Severity: Minor
            Found in core/model/modx/xmlrss/magpierss.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

            Method feed_end_element has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function feed_end_element ($p, $el) {
                    $el = strtolower($el);
            
                    if ( $el == 'item' or $el == 'entry' )
                    {
            Severity: Minor
            Found in core/model/modx/xmlrss/magpierss.class.php - About 1 hr to fix

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

                  function php4_create_parser($source, $in_enc, $detect) {
                      if ( !$detect ) {
                          return array(xml_parser_create($in_enc), $source);
                      }
              
              
              Severity: Minor
              Found in core/model/modx/xmlrss/magpierss.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

              Method php4_create_parser has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function php4_create_parser($source, $in_enc, $detect) {
                      if ( !$detect ) {
                          return array(xml_parser_create($in_enc), $source);
                      }
              
              
              Severity: Minor
              Found in core/model/modx/xmlrss/magpierss.class.php - About 1 hr to fix

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

                    function __construct($source, $output_encoding='ISO-8859-1',$input_encoding=null, $detect_encoding=true) {
                        # if PHP xml isn't compiled in, die
                        #
                        if (!function_exists('xml_parser_create')) {
                            $this->error( "Failed to load PHP's XML Extension. " .
                Severity: Minor
                Found in core/model/modx/xmlrss/magpierss.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 feed_end_element has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    function feed_end_element ($p, $el) {
                        $el = strtolower($el);
                
                        if ( $el == 'item' or $el == 'entry' )
                        {
                Severity: Minor
                Found in core/model/modx/xmlrss/magpierss.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

                Avoid too many return statements within this method.
                Open

                        return array(xml_parser_create(), $source);
                Severity: Major
                Found in core/model/modx/xmlrss/magpierss.class.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status