alsemyonov/xommelier

View on GitHub

Showing 10 of 10 total issues

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

    class Element
      module Structure
        extend ActiveSupport::Concern

        included do
Severity: Minor
Found in lib/xommelier/xml/element/structure.rb - About 3 hrs to fix

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

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

          def define_element_accessors(element)
            name = element.name
            if element.multiple?
              # Define plural accessors
              plural = element.plural
Severity: Minor
Found in lib/xommelier/xml/element/structure.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

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

Method element has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

          def element(name, options = {})
            # Set name, type and element name by reference if provided
            if name.is_a?(Hash)
              options = name
              name = nil
Severity: Minor
Found in lib/xommelier/xml/element/structure.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_accessors has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def define_element_accessors(element)
            name = element.name
            if element.multiple?
              # Define plural accessors
              plural = element.plural
Severity: Minor
Found in lib/xommelier/xml/element/structure.rb - About 1 hr to fix

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

        def write_element(name, value, index = nil)
          element = element_options(name)
          type    = element.type
          unless value.is_a?(type)
            value = if element.complex_type? && !value.is_a?(Nokogiri::XML::Node)
Severity: Minor
Found in lib/xommelier/xml/element/structure.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

Severity
Category
Status
Source
Language