Showing 7 of 7 total issues
Class Booking
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
class Booking < Adapter
def self.api_base
'/api/bookings'
end
Class ProductConfiguration
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class ProductConfiguration
attr_reader :product, :extra_pick_configurations
delegate :id, :name, to: :product
def initialize(product)
Method cache
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.cache(key, cache_options = nil)
return yield unless key.present?
cache_options ||= {}
key = "#{@@namespace}_#{key}" unless cache_options[:disable_namespacing]
cached_value = cache_store.read(key)
- 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"
Further reading
Method call_and_validate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.call_and_validate(http_method, path, query = {}, opts = {})
http_params = opts.clone
# Set default token
http_params[:query] ||= FilterQuery.new(query).call
http_params[:headers] ||= {}
Method define_readers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def define_readers(keys)
keys.each do |key|
next if respond_to?(key)
define_singleton_method(key) { instance_variable_get("@#{key}") }
if key.to_s.ends_with? '_cents'
- 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"
Further reading
Method call_and_validate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.call_and_validate(http_method, path, query = {}, opts = {})
http_params = opts.clone
# Set default token
http_params[:query] ||= FilterQuery.new(query).call
http_params[:headers] ||= {}
- 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"
Further reading
Avoid too many return
statements within this method. Open
return convert(value, :to_datetime) if attribute.to_s.ends_with?('_at')