Showing 215 of 228 total issues

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

        def add_search_scopes(base_scope)
          if search.is_a?(ActionController::Parameters)
            search.each do |name, scope_attribute|
              scope_name = name.to_sym

Severity: Minor
Found in core/lib/spree/core/search/base.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 remove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def remove(units_count, target_shipment = nil)
      quantity = set_quantity_to_remove(units_count)

      if target_shipment.present?
        remove_from_shipment(target_shipment, quantity)
Severity: Minor
Found in core/app/models/spree/order_inventory.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.parse(number)
      return number unless number.is_a?(String)

      separator, delimiter = I18n.t([:'number.currency.format.separator', :'number.currency.format.delimiter'])
      non_number_characters = /[^0-9\-#{separator}]/
Severity: Minor
Found in core/lib/spree/localized_number.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 activate
        promotions.each do |promotion|
          next if promotion.code.present? && !order_promo_ids.include?(promotion.id)

          promotion.activate(order: order) if promotion.eligible?(order)
Severity: Minor
Found in core/app/models/spree/promotion_handler/free_shipping.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 postal_code_validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def postal_code_validate
      return if country.blank? || country_iso.blank? || !require_zipcode? || zipcode.blank?
      return unless ::ValidatesZipcode::CldrRegexpCollection::ZIPCODES_REGEX.keys.include?(country_iso.upcase.to_sym)

      formatted_zip = ::ValidatesZipcode::Formatter.new(
Severity: Minor
Found in core/app/models/spree/address.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if not Spree::Taxon::Translation.exists?
      ActiveRecord::Base.connection.execute("
      INSERT INTO #{TAXON_TRANSLATIONS_TABLE} (name, description, meta_title, meta_description, meta_keywords, permalink, locale, spree_taxon_id, created_at, updated_at)
      SELECT name, description, meta_title, meta_description, meta_keywords, permalink, '#{DEFAULT_LOCALE}' as locale, id, created_at, updated_at FROM #{TAXONS_TABLE};
                                            ")
core/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb on lines 13..19

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 29.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if not Spree::Product::Translation.exists?
      ActiveRecord::Base.connection.execute("
      INSERT INTO #{PRODUCT_TRANSLATIONS_TABLE} (name, description, locale, spree_product_id, created_at, updated_at, meta_description, meta_keywords, meta_title, slug)
      SELECT name, description, '#{DEFAULT_LOCALE}' as locale, id, created_at, updated_at, meta_description, meta_keywords, meta_title, slug FROM #{PRODUCTS_TABLE};
                                            ")
core/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb on lines 25..31

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 29.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      def ship_address_id=(id)
        address = Spree::Address.find_by(id: id)
        if address && address.user_id == user_id
          self['ship_address_id'] = address.id
          ship_address.reload
Severity: Minor
Found in core/app/models/spree/order/address_book.rb and 1 other location - About 20 mins to fix
core/app/models/spree/order/address_book.rb on lines 21..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 9 locations. Consider refactoring.
Open

  def change
    change_table :spree_products do |t|
      if t.respond_to? :jsonb
        add_column :spree_products, :public_metadata, :jsonb
        add_column :spree_products, :private_metadata, :jsonb
core/db/migrate/20210915064321_add_metadata_to_spree_orders.rb on lines 2..10
core/db/migrate/20210915064323_add_metadata_to_spree_variants.rb on lines 2..10
core/db/migrate/20210915064324_add_metadata_to_spree_line_items.rb on lines 2..10
core/db/migrate/20210915064325_add_metadata_to_spree_shipments.rb on lines 2..10
core/db/migrate/20210915064326_add_metadata_to_spree_payments.rb on lines 2..10
core/db/migrate/20210915064328_add_metadata_to_spree_stock_transfers.rb on lines 2..10
core/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb on lines 2..10
core/db/migrate/20220613133029_add_metadata_to_spree_stock_items.rb on lines 2..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 9 locations. Consider refactoring.
Open

  def change
    change_table :spree_stock_transfers do |t|
      if t.respond_to? :jsonb
        add_column :spree_stock_transfers, :public_metadata, :jsonb
        add_column :spree_stock_transfers, :private_metadata, :jsonb
core/db/migrate/20210915064321_add_metadata_to_spree_orders.rb on lines 2..10
core/db/migrate/20210915064322_add_metadata_to_spree_products.rb on lines 2..10
core/db/migrate/20210915064323_add_metadata_to_spree_variants.rb on lines 2..10
core/db/migrate/20210915064324_add_metadata_to_spree_line_items.rb on lines 2..10
core/db/migrate/20210915064325_add_metadata_to_spree_shipments.rb on lines 2..10
core/db/migrate/20210915064326_add_metadata_to_spree_payments.rb on lines 2..10
core/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb on lines 2..10
core/db/migrate/20220613133029_add_metadata_to_spree_stock_items.rb on lines 2..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  class PromotionRuleTaxon < Spree::Base
    belongs_to :promotion_rule, class_name: 'Spree::PromotionRule'
    belongs_to :taxon, class_name: 'Spree::Taxon'

    validates :promotion_rule, :taxon, presence: true
Severity: Minor
Found in core/app/models/spree/promotion_rule_taxon.rb and 1 other location - About 20 mins to fix
core/app/models/spree/product_promotion_rule.rb on lines 2..8

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 9 locations. Consider refactoring.
Open

  def change
    change_table :spree_shipments do |t|
      if t.respond_to? :jsonb
        add_column :spree_shipments, :public_metadata, :jsonb
        add_column :spree_shipments, :private_metadata, :jsonb
core/db/migrate/20210915064321_add_metadata_to_spree_orders.rb on lines 2..10
core/db/migrate/20210915064322_add_metadata_to_spree_products.rb on lines 2..10
core/db/migrate/20210915064323_add_metadata_to_spree_variants.rb on lines 2..10
core/db/migrate/20210915064324_add_metadata_to_spree_line_items.rb on lines 2..10
core/db/migrate/20210915064326_add_metadata_to_spree_payments.rb on lines 2..10
core/db/migrate/20210915064328_add_metadata_to_spree_stock_transfers.rb on lines 2..10
core/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb on lines 2..10
core/db/migrate/20220613133029_add_metadata_to_spree_stock_items.rb on lines 2..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 9 locations. Consider refactoring.
Open

  def change
    change_table :spree_payments do |t|
      if t.respond_to? :jsonb
        add_column :spree_payments, :public_metadata, :jsonb
        add_column :spree_payments, :private_metadata, :jsonb
core/db/migrate/20210915064321_add_metadata_to_spree_orders.rb on lines 2..10
core/db/migrate/20210915064322_add_metadata_to_spree_products.rb on lines 2..10
core/db/migrate/20210915064323_add_metadata_to_spree_variants.rb on lines 2..10
core/db/migrate/20210915064324_add_metadata_to_spree_line_items.rb on lines 2..10
core/db/migrate/20210915064325_add_metadata_to_spree_shipments.rb on lines 2..10
core/db/migrate/20210915064328_add_metadata_to_spree_stock_transfers.rb on lines 2..10
core/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb on lines 2..10
core/db/migrate/20220613133029_add_metadata_to_spree_stock_items.rb on lines 2..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 9 locations. Consider refactoring.
Open

  def change
    change_table :spree_line_items do |t|
      if t.respond_to? :jsonb
        add_column :spree_line_items, :public_metadata, :jsonb
        add_column :spree_line_items, :private_metadata, :jsonb
core/db/migrate/20210915064321_add_metadata_to_spree_orders.rb on lines 2..10
core/db/migrate/20210915064322_add_metadata_to_spree_products.rb on lines 2..10
core/db/migrate/20210915064323_add_metadata_to_spree_variants.rb on lines 2..10
core/db/migrate/20210915064325_add_metadata_to_spree_shipments.rb on lines 2..10
core/db/migrate/20210915064326_add_metadata_to_spree_payments.rb on lines 2..10
core/db/migrate/20210915064328_add_metadata_to_spree_stock_transfers.rb on lines 2..10
core/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb on lines 2..10
core/db/migrate/20220613133029_add_metadata_to_spree_stock_items.rb on lines 2..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 9 locations. Consider refactoring.
Open

  def change
    change_table :spree_stock_items do |t|
      if t.respond_to? :jsonb
        add_column :spree_stock_items, :public_metadata, :jsonb
        add_column :spree_stock_items, :private_metadata, :jsonb
core/db/migrate/20210915064321_add_metadata_to_spree_orders.rb on lines 2..10
core/db/migrate/20210915064322_add_metadata_to_spree_products.rb on lines 2..10
core/db/migrate/20210915064323_add_metadata_to_spree_variants.rb on lines 2..10
core/db/migrate/20210915064324_add_metadata_to_spree_line_items.rb on lines 2..10
core/db/migrate/20210915064325_add_metadata_to_spree_shipments.rb on lines 2..10
core/db/migrate/20210915064326_add_metadata_to_spree_payments.rb on lines 2..10
core/db/migrate/20210915064328_add_metadata_to_spree_stock_transfers.rb on lines 2..10
core/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb on lines 2..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 9 locations. Consider refactoring.
Open

  def change
    change_table :spree_orders do |t|
      if t.respond_to? :jsonb
        add_column :spree_orders, :public_metadata, :jsonb
        add_column :spree_orders, :private_metadata, :jsonb
Severity: Major
Found in core/db/migrate/20210915064321_add_metadata_to_spree_orders.rb and 8 other locations - About 20 mins to fix
core/db/migrate/20210915064322_add_metadata_to_spree_products.rb on lines 2..10
core/db/migrate/20210915064323_add_metadata_to_spree_variants.rb on lines 2..10
core/db/migrate/20210915064324_add_metadata_to_spree_line_items.rb on lines 2..10
core/db/migrate/20210915064325_add_metadata_to_spree_shipments.rb on lines 2..10
core/db/migrate/20210915064326_add_metadata_to_spree_payments.rb on lines 2..10
core/db/migrate/20210915064328_add_metadata_to_spree_stock_transfers.rb on lines 2..10
core/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb on lines 2..10
core/db/migrate/20220613133029_add_metadata_to_spree_stock_items.rb on lines 2..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      def silence_stream(stream)
        old_stream = stream.dup
        stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
        stream.sync = true
        yield
Severity: Minor
Found in core/lib/spree/testing_support/kernel.rb and 1 other location - About 20 mins to fix
core/lib/generators/spree/install/install_generator.rb on lines 241..249

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      def bill_address_id=(id)
        address = Spree::Address.find_by(id: id)
        if address && address.user_id == user_id
          self['bill_address_id'] = address.id
          bill_address.reload
Severity: Minor
Found in core/app/models/spree/order/address_book.rb and 1 other location - About 20 mins to fix
core/app/models/spree/order/address_book.rb on lines 36..43

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    def silence_stream(stream)
      old_stream = stream.dup
      stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
      stream.sync = true
      yield
Severity: Minor
Found in core/lib/generators/spree/install/install_generator.rb and 1 other location - About 20 mins to fix
core/lib/spree/testing_support/kernel.rb on lines 6..14

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  class ProductPromotionRule < Spree::Base
    belongs_to :product, class_name: 'Spree::Product'
    belongs_to :promotion_rule, class_name: 'Spree::PromotionRule'

    validates :product, :promotion_rule, presence: true
Severity: Minor
Found in core/app/models/spree/product_promotion_rule.rb and 1 other location - About 20 mins to fix
core/app/models/spree/promotion_rule_taxon.rb on lines 2..8

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language