Showing 203 of 346 total issues
Method show
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show
authorize! :create_orders, current_user
@order = find_or_create_order
#@order = session_admin_cart.add_items_to_checkout(order) # need here because items can also be removed
- 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 fulfillment_grid
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.fulfillment_grid(params = {})
grid = Order.includes([:user]).where({ :orders => {:shipped => false }} ).where("orders.completed_at IS NOT NULL")
grid = grid.where({:active => true }) unless params[:show_all].present? && params[:show_all] == 'true'
grid = grid.where("orders.number LIKE ?", "#{params[:number]}%") if params[:number].present?
grid = grid.where("orders.shipped = ?", true) if (params[:shipped].present? && params[:shipped] == 'true')
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def update
@shopping_address = current_user.addresses.new(allowed_params)
@shopping_address.replace_address_id = params[:id] # This makes the address we are updating inactive if we save successfully
# if we are editing the current default address then this is the default address
- 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"