buckybox/webstore

View on GitHub

Showing 5 of 7 total issues

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

class Order
  include Draper::Decoratable

  attr_reader :cart
  attr_reader :product_id
Severity: Minor
Found in app/models/order.rb - About 5 hrs to fix

    Class Cart has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Cart
      include Draper::Decoratable
    
      attr_reader :id
      attr_reader :order
    Severity: Minor
    Found in app/models/cart.rb - About 2 hrs to fix

      Class PaymentOptions has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class PaymentOptions < Form
        PAID = "paid"
      
        attribute :name,            String
        attribute :phone_number,    String
      Severity: Minor
      Found in app/models/checkout/payment_options.rb - About 2 hrs to fix

        Class CustomerFactory has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class CustomerFactory
          CustomerWrapper = Struct.new(
            :id, :address, :via_webstore, :email, :delivery_service_id,
            :first_name, :last_name
          )
        Severity: Minor
        Found in app/models/customer_factory.rb - About 2 hrs to fix

          Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def initialize(frequency:, start_date:, days:)
              self.frequency = frequency.to_sym
              raise ArgumentError unless FREQUENCIES.include?(self.frequency)
          
              self.start_date = start_date.is_a?(Date) ? start_date : Date.parse(start_date)
          Severity: Minor
          Found in lib/schedule_rule.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