mvz/happymapper

View on GitHub

Showing 12 of 12 total issues

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 element_to_xml has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def element_to_xml(element, xml, default_namespace)
        #
        # If an element is marked as read only do not consider at all when
        # saving to XML.
        #
    Severity: Minor
    Found in lib/happymapper.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 collect_writable_attributes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def collect_writable_attributes
        #
        # Find the attributes for the class and collect them into an array
        # that will be placed into a Hash structure
        #
    Severity: Minor
    Found in lib/happymapper.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 define_element_on_class has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def define_element_on_class(klass, node)
          # When a text node has been provided create the necessary
          # HappyMapper content attribute if the text happens to contain
          # some content.
    
    
    Severity: Minor
    Found in lib/happymapper/anonymous_mapper.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 find has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def find(node, namespace, xpath_options)
          if self.namespace
            # from the class definition
            namespace = self.namespace
          elsif options[:namespace]
    Severity: Minor
    Found in lib/happymapper/element.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 handle_attributes_option has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_attributes_option(result, value, xpath_options)
          return unless options[:attributes].is_a?(Hash)
    
          result = result.first unless result.respond_to?(:attribute_nodes)
          return unless result.respond_to?(:attribute_nodes)
    Severity: Minor
    Found in lib/happymapper/element.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 element_to_xml has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def element_to_xml(element, xml, default_namespace)
        #
        # If an element is marked as read only do not consider at all when
        # saving to XML.
        #
    Severity: Minor
    Found in lib/happymapper.rb - About 1 hr to fix

      Method to_xml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def to_xml(builder = nil, default_namespace = nil, namespace_override = nil,
                   tag_from_parent = nil)
      
          #
          # If to_xml has been called without a passed in builder instance that
      Severity: Minor
      Found in lib/happymapper.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

      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
        Severity
        Category
        Status
        Source
        Language