zoer/xmlable

View on GitHub

Showing 9 of 11 total issues

Method export_node_children has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def export_node_children(node, opts)
        node.children.each do |child|
          next if child.is_a?(Nokogiri::XML::Attr)
          if child.is_a?(Nokogiri::XML::Element)
            next if opts.drop_empty_elements? && empty?(child)
Severity: Minor
Found in lib/xmlable/exports/xml_exporter.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 export_element_children has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def export_element_children(el, opts)
        object_handlers(el, opts).each_with_object({}) do |h, memo|
          obj = el[h.method_name]
          if h.is_a?(Handlers::Element)
            next if opts.drop_empty_elements? && empty?(obj)
Severity: Minor
Found in lib/xmlable/exports/json_exporter.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_attributes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def node_attributes(node, opts)
        return {} unless node.respond_to?(:attributes)
        attrs = node.attributes.values.select do |att|
          next if opts.drop_undescribed_attributes? && !described?(att)
          next if opts.drop_empty_attributes? && empty?(att)
Severity: Minor
Found in lib/xmlable/exports/xml_exporter.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 __initialize_with has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def __initialize_with(value)
        if value.is_a?(Hash)
          value.each do |key, val|
            if respond_to?(:__overwrite_content) && __content_methods.include?(key.to_s)
              next __overwrite_content(val)
Severity: Minor
Found in lib/xmlable/mixins/instantiable.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 object_handlers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def object_handlers(el, opts)
        handlers = []
        if el.respond_to?(:__attributes_handlers)
          el.__attributes_handlers.storage.each do |h|
            next if opts.drop_undescribed_attributes? && !described?(h)
Severity: Minor
Found in lib/xmlable/exports/json_exporter.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 export_element has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def export_element(el, opts)
        opts = node_merged_opts(el.__node, opts)
        handlers = object_handlers(el, opts)
        content = export_content(el, opts)
        return content if handlers.size == 0
Severity: Minor
Found in lib/xmlable/exports/json_exporter.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 export_element has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def export_element(node, opts)
        opts = node_merged_opts(node, opts)
        ns = node.namespace
        if ns && !node_ns_definition(node, ns.prefix)
          opts[:xml] = opts[:xml][ns.prefix] if ns.prefix
Severity: Minor
Found in lib/xmlable/exports/xml_exporter.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 __nested has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def __nested(var)
          klass = superclass
          obj = nil
          loop do
            obj = klass.instance_variable_get(var)
Severity: Minor
Found in lib/xmlable/mixins/object.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

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

      def __define_namespaces(handlers)
        handlers.each do |h|
          next if __node.namespace_scopes.find { |ns| ns.prefix == h.prefix }
          __node.add_namespace_definition(h.prefix ? h.prefix.to_s : nil, h.href)
        end
Severity: Minor
Found in lib/xmlable/mixins/namespace_definitions_storage.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