mvz/happymapper

View on GitHub
lib/happymapper/class_methods.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method parse has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(xml, options = {})
      # Capture any provided namespaces and merge in any namespaces that have
      # been registered on the object.
      namespaces = options[:namespaces] || {}
      namespaces = namespaces.merge(@registered_namespaces)
Severity: Minor
Found in lib/happymapper/class_methods.rb - 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 find_nodes_to_parse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def find_nodes_to_parse(options, namespace, tag_name, namespaces, node, root)
      # when at the root use the xpath '/' otherwise use a more gready './/'
      # unless an xpath has been specified, which should overwrite default
      # and finally attach the current namespace if one has been defined
      #
Severity: Minor
Found in lib/happymapper/class_methods.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 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse(xml, options = {})
      # Capture any provided namespaces and merge in any namespaces that have
      # been registered on the object.
      namespaces = options[:namespaces] || {}
      namespaces = namespaces.merge(@registered_namespaces)
Severity: Minor
Found in lib/happymapper/class_methods.rb - About 1 hr to fix

    Method parse_node has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_node(node, options, namespace, namespaces)
          # If an existing HappyMapper object is provided, update it with the
          # values from the xml being parsed.  Otherwise, create a new object
    
          obj = options[:update] || new
    Severity: Minor
    Found in lib/happymapper/class_methods.rb - 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 find_nodes_to_parse has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def find_nodes_to_parse(options, namespace, tag_name, namespaces, node, root)
    Severity: Minor
    Found in lib/happymapper/class_methods.rb - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status