drhenner/ror_ecommerce

View on GitHub

Showing 203 of 346 total issues

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')
Severity: Minor
Found in app/models/order.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 merge_with_previous_cart! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def merge_with_previous_cart!
    if user_id && previous_cart
      current_items = cart_items.map(&:variant_id)
      previous_cart.cart_items.each do |item|
        self.add_variant(item.variant_id, item.user, item.quantity) unless current_items.include?(item.variant_id)
Severity: Minor
Found in app/models/cart.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 next_admin_order_form has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def next_admin_order_form()
     # if cart is empty
    if !session_admin_cart.customer_id
      return admin_shopping_users_url
    elsif !session_admin_cart.shopping_cart_items
Severity: Minor
Found in app/controllers/admin/shopping/checkout/base_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

Severity
Category
Status
Source
Language