werein/prestashop

View on GitHub
lib/prestashop/api/converter.rb

Summary

Maintainability
D
2 days
Test Coverage

Method xml_node_to_hash has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

      def self.xml_node_to_hash node 
        # If we are at the root of the document, start the hash
        if node.element?
          result_hash = {}
          if node.attributes != {}
Severity: Minor
Found in lib/prestashop/api/converter.rb - About 1 day 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_nodes has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

      def self.build_nodes ml, source, mkey = nil
        unless source[:attr] and source[:val]
          source.each do |key, value| 
            if value.kind_of? Hash
              if value[:attr]
Severity: Minor
Found in lib/prestashop/api/converter.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 xml_node_to_hash has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.xml_node_to_hash node 
        # If we are at the root of the document, start the hash
        if node.element?
          result_hash = {}
          if node.attributes != {}
Severity: Minor
Found in lib/prestashop/api/converter.rb - About 1 hr to fix

    Method build_nodes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.build_nodes ml, source, mkey = nil
            unless source[:attr] and source[:val]
              source.each do |key, value| 
                if value.kind_of? Hash
                  if value[:attr]
    Severity: Minor
    Found in lib/prestashop/api/converter.rb - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                    elsif result_hash[child.name.to_sym]
                      if result_hash[child.name.to_sym].is_a?(Object::Array)
                        result_hash[child.name.to_sym] << prepare(result)
                      else
                        result_hash[child.name.to_sym] = [result_hash[child.name.to_sym]] << prepare(result)
      Severity: Major
      Found in lib/prestashop/api/converter.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if !result_hash.empty?
                          result_hash[:val] = prepare(result)
                          return result_hash
                        end
        Severity: Major
        Found in lib/prestashop/api/converter.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            if !result_hash.empty?
                              result_hash[:val] = prepare(result)
                              return result_hash
                            end
          Severity: Major
          Found in lib/prestashop/api/converter.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                              result_hash[:attr] = {} unless result_hash[:attr]
            Severity: Major
            Found in lib/prestashop/api/converter.rb - About 45 mins to fix

              Avoid too many return statements within this method.
              Open

                        return prepare(node.content.to_s) 
              Severity: Major
              Found in lib/prestashop/api/converter.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return result_hash
                Severity: Major
                Found in lib/prestashop/api/converter.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return result_hash
                  Severity: Major
                  Found in lib/prestashop/api/converter.rb - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status