File shopping_cart_plugin_controller.rb
has 334 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "base64"
class ShoppingCartPluginController < OrdersPluginController
include ShoppingCartPlugin::CartHelper
helper ShoppingCartPlugin::CartHelper
Class ShoppingCartPluginController
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class ShoppingCartPluginController < OrdersPluginController
include ShoppingCartPlugin::CartHelper
helper ShoppingCartPlugin::CartHelper
def get
Method repeat
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def repeat
unless params[:id].present?
@orders = previous_orders.last(5).reverse
@orders.each { |o| o.enable_product_diff }
else
- 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 buy
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def buy
@no_design_blocks = true
@customer = user || Person.new
return redirect_to request.referer || environment.top_url if self.cart.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
Method add
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add
product = find_product(params[:id])
if product && (profile = validate_same_profile(product))
self.cart = { profile_id: profile.id, items: {} } if self.cart.nil?
self.cart[:items][product.id] = 0 if self.cart[:items][product.id].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"