werein/prestashop

View on GitHub

Showing 29 of 31 total issues

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 initialize has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def initialize args = {}
        @id                         = args[:id]
        @id_manufacturer            = args[:id_manufacturer]
        @id_supplier                = args.fetch(:id_supplier)
        @id_category_default        = args[:id_category_default]
Severity: Major
Found in lib/prestashop/mapper/models/product.rb - About 2 hrs to fix

    Method get has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def get resource, id = nil, opts = {}
            id.to_i unless id.kind_of?(Array)
            raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
            raise ArgumentError, "id: #{id} must be integer, array or nil" unless id.kind_of?(Integer) or id.kind_of?(Array) or id == nil
    
    
    Severity: Minor
    Found in lib/prestashop/api/connection.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 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 handle_result has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

                def handle_result result, options = {}
                  if options[:display]
                    if result[self.resource].kind_of?(Hash) and result[self.resource][self.model]
                      objects = result[self.resource][self.model]
                      objects.kind_of?(Array) ? objects : [objects]
      Severity: Minor
      Found in lib/prestashop/mapper/extension.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 upload has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def upload type, resource, id, payload, file
              raise ArgumentError, "type: #{type} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
              raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
              raise ArgumentError, "id: #{id} must be integer" unless id.to_i.kind_of?(Integer)
      
      
      Severity: Minor
      Found in lib/prestashop/api/connection.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 hash has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def hash
              product = {
                id_supplier:          id_supplier,
                id_manufacturer:      id_manufacturer,
                id_category_default:  id_category_default,
      Severity: Minor
      Found in lib/prestashop/mapper/models/product.rb - About 1 hr to fix

        Method head has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def head resource, id = nil
                raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
                raise ArgumentError, "id: #{id} must be integer or nil" unless id.to_i.kind_of?(Integer) or id == nil
        
                request_path = path(resource, id)
        Severity: Minor
        Found in lib/prestashop/api/connection.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 delete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def delete resource, id
                raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
                raise ArgumentError, "id: #{id} must be integer" unless id.to_i.kind_of?(Integer)
        
                request_path = path(resource, id)
        Severity: Minor
        Found in lib/prestashop/api/connection.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 uploader has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def uploader source
                if source =~ URI::regexp
                  source = URI::encode(source)
                  self.file = MiniMagick::Image.open(source)
                  file.format 'png' unless %w(jpg jpeg png gif).include?(file[:format])
        Severity: Minor
        Found in lib/prestashop/mapper/models/image.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 put has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def put resource, id, payload
                raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
                raise ArgumentError, "id: #{id} must be integer" unless id.to_i.kind_of?(Integer)
        
                request_path = path(resource, id)
        Severity: Minor
        Found in lib/prestashop/api/connection.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_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

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

                def validate!
                  raise ArgumentError, 'id lang must be number' unless id_lang.kind_of?(Integer)
                  raise ArgumentError, 'name must string' unless name.kind_of?(String)
                  raise ArgumentError, 'id attribute group must be number' unless id_attribute_group.kind_of?(Integer)
                  raise ArgumentError, 'color must be true or false' unless color == 1 or color == 0
          Severity: Minor
          Found in lib/prestashop/mapper/models/product_option_value.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

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

                def validate!
                  raise ArgumentError, 'id lang must be number' unless id_lang.kind_of?(Integer)
                  raise ArgumentError, 'id feature must string' unless id_feature.kind_of?(Integer)
                  raise ArgumentError, 'custom must be 0 or 1' unless custom == 0 or custom == 1
                  raise ArgumentError, 'value must string' unless value.kind_of?(String)
          Severity: Minor
          Found in lib/prestashop/mapper/models/product_feature_value.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

          Method post has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def post resource, payload
                  raise ArgumentError, "resource: #{resource} must be string or symbol" unless resource.kind_of?(String) or resource.kind_of?(Symbol)
          
                  request_path = path(resource)
                  response = connection.post request_path, payload
          Severity: Minor
          Found in lib/prestashop/api/connection.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

          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

                          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

                                result_hash[:attr] = {} unless result_hash[:attr]
              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
                  Severity
                  Category
                  Status
                  Source
                  Language