savonrb/gyoku

View on GitHub

Showing 10 of 10 total issues

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

    def self.iterate_with_xml(hash)
      xml = Builder::XmlMarkup.new
      attributes = hash[:attributes!] || {}
      hash_without_attributes = hash.reject { |key, value| key == :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 create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def create(object, escape_xml = true, options = {})
        if Time === object
          object.strftime XS_TIME_FORMAT
        elsif DateTime === object
          object.strftime XS_DATETIME_FORMAT
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 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)

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 iterate_with_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

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

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

            def self.iterate_array(xml, array, attributes, &block)
              array.each_with_index do |item, index|
                if item.respond_to?(:keys)
                  attrs = item.reduce({}) do |st, v|
                    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 order has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.order(hash)
              order = hash[:order!] || hash.delete('order!')
              hash_without_order = hash.reject { |key, value| key == :order! }
              order = hash_without_order.keys unless order.kind_of? ::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 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]
                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 tag_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.tag_attributes(attributes, index)
              return {} if attributes.empty?
        
              attributes.inject({}) do |hash, (key, value)|
                value = value[index] if value.kind_of? ::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