Noosfero/noosfero

View on GitHub
plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

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
Severity: Minor
Found in plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb - About 4 hrs to fix

    Class ShoppingCartPluginController has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ShoppingCartPluginController < OrdersPluginController
      include ShoppingCartPlugin::CartHelper
      helper ShoppingCartPlugin::CartHelper
    
      def get
    Severity: Minor
    Found in plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb - About 3 hrs to fix

      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
      Severity: Minor
      Found in plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb - About 45 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 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?
      
      
      Severity: Minor
      Found in plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb - About 35 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 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?
      Severity: Minor
      Found in plugins/shopping_cart/controllers/shopping_cart_plugin_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

      There are no issues that match your filters.

      Category
      Status