Showing 203 of 346 total issues
Method receive!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def receive!
PurchaseOrderVariant.transaction do
### Add to variant stock level
self.variant.inventory.count_on_hand = self.variant.inventory.count_on_hand + quantity
if self.variant.inventory.save!
- 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 update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update ## This selects a new address, sets the orders address & redirects to order_history
@order = Order.includes([:ship_address, {:user => :addresses}]).find_by_number(params[:order_id])
@address = Address.find(params[:id])
respond_to do |format|
- 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 sanitize_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_data
self.email = self.email.strip.downcase unless email.blank?
self.first_name = self.first_name.strip.capitalize unless first_name.nil?
self.last_name = self.last_name.strip.capitalize unless last_name.nil?
- 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
Consider simplifying this complex logical expression. Open
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'))
result = xhr.responseText
try {
Function add
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
jQuery.event.add = function( elem, types, handler, data, selector ){
Function anim
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function anim(el, speed, opacity, scale, callback) {
Function remove
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function remove(element, events, fn, selector, capture){
Function _w
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var _w = function(f, a1, a2, a3, a4)
Function remove
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
Function jq_param_sub
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function jq_param_sub( is_fragment, get_func, url, params, merge_mode ) {
Method add_cart_items
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_cart_items(items, qty, customer, cart_item_type_id, variant_id)
Method add_variant
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_variant(variant_id, customer, qty = 1, cart_item_type_id = ItemType::SHOPPING_CART_ID, admin_purchase = false)
Method new_transaction_ledgers
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def new_transaction_ledgers( transactor, credit_transaction_account_id, debit_transaction_account_id, amount, at)
Method session_cart!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def session_cart!
if cookies[:cart_id]
@session_cart = Cart.includes(:shopping_cart_items).find_by_id(cookies[:cart_id])
unless @session_cart
@session_cart = Cart.create(:user_id => current_user_id)
- 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 items_to_add_or_destroy
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def items_to_add_or_destroy(items_in_cart, order)
#destroy_any_order_item_that_was_removed_from_cart
destroy_order_items_not_in_cart!(items_in_cart, order)
# order.order_items.delete_all #destroy(order_item.id)
items = order.order_items.inject({}) {|h, item| h[item.variant_id].nil? ? h[item.variant_id] = [item.id] : h[item.variant_id] << item.id; h}
- 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 charge
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def charge( amount, profile_key, options ={})
options[:order_id] ||= unique_order_number
if GATEWAY.respond_to?(:purchase)
process( 'charge', amount ) do |gw|
gw.purchase( amount, profile_key, options )
- 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 remove_items
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def remove_items(variant, final_quantity)
current_qty = 0
items_to_remove = []
self.order_items.each_with_index do |order_item, i|
- 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
Avoid too many return
statements within this function. Open
return el.hide();
Avoid too many return
statements within this function. Open
return zepto.Z(dom, selector)
Avoid too many return
statements within this function. Open
return $(this.scope).width() < settings.small_breakpoint;