Method initialize
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
if desc_or_options.is_a?(Hash)
options = options.merge(desc_or_options)
elsif desc_or_options.is_a?(String)
- 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
Class ParamDescription
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class ParamDescription
attr_reader :method_description, :name, :desc, :allow_nil, :allow_blank, :validator, :options, :metadata, :show, :as, :validations, :response_only, :request_only
attr_reader :additional_properties, :is_array
attr_accessor :parent, :required
Method initialize
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
if desc_or_options.is_a?(Hash)
options = options.merge(desc_or_options)
elsif desc_or_options.is_a?(String)
Method validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate(value)
return true if allow_nil && value.nil?
return true if allow_blank && value.blank?
value = normalized_value(value)
if (!allow_nil && value.nil?) || (blank_forbidden? && value.blank?) || !validator.valid?(value)
- 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 action_awareness
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def action_awareness
if action_aware?
if !@options.key?(:allow_nil)
if @required
@allow_nil = false
- 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 initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
Method is_required?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_required?
if @options.key?(:required)
if (@options[:required] == true) || (@options[:required] == false)
@options[:required]
else
- 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"