savonrb/gyoku

View on GitHub

Showing 11 of 11 total issues

Method iterate_with_xml has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def iterate_with_xml(hash)
      xml = Builder::XmlMarkup.new
      attributes = hash[:attributes!] || {}
      hash_without_attributes = hash.except(:attributes!)

Severity: Minor
Found in lib/gyoku/hash.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 build_xml has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def self.build_xml(array, key, escape_xml = true, attributes = {}, options = {})
      self_closing = options.delete(:self_closing)
      unwrap = unwrap?(options.fetch(:unwrap, false), key)

      iterate_with_xml array, key, attributes, options do |xml, item, attrs, index|
Severity: Minor
Found in lib/gyoku/array.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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def create(object, escape_xml = true, options = {})
        case object
        when Time
          object.strftime XS_TIME_FORMAT
        when DateTime
Severity: Minor
Found in lib/gyoku/xml_value.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 build_xml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def build_xml(hash, options = {})
      iterate_with_xml hash do |xml, key, value, attributes|
        self_closing = key.to_s[-1, 1] == "/"
        escape_xml = key.to_s[-1, 1] != "!"
        xml_key = XMLKey.create key, options
Severity: Minor
Found in lib/gyoku/hash.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 to_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def to_xml(array, key, escape_xml = true, attributes = {}, options = {})
Severity: Minor
Found in lib/gyoku/array.rb - About 35 mins to fix

    Method build_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def self.build_xml(array, key, escape_xml = true, attributes = {}, options = {})
    Severity: Minor
    Found in lib/gyoku/array.rb - About 35 mins to fix

      Method iterate_with_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def iterate_with_xml(array, key, attributes, options, &block)
      Severity: Minor
      Found in lib/gyoku/array.rb - About 35 mins to fix

        Method iterate_array has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def iterate_array(xml, array, attributes, &block)
              array.each_with_index do |item, index|
                attrs = if item.respond_to?(:keys)
                  item.each_with_object({}) do |v, st|
                    k = v[0].to_s
        Severity: Minor
        Found in lib/gyoku/array.rb - About 35 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 key_converter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def key_converter(options, xml_key)
                return options[:key_converter] if options[:key_converter].is_a? Proc
        
                defined_key = options[:key_to_convert]
                key_converter = if !defined_key.nil? && (defined_key == xml_key)
        Severity: Minor
        Found in lib/gyoku/xml_key.rb - About 35 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 order has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def order(hash)
              order = hash[:order!] || hash.delete("order!")
              hash_without_order = hash.except(:order!)
              order = hash_without_order.keys unless order.is_a? ::Array
        
        
        Severity: Minor
        Found in lib/gyoku/hash.rb - About 35 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 tag_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def tag_attributes(attributes, index)
              return {} if attributes.empty?
        
              attributes.inject({}) do |hash, (key, value)|
                value = value[index] if value.is_a? ::Array
        Severity: Minor
        Found in lib/gyoku/array.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