Showing 211 of 224 total issues

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

    create_table "spree_role_users", force: :cascade do |t|
      t.bigint "role_id"
      t.bigint "user_id"
      t.datetime "created_at"
      t.datetime "updated_at"
Severity: Minor
Found in core/db/migrate/20210914000000_spree_four_three.rb and 2 other locations - About 35 mins to fix
core/db/migrate/20210914000000_spree_four_three.rb on lines 580..587
core/db/migrate/20210914000000_spree_four_three.rb on lines 847..854

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 34.

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 3 locations. Consider refactoring.
Open

    create_table "spree_shipping_method_zones", force: :cascade do |t|
      t.bigint "shipping_method_id"
      t.bigint "zone_id"
      t.datetime "created_at"
      t.datetime "updated_at"
Severity: Minor
Found in core/db/migrate/20210914000000_spree_four_three.rb and 2 other locations - About 35 mins to fix
core/db/migrate/20210914000000_spree_four_three.rb on lines 580..587
core/db/migrate/20210914000000_spree_four_three.rb on lines 790..797

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 34.

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

  module Orders
    class Approve
      prepend Spree::ServiceModule::Base

      def call(order:, approver: nil)
Severity: Minor
Found in core/app/services/spree/orders/approve.rb and 1 other location - About 35 mins to fix
core/app/services/spree/orders/cancel.rb on lines 2..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 34.

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

  module Orders
    class Cancel
      prepend Spree::ServiceModule::Base

      def call(order:, canceler: nil)
Severity: Minor
Found in core/app/services/spree/orders/cancel.rb and 1 other location - About 35 mins to fix
core/app/services/spree/orders/approve.rb on lines 2..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 34.

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 3 locations. Consider refactoring.
Open

    create_table "spree_promotion_rule_taxons", force: :cascade do |t|
      t.bigint "taxon_id"
      t.bigint "promotion_rule_id"
      t.datetime "created_at"
      t.datetime "updated_at"
Severity: Minor
Found in core/db/migrate/20210914000000_spree_four_three.rb and 2 other locations - About 35 mins to fix
core/db/migrate/20210914000000_spree_four_three.rb on lines 790..797
core/db/migrate/20210914000000_spree_four_three.rb on lines 847..854

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 34.

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 3 locations. Consider refactoring.
Open

  class StoreProduct < Spree::Base
    self.table_name = 'spree_products_stores'

    belongs_to :store, class_name: 'Spree::Store', touch: true
    belongs_to :product, class_name: 'Spree::Product', touch: true
Severity: Minor
Found in core/app/models/spree/store_product.rb and 2 other locations - About 30 mins to fix
core/app/models/spree/store_payment_method.rb on lines 2..10
core/app/models/spree/store_promotion.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 33.

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 3 locations. Consider refactoring.
Open

  class StorePaymentMethod < Spree::Base
    self.table_name = 'spree_payment_methods_stores'

    belongs_to :store, class_name: 'Spree::Store', touch: true
    belongs_to :payment_method, class_name: 'Spree::PaymentMethod', touch: true
Severity: Minor
Found in core/app/models/spree/store_payment_method.rb and 2 other locations - About 30 mins to fix
core/app/models/spree/store_product.rb on lines 2..10
core/app/models/spree/store_promotion.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 33.

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 3 locations. Consider refactoring.
Open

  class StorePromotion < Spree::Base
    self.table_name = 'spree_promotions_stores'

    belongs_to :store, class_name: 'Spree::Store', touch: true
    belongs_to :promotion, class_name: 'Spree::Promotion', touch: true
Severity: Minor
Found in core/app/models/spree/store_promotion.rb and 2 other locations - About 30 mins to fix
core/app/models/spree/store_payment_method.rb on lines 2..10
core/app/models/spree/store_product.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 33.

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

Avoid too many return statements within this method.
Open

        return false if (target.states.pluck(:country_id) - countries.pluck(:id)).present?
