sferik/multi_xml

View on GitHub

Showing 11 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/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 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 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

                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

        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

          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

            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