alsemyonov/xommelier

View on GitHub
lib/xommelier/xml/element/serialization.rb

Summary

Maintainability
C
1 day
Test Coverage

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

        def to_xml(options = {})
          options = SERIALIZATION_OPTIONS.merge(options)
          save_options = options.slice(:encoding, *SAVE_OPTIONS)
          options = options.except(*SAVE_OPTIONS)

Severity: Minor
Found in lib/xommelier/xml/element/serialization.rb - About 3 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

Class Element has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Element
      module Serialization
        extend ActiveSupport::Concern

        SERIALIZATION_OPTIONS = {
Severity: Minor
Found in lib/xommelier/xml/element/serialization.rb - About 2 hrs to fix

Method to_hash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def to_hash
          attributes.dup.tap do |hash|
            @elements.each do |name, value|
              element = element_options(name)
              if element.multiple?
Severity: Minor
Found in lib/xommelier/xml/element/serialization.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 to_xml has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def to_xml(options = {})
          options = SERIALIZATION_OPTIONS.merge(options)
          save_options = options.slice(:encoding, *SAVE_OPTIONS)
          options = options.except(*SAVE_OPTIONS)

Severity: Minor
Found in lib/xommelier/xml/element/serialization.rb - About 1 hr to fix

Method serialize_element has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def serialize_element(name, value, xml, element)
          if element.multiple?
            element.override(multiple: false) do
              value.each do |item|
                serialize_element(name, item, xml, element)
Severity: Minor
Found in lib/xommelier/xml/element/serialization.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

There are no issues that match your filters.

Category
Status