Showing 22 of 78 total issues
Class Params
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Params
DEFAULT_OPTS = { strict: true }.freeze
BASIC_TYPES = [String, Symbol, Float, Integer, Array, Hash].freeze
DEFAULT_TYPE_MATCHERS = {
Class Service
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Service
autoload(:Request, 'rester/service/request')
autoload(:Resource, 'rester/service/resource')
autoload(:Middleware, 'rester/service/middleware')
Method assert_deep_include
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def assert_deep_include(response, stub, accessors=[])
case stub
when Hash
_type_error(response, stub, accessors) unless response.is_a?(Hash)
stub.all? { |k,v| assert_deep_include(response[k], v, accessors + [k]) }
- 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
File params.rb
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Rester
class Service::Resource
class Params
DEFAULT_OPTS = { strict: true }.freeze
BASIC_TYPES = [String, Symbol, Float, Integer, Array, Hash].freeze
Method _setup_example
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _setup_example(ex)
# Gather the request args from the spec descriptions
#
# For example:
#
- 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 _add_validator
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _add_validator(name, klass, opts)
fail 'must specify param name' unless name
fail 'validation options must be a Hash' unless opts.is_a?(Hash)
default_opts = { match: DEFAULT_TYPE_MATCHERS[klass] }
opts = default_opts.merge(opts)
- 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 _request
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _request(verb, path, opts={})
body = opts[:data] || ''
query = opts[:query] || ''
response = Timeout::timeout(timeout) do
Method _process_request
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _process_request(path, verb, params)
unless stub[path]
fail Errors::StubError, "#{path} not found"
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 _request
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _request(verb, path, opts={})
body = opts[:data] || ''
query = opts[:query] || ''
response = Timeout::timeout(timeout) do
- 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_with_class
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _parse_with_class(klass, value)
if klass == String
value
elsif klass == Integer
value.to_i
- 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 encode_www_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def encode_www_data(value, prefix = nil)
# Rack::Utils.build_nested_query(value)
case value
when Array
value.map { |v|
- 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_to_response
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _error_to_response(error)
code = _error_to_http_code(error)
unless [401, 403, 404].include?(code)
body_h = { error: _error_name(error) }
- 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 _process_response
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _process_response(start_time, verb, path, status, headers, body)
Method _validate_required
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _validate_required(key, is_defined)
unless is_defined
_, key, index = /(\w+)(\[\d+\])?/.match(key).to_a
if required?(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 _find_service
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _find_service
service = app
loop {
break if service.is_a?(Service)
- 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 _record_failure
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _record_failure
if @failure_count < threshold
_synchronize do
if @failure_count < threshold
@failure_count += 1
- 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 _param_diff
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _param_diff(params, spec_params)
params = params.dup
# Compile a list of mismatched params values
diff = spec_params.map { |k,v|
param_value = params.delete(k)
- 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 _validate_obj
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _validate_obj(key, obj, opts)
fail if obj.nil? # Assert, at this point should be guaranteed
opts.each do |opt, value|
case opt
- 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 _validate_str
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _validate_str(key, value, klass, opts)
fail unless value.is_a?(String) # assert
if [Array, Hash].include?(klass)
_error!("expected #{key} to be of type #{klass}")
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 _determine_method
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _determine_method(request)
if request.object_chain.length.odd?
case request.request_method
when 'GET' then 'search'
when 'POST' then 'create'
- 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"