Showing 155 of 227 total issues
Method up
has 1116 lines of code (exceeds 25 allowed). Consider refactoring. Open
def up
# This migration is just a compressed version of all the previous
# migrations for spree_core. Do not run it if one of the core tables
# already exists. Assume the best.
return if data_source_exists?(:spree_addresses)
File 20210914000000_spree_four_three.rb
has 1120 lines of code (exceeds 250 allowed). Consider refactoring. Open
class SpreeFourThree < ActiveRecord::Migration[5.2]
def up
# This migration is just a compressed version of all the previous
# migrations for spree_core. Do not run it if one of the core tables
# already exists. Assume the best.
Class Order
has 89 methods (exceeds 20 allowed). Consider refactoring. Open
class Order < Spree::Base
PAYMENT_STATES = %w(balance_due credit_owed failed paid void)
SHIPMENT_STATES = %w(backorder canceled partial pending ready shipped)
include Spree::Order::Checkout
File order.rb
has 564 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_dependency 'spree/order/checkout'
require_dependency 'spree/order/currency_updater'
require_dependency 'spree/order/digital'
require_dependency 'spree/order/payments'
require_dependency 'spree/order/store_credit'
Method included
has 231 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(klass)
klass.class_eval do
class_attribute :next_event_transitions
class_attribute :previous_states
class_attribute :checkout_flow
Class Product
has 58 methods (exceeds 20 allowed). Consider refactoring. Open
class Product < Spree::Base
extend FriendlyId
include Spree::ProductScopes
include Spree::MultiStoreResource
include Spree::TranslatableResource
File product.rb
has 405 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Spree
class Product < Spree::Base
extend FriendlyId
include Spree::ProductScopes
include Spree::MultiStoreResource
Class Variant
has 41 methods (exceeds 20 allowed). Consider refactoring. Open
class Variant < Spree::Base
acts_as_paranoid
acts_as_list scope: :product
include Spree::MemoizedData
Class Shipment
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class Shipment < Spree::Base
include Spree::Core::NumberGenerator.new(prefix: 'H', length: 11)
include Spree::NumberIdentifier
include Spree::NumberAsParam
include Spree::Metadata
Class Find
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Find
def initialize(scope:, params:, current_currency: nil)
@scope = scope
if current_currency.present?
Method update_from_params
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def update_from_params(params, permitted_params, request_env = {})
success = false
@updating_params = params
run_callbacks :updating_from_params do
# Set existing card after setting permitted parameters because
- Read upRead up
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
Class CartController
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class CartController < ::Spree::Api::V2::BaseController
include OrderConcern
include CouponCodesHelper
include Spree::Api::V2::Storefront::MetadataControllerConcern
Method define_state_machine!
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def self.define_state_machine!
self.checkout_steps = {}
self.next_event_transitions = []
self.previous_states = [:cart]
self.removed_transitions = []
- Read upRead up
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
Class Payment
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Payment < Spree::Base
include Spree::Core::NumberGenerator.new(prefix: 'P', letters: true, length: 7)
include Spree::NumberIdentifier
include Spree::NumberAsParam
include Spree::Metadata
Method call
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def call
Spree::Country.where(states_required: true).each do |country|
carmen_country = Carmen::Country.named(country.name)
next unless carmen_country
- Read upRead up
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
File variant.rb
has 293 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Spree
class Variant < Spree::Base
acts_as_paranoid
acts_as_list scope: :product
File shipment.rb
has 292 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'ostruct'
module Spree
class Shipment < Spree::Base
include Spree::Core::NumberGenerator.new(prefix: 'H', length: 11)
Class ReturnItem
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class ReturnItem < Spree::Base
COMPLETED_RECEPTION_STATUSES = %w(received given_to_customer)
if defined?(Spree::Webhooks::HasWebhooks)
include Spree::Webhooks::HasWebhooks
Method remove_from_shipment
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def remove_from_shipment(shipment, quantity)
return 0 if quantity.zero? || shipment.shipped?
shipment_units = shipment.inventory_units_for_item(line_item, variant).reject(&:shipped?).sort_by(&:state)
- Read upRead up
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
Class OrdersController
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class OrdersController < ResourceController
include CouponCodesHelper
include NumberResource
def create