Showing 5 of 7 total issues
Class Order
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Order
include Draper::Decoratable
attr_reader :cart
attr_reader :product_id
Class Cart
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Cart
include Draper::Decoratable
attr_reader :id
attr_reader :order
Class PaymentOptions
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class PaymentOptions < Form
PAID = "paid"
attribute :name, String
attribute :phone_number, String
Class CustomerFactory
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class CustomerFactory
CustomerWrapper = Struct.new(
:id, :address, :via_webstore, :email, :delivery_service_id,
:first_name, :last_name
)
Method initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
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)
- 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"