Showing 83 of 103 total issues
Method has_many
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def has_many(key, klass = nil)
if klass.nil?
klass = key.to_s.classify.constantize
end
- 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 perform_caching
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def perform_caching(value = nil)
@perform_caching = nil unless instance_variable_defined?(:@perform_caching)
if value.nil?
value = if @perform_caching.nil?
@@perform_caching
- 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 make_safe_request
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def make_safe_request(path, &block)
block.call
rescue Faraday::TimeoutError
raise Flexirest::TimeoutException.new("Timed out getting #{full_url(path)}")
rescue Faraday::ConnectionFailed => e1
- 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 handle_hal_links_embedded
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_hal_links_embedded(object, attributes)
attributes["_links"] = attributes[:_links] if attributes[:_links]
attributes["_embedded"] = attributes[:_embedded] if attributes[:_embedded]
if attributes["_links"]
attributes["_links"].each do |key, value|
Method fetch_attributes_and_relationships
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_attributes_and_relationships(record, included, rels, base: nil)
base = Array(base) unless base.is_a?(Array)
rels = rels - [base.last]
rels_object = record['relationships']
Method new_object
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_object(attributes, name = nil, parent = nil, parent_attribute_name = nil)
@method[:options][:has_many] ||= {}
name = name.to_sym rescue nil
if @method[:options][:has_many][name]
parent_name = name
Method parse_attribute_value
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parse_attribute_value(v)
return v if v.is_a?(Date) || v.is_a?(DateTime) ||
v.kind_of?(NilClass) || v.kind_of?(TrueClass) || v.kind_of?(FalseClass) || v.kind_of?(Numeric)
if v.to_s[(/\A(((19|20)\d\d[- \/.](0[1-9]|1[012]|[1-9])[- \/.](0[1-9]|[12][0-9]|3[01]|[1-9]))|((0[1-9]|1[012]|[1-9])[- \/.](0[1-9]|[12][0-9]|3[01]|[1-9])[- \/.](19|20)\d\d))\Z/)]
- 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 deeply nested control flow statements. Open
if options[:maximum]
@errors[validation[:field_name]] << (validation[:options][:message] || "must be no more than #{options[:maximum]} characters long") unless value.to_s.length <= options[:maximum]
end
Avoid deeply nested control flow statements. Open
@errors[validation[:field_name]] << (validation[:options][:message] || "must be not be nil") unless allow_nil
Avoid deeply nested control flow statements. Open
@body ||= if params.is_a?(String)
params
elsif @post_params.is_a?(String)
@post_params
else
Avoid deeply nested control flow statements. Open
if @object.changes.has_key? changed_attr.to_sym
newPostHash[changed_attr.to_sym] = @object[changed_attr.to_sym]
end
Avoid deeply nested control flow statements. Open
if options[:within]
@errors[validation[:field_name]] << (validation[:options][:message] || "must be within range #{options[:within]}") unless options[:within].include?(value.to_s.length )
end
Avoid deeply nested control flow statements. Open
raise ValidationFailedException.new if respond_to?(:valid?) && !valid?
Avoid deeply nested control flow statements. Open
if wrap_root.present?
p = {wrap_root => p}
end
Method value_for_inspect
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def value_for_inspect(value)
if value.is_a?(String) && value.length > 50
"#{value[0..50]}...".inspect
elsif value.is_a?(Date) || value.is_a?(Time)
%("#{value.respond_to?(:to_fs) ? value.to_fs(:db) : value.to_s(:db)}")
- 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 deeply nested control flow statements. Open
elsif type == :minimum
if value.nil?
@errors[validation[:field_name]] << (validation[:options][:message] || "must be not be nil") unless allow_nil
else
@errors[validation[:field_name]] << (validation[:options][:message] || "must be at least #{options}") unless value.to_f >= options.to_f
Avoid deeply nested control flow statements. Open
if options[:minimum]
@errors[validation[:field_name]] << (validation[:options][:message] || "must be at least #{options[:minimum]} characters long") unless value.to_s.length >= options[:minimum]
end
Method each
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def each
if @subloaders
if @subloaders.is_a? Array
@subloaders.each do |loader|
yield loader
- 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 deeply nested control flow statements. Open
elsif request_body_type == :json
@body ||= if params.is_a?(String)
params
elsif @post_params.is_a?(String)
@post_params
Method cache_store=
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def cache_store=(value)
@@cache_store = nil if value.nil? and return
raise InvalidCacheStoreException.new("Cache store does not implement #read") unless value.respond_to?(:read)
raise InvalidCacheStoreException.new("Cache store does not implement #write") unless value.respond_to?(:write)
raise InvalidCacheStoreException.new("Cache store does not implement #fetch") unless value.respond_to?(:fetch)
- 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"