Method import
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.import(user, params)
ensure_country_id_from_params params[:ship_address_attributes]
ensure_state_id_from_params params[:ship_address_attributes]
ensure_country_id_from_params params[:bill_address_attributes]
ensure_state_id_from_params params[:bill_address_attributes]
- 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
Method create_shipments_from_params
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.create_shipments_from_params(shipments_hash, order)
return [] unless shipments_hash
shipments_hash.each do |s|
shipment = order.shipments.build
- 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
Method create_payments_from_params
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.create_payments_from_params(payments_hash, order)
return [] unless payments_hash
payments_hash.each do |p|
payment = order.payments.build order: order
- 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
Method create_shipments_from_params
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_shipments_from_params(shipments_hash, order)
return [] unless shipments_hash
shipments_hash.each do |s|
shipment = order.shipments.build
Method import
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import(user, params)
ensure_country_id_from_params params[:ship_address_attributes]
ensure_state_id_from_params params[:ship_address_attributes]
ensure_country_id_from_params params[:bill_address_attributes]
ensure_state_id_from_params params[:bill_address_attributes]
Method create_line_items_from_params
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.create_line_items_from_params(line_items, order)
return {} unless line_items
line_items.each do |line_item|
adjustments = line_item.delete(:adjustments_attributes)
- 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
Method ensure_state_id_from_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.ensure_state_id_from_params(address)
return if address.nil? || address[:state_id].present? || address[:state].nil?
begin
search = {}
- 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
Method ensure_country_id_from_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.ensure_country_id_from_params(address)
return if address.nil? || address[:country_id].present? || address[:country].nil?
begin
search = {}
- 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"