drhenner/ror_ecommerce

View on GitHub
app/models/order.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Order has 51 methods (exceeds 20 allowed). Consider refactoring.
Open

class Order < ApplicationRecord
  include AASM
  extend FriendlyId
  friendly_id :number
  include Presentation::OrderPresenter
Severity: Major
Found in app/models/order.rb - About 7 hrs to fix

    File order.rb has 324 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Order < ApplicationRecord
      include AASM
      extend FriendlyId
      friendly_id :number
      include Presentation::OrderPresenter
    Severity: Minor
    Found in app/models/order.rb - About 3 hrs to fix

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

        def create_invoice(credit_card, charge_amount, args, credited_amount = 0.0)
          transaction do
            new_invoice = create_invoice_transaction(credit_card, charge_amount, args, credited_amount)
            if new_invoice.succeeded?
              remove_user_store_credits
      Severity: Minor
      Found in app/models/order.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 update_tax_rates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_tax_rates
          if saved_change_to_attribute?(:ship_address_id)
            # set_beginning_values
            tax_time = completed_at? ? completed_at : Time.zone.now
            order_items.each do |item|
      Severity: Minor
      Found in app/models/order.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 remove_items has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def remove_items(variant, final_quantity)
      
          current_qty = 0
          items_to_remove = []
          self.order_items.each_with_index do |order_item, i|
      Severity: Minor
      Found in app/models/order.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 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

      There are no issues that match your filters.

      Category
      Status