sferik/multi_xml

View on GitHub

Showing 13 of 13 total issues

Method typecast_xml_value has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

    def typecast_xml_value(value, disallowed_types = nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
      disallowed_types ||= DISALLOWED_XML_TYPES

      case value
      when Hash
Severity: Minor
Found in lib/multi_xml.rb - 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 typecast_xml_value has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def typecast_xml_value(value, disallowed_types = nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
      disallowed_types ||= DISALLOWED_XML_TYPES

      case value
      when Hash
Severity: Major
Found in lib/multi_xml.rb - About 2 hrs to fix

    Method node_to_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def node_to_hash(node, hash = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
            node_hash = { MultiXml::CONTENT_ROOT => "" }
    
            name = node_name(node)
    
    
    Severity: Minor
    Found in lib/multi_xml/parsers/oga.rb - 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 node_to_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def node_to_hash(node, hash = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
            node_hash = { MultiXml::CONTENT_ROOT => "" }
    
            name = node_name(node)
    
    
    Severity: Minor
    Found in lib/multi_xml/parsers/libxml2_parser.rb - 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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse(xml, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
          xml ||= ""
    
          options = DEFAULT_OPTIONS.merge(options)
    
    
    Severity: Minor
    Found in lib/multi_xml.rb - About 55 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 deeply nested control flow statements.
    Open

              xml_value["file"].is_a?(StringIO) ? xml_value["file"] : xml_value
    Severity: Major
    Found in lib/multi_xml.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  value.keys.size > 1 ? value : content
      Severity: Major
      Found in lib/multi_xml.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if block.arity == 1
                      value.delete("type") if PARSING[value["type"]]
                      if value.keys.size > 1
                        value[CONTENT_ROOT] = block.call(content)
                        value
        Severity: Major
        Found in lib/multi_xml.rb - About 45 mins to fix

          Method default_parser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def default_parser
                return :ox if defined?(::Ox)
                return :libxml if defined?(::LibXML)
                return :nokogiri if defined?(::Nokogiri)
                return :oga if defined?(::Oga)
          Severity: Minor
          Found in lib/multi_xml.rb - 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 parser
          Severity: Major
          Found in lib/multi_xml.rb - About 30 mins to fix

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

                    case hash[name]
                    when Array
                      hash[name] << node_hash
                    when Hash
                      hash[name] = [hash[name], node_hash]
            Severity: Minor
            Found in lib/multi_xml/parsers/libxml2_parser.rb and 1 other location - About 25 mins to fix
            lib/multi_xml/parsers/oga.rb on lines 25..31

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

            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

                    case hash[name]
                    when Array
                      hash[name] << node_hash
                    when Hash
                      hash[name] = [hash[name], node_hash]
            Severity: Minor
            Found in lib/multi_xml/parsers/oga.rb and 1 other location - About 25 mins to fix
            lib/multi_xml/parsers/libxml2_parser.rb on lines 17..23

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

            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

            Method merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def merge!(hash, key, value)
                    if hash.key?(key)
                      if hash[key].instance_of?(Array)
                        hash[key] << value
                      else
            Severity: Minor
            Found in lib/multi_xml/parsers/rexml.rb - 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

            Severity
            Category
            Status
            Source
            Language