rails-stall/stall

View on GitHub

Showing 18 of 168 total issues

Method draw has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def draw(mount_location, options = {})
      routes = self

      users = options.fetch(:users, true)
      products = options.fetch(:products, true)
Severity: Major
Found in lib/stall/routes.rb - About 2 hrs to fix

    Method create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def create
          if service.call
            @quantity = params[:line_item][:quantity].to_i
            @line_item = service.line_item
            # Allow subclasses to hook into successful product list add
    Severity: Minor
    Found in app/controllers/stall/line_items_controller.rb - About 1 hr 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 cart_params has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def cart_params(*attributes)
            @cart_params ||= super(
              *merge_arrays(
                [
                  :use_another_address_for_billing, :terms,
    Severity: Minor
    Found in lib/stall/checkout/informations_checkout_step.rb - About 1 hr to fix

      Method validate_nested_forms has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def validate_nested_forms
              # If no nested forms are present in the class, just return true since
              # no validation should be tested
              return true unless nested_forms
      
      
      Severity: Minor
      Found in lib/stall/checkout/step_form.rb - About 1 hr 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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def call
            return false unless line_item_valid?
      
            cart.line_items << line_item unless assemble_identical_line_items
      
      
      Severity: Minor
      Found in app/services/stall/add_to_cart_service.rb - About 55 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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def create
            if !service.line_item_params? && (product_id = params[:product_id]).present?
              product = Product.find(product_id)
      
              if product.variants.length > 1
      Severity: Minor
      Found in app/controllers/stall/wish_list_line_items_controller.rb - About 55 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 draw has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def draw(mount_location, options = {})
            routes = self
      
            users = options.fetch(:users, true)
            products = options.fetch(:products, true)
      Severity: Minor
      Found in lib/stall/routes.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 prepare_cart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def prepare_cart(cart)
            cart.tap do
              cart.customer = current_customer if current_customer
              # Keep track of potential customer locale switching to allow e-mailing
              # him in his last used locale
      Severity: Minor
      Found in lib/stall/cart_helper.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 copy_address has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def copy_address(type)
              source.with_actual_address_associations do
                target.with_actual_address_associations do
                  address = if target.send(:"#{ type }_address?")
                    target.send(:"#{ type }_address")
      Severity: Minor
      Found in lib/stall/addresses/copy_source_to_target.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 prepare_wish_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def prepare_wish_list(wish_list)
            wish_list.tap do
              wish_list.customer = current_customer if current_customer
              # Keep track of potential customer locale switching to allow e-mailing
              # him in his last used locale
      Severity: Minor
      Found in lib/stall/wish_list_helper.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 load_from has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_from(csv_string)
              csv = CSV.parse(csv_string)
              headers = csv.shift
      
              headers.each_with_index.each_with_object({}) do |(countries, index), hash|
      Severity: Minor
      Found in lib/stall/shipping/country_weight_table_calculator.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 for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.for(shipping_method)
              identifier = case shipping_method
              when String, Symbol then shipping_method.to_s
              else shipping_method && shipping_method.identifier
              end
      Severity: Minor
      Found in lib/stall/shipping/calculator.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 find_cart has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_cart(identifier, ensure_active_cart = true)
            if (cart_token = cookies.encrypted[cart_key(identifier)])
              if (current_cart = ProductList.find_by_token(cart_token)) &&
                 (!ensure_active_cart || current_cart.active?)
              then
      Severity: Minor
      Found in lib/stall/cart_helper.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 prepare_user_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def prepare_user_attributes
              return if params[:create_account] == '1'
      
              if cart_params[:customer_attributes] && cart_params[:customer_attributes][:user_attributes]
                cart_params[:customer_attributes].delete(:user_attributes)
      Severity: Minor
      Found in lib/stall/checkout/informations_checkout_step.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 with_errors_from_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def with_errors_from_user(customer)
            return customer unless (user = customer.user) && user.errors.any?
            return unless (messages = user.errors.messages[:email]) && messages.any?
      
            messages.each do |message|
      Severity: Minor
      Found in app/helpers/stall/customers_helper.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 find_wish_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_wish_list(identifier, ensure_active_wish_list = true)
            if (wish_list_token = cookies.encrypted[wish_list_key(identifier)])
              if (current_wish_list = ProductList.find_by_token(wish_list_token)) &&
                 (!ensure_active_wish_list || current_wish_list.active?)
              then
      Severity: Minor
      Found in lib/stall/wish_list_helper.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 param has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def param(name, default = nil)
              attr_writer name
      
              instance_variable_name = :"@#{ name }"
      
      
      Severity: Minor
      Found in lib/stall/utils/config_dsl.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 up has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def up
          change_table :stall_addresses do |t|
            t.string :type
            t.references :addressable, polymorphic: true
          end
      Severity: Minor
      Found in db/migrate/20161129101956_add_type_to_stall_address_ownerships.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