Showing 83 of 103 total issues
Avoid deeply nested control flow statements. Open
if value.nil?
@errors[validation[:field_name]] << (validation[:options][:message] || "must be not be nil") unless allow_nil
else
numeric = (true if Float(value) rescue false)
if !numeric
Consider simplifying this complex logical expression. Open
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)
Consider simplifying this complex logical expression. Open
if @forced_url && @forced_url.present?
@url = @forced_url
else
@url = @method[:url].dup
matches = @url.scan(/(:[a-z_-]+)/)
Method warn
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.warn(message)
if defined?(Rails) && Rails.logger.present?
Rails.logger.warn(message)
elsif @logfile
if @logfile.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
Method read_cached_response
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def read_cached_response(request, quiet)
if cache_store && perform_caching && request.method[:method] == :get
key = "#{request.class_name}:#{request.original_url}"
Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{key} - Trying to read from cache" unless quiet
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 sign_request
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sign_request(request, api_auth)
return if api_auth[:api_auth_access_id].nil? || api_auth[:api_auth_secret_key].nil?
ApiAuth.sign!(
request,
api_auth[:api_auth_access_id],
- 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 error
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.error(message)
if defined?(Rails) && Rails.logger.present?
Rails.logger.error(message)
elsif @logfile
if @logfile.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
Method append_parameter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.append_parameter(fp, key, value)
if value.is_a?(Array)
value.each do |i|
append_parameter(fp, "#{key}[]", i)
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 parse
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse(body, object)
# Save resource class for building lazy association loaders
save_resource_class(object)
# According to the spec:
- 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 info
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.info(message)
if defined?(Rails) && Rails.logger.present?
Rails.logger.info(message)
elsif @logfile
if @logfile.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
Method debug
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.debug(message)
if defined?(Rails) && Rails.logger.present?
Rails.logger.debug(message)
elsif @logfile
if @logfile.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
Avoid too many return
statements within this method. Open
return result if response.finished?
Avoid too many return
statements within this method. Open
return @response_delegate
Method _set_attribute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _set_attribute(key, value)
old_value = @dirty_attributes[key.to_sym]
old_value = @attributes[key.to_sym] unless old_value
old_value = old_value[0] if old_value and old_value.is_a? Array
@dirty_attributes[key.to_sym] = [old_value, value] if old_value != 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 api_auth_access_id
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def api_auth_access_id
ret = nil
if object_is_class?
ret = @object.api_auth_access_id
ret = ret.call if ret.respond_to?(:call)
- 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 username
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def username
ret = nil
if object_is_class?
ret = @object.username
ret = ret.call if ret.respond_to?(:call)
- 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 wrap_root
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def wrap_root(value=nil)
if value.nil?
value = if @wrap_root.nil? && superclass.respond_to?(:wrap_root)
superclass.wrap_root
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"
Further reading
Method password
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def password
ret = nil
if object_is_class?
ret = @object.password
ret = ret.call if ret.respond_to?(:call)
- 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 has_one
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def has_one(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 ignore_root
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ignore_root(value=nil)
if value.nil?
value = if @ignore_root.nil? && superclass.respond_to?(:ignore_root)
superclass.ignore_root
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"