ngelx/solidus_import_products

View on GitHub

Showing 13 of 66 total issues

Method associate_product_with_taxon has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def associate_product_with_taxon(product, taxon_hierarchy, putInTop)
        return if product.nil? || taxon_hierarchy.nil?

        taxon_hierarchy.split(/\s*\|\s*/).each do |hierarchy|
          hierarchy = hierarchy.split(/\s*>\s*/)
Severity: Minor
Found in lib/solidus_import_products/import_helper.rb - About 4 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 associate_product_with_taxon has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def associate_product_with_taxon(product, taxon_hierarchy, putInTop)
        return if product.nil? || taxon_hierarchy.nil?

        taxon_hierarchy.split(/\s*\|\s*/).each do |hierarchy|
          hierarchy = hierarchy.split(/\s*>\s*/)
Severity: Minor
Found in lib/solidus_import_products/import_helper.rb - About 1 hr to fix

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

        def call(args = { product: nil, product_information: nil })
          self.logger = SolidusImportProducts::Logger.instance
          self.product_information = args[:product_information]
          self.product = args[:product]
    
    
    Severity: Minor
    Found in app/services/solidus_import_products/update_product.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 extract_product_information has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def extract_product_information
          col.each do |key, value|
            row[value].try :strip!
            if parser.variant_option_field?(key)
              product_information[:variant_options][key] = row[value]
    Severity: Minor
    Found in app/services/solidus_import_products/process_row.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 call has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def call(args = { product: nil, product_information: nil })
          self.logger = SolidusImportProducts::Logger.instance
          self.product_information = args[:product_information]
          self.product = args[:product]
          return if product_information.nil?
    Severity: Minor
    Found in app/services/solidus_import_products/create_variant.rb - About 1 hr to fix

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

          def call(args = { product: nil, product_information: nil })
            self.logger = SolidusImportProducts::Logger.instance
            self.product_information = args[:product_information]
            self.product = args[:product]
            return if product_information.nil?
      Severity: Minor
      Found in app/services/solidus_import_products/create_variant.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 extract_column_mappings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def extract_column_mappings
              rows[0].each_with_index do |heading, index|
                break if heading.blank?
                field_name = heading.downcase.gsub(/\A\s*/, '').chomp.gsub(/\s/, '_')
                if field_name.include?('[opt]')
      Severity: Minor
      Found in app/models/solidus_import_products/parser/csv.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 stock_items has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def stock_items
            source_location = Spree::StockLocation.find_by(default: true)
            unless source_location
              logger.log('Seems that there are no SourceLocation set right?, so stock will not set.', :warn) if product_information[:attributes][:stock] || product_information[:attributes][:backorderable]
              return
      Severity: Minor
      Found in app/services/solidus_import_products/create_variant.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 convert_to_price has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def convert_to_price(price_str)
            raise SolidusImportProducts::Exception::InvalidPrice unless price_str
            punt = price_str.index('.')
            coma = price_str.index(',')
            if !coma.nil? && !punt.nil?
      Severity: Minor
      Found in app/services/solidus_import_products/process_row.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 find_and_attach_image_to has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def find_and_attach_image_to(product_or_variant, filename)
              return if filename.blank?
      
              temp_file = fetch_image(filename)
              return unless temp_file
      Severity: Minor
      Found in lib/solidus_import_products/import_helper.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def call
            extract_product_information
            product_information_default_values
            logger.log(product_information.to_s, :debug)
      
      
      Severity: Minor
      Found in app/services/solidus_import_products/process_row.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

      Method options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def options(field, value)
            return unless value
      
            option_type = get_or_create_option_type(field)
            option_value = get_or_create_option_value(option_type, value)
      Severity: Minor
      Found in app/services/solidus_import_products/create_variant.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

      Method activate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.activate
            Dir.glob(File.join(File.dirname(__FILE__), '../app/**/*_decorator*.rb')) do |c|
              Rails.env.production? ? require(c) : load(c)
            end
      
      
      Severity: Minor
      Found in lib/solidus_import_products/engine.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