Severity: Major
Found in core/app/models/spree/zone.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return if webhook_payload_body.blank?
    Severity: Major
    Found in api/app/models/concerns/spree/webhooks/has_webhooks.rb - About 30 mins to fix

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

      shared_examples_for 'create only' do
        it 'should allow create' do
          expect(ability).to be_able_to(:create, resource)
        end
      
      
      Severity: Minor
      Found in core/lib/spree/testing_support/ability_helpers.rb and 3 other locations - About 25 mins to fix
      core/lib/spree/testing_support/ability_helpers.rb on lines 18..28
      core/lib/spree/testing_support/ability_helpers.rb on lines 71..81
      core/lib/spree/testing_support/ability_helpers.rb on lines 85..95

      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 31.

      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 4 locations. Consider refactoring.
      Open

      shared_examples_for 'read only' do
        it 'should not allow create' do
          expect(ability).to_not be_able_to(:create, resource)
        end
      
      
      Severity: Minor
      Found in core/lib/spree/testing_support/ability_helpers.rb and 3 other locations - About 25 mins to fix
      core/lib/spree/testing_support/ability_helpers.rb on lines 18..28
      core/lib/spree/testing_support/ability_helpers.rb on lines 57..67
      core/lib/spree/testing_support/ability_helpers.rb on lines 85..95

      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 31.

      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 4 locations. Consider refactoring.
      Open

      shared_examples_for 'update only' do
        it 'should not allow create' do
          expect(ability).to_not be_able_to(:create, resource)
        end
      
      
      Severity: Minor
      Found in core/lib/spree/testing_support/ability_helpers.rb and 3 other locations - About 25 mins to fix
      core/lib/spree/testing_support/ability_helpers.rb on lines 18..28
      core/lib/spree/testing_support/ability_helpers.rb on lines 57..67
      core/lib/spree/testing_support/ability_helpers.rb on lines 71..81

      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 31.

      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 4 locations. Consider refactoring.
      Open

      shared_examples_for 'access denied' do
        it 'should not allow read' do
          expect(ability).to_not be_able_to(:read, resource)
        end
      
      
      Severity: Minor
      Found in core/lib/spree/testing_support/ability_helpers.rb and 3 other locations - About 25 mins to fix
      core/lib/spree/testing_support/ability_helpers.rb on lines 57..67
      core/lib/spree/testing_support/ability_helpers.rb on lines 71..81
      core/lib/spree/testing_support/ability_helpers.rb on lines 85..95

      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 31.

      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

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

                def transfer_to_location
                  stock_location = Spree::StockLocation.find(params.dig(:shipment, :stock_location_id))
                  quantity = params.dig(:shipment, :quantity)&.to_i || 1
      
                  unless quantity > 0
      Severity: Minor
      Found in api/app/controllers/spree/api/v2/platform/shipments_controller.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 ordered has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def ordered(products)
              return products unless sort_by?
      
              case sort_by
              when 'default'
      Severity: Minor
      Found in core/app/finders/spree/products/find.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 revert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def revert(options = {})
                order = options[:order]
                return if eligible?(order)
      
                action_taken = false
      Severity: Minor
      Found in core/app/models/spree/promotion/actions/create_line_items.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 split has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def split(packages)
                split_packages = []
      
                packages.each do |package|
                  split_packages << build_package(package.on_hand) unless package.on_hand.empty?
      Severity: Minor
      Found in core/app/models/spree/stock/splitter/backordered.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 user_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.user_class(constantize: true)
          if @@user_class.is_a?(Class)
            raise 'Spree.user_class MUST be a String or Symbol object, not a Class object.'
          elsif @@user_class.is_a?(String) || @@user_class.is_a?(Symbol)
            constantize ? @@user_class.to_s.constantize : @@user_class.to_s
      Severity: Minor
      Found in core/lib/spree/core.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 copy_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def copy_actions
              @promotion.promotion_actions.each do |action|
                new_action = action.dup
                new_action.calculator = action.calculator.dup if action.try(:calculator)
      
      
      Severity: Minor
      Found in core/app/models/spree/promotion_handler/promotion_duplicator.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