Showing 17 of 21 total issues
Method setup
has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring. Open
def self.setup(options)
defaults = {
target_class: nil,
mount_path: '/swagger_doc',
mount_with_version: 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 parse_params
has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring. Open
def parse_params(params, path, method)
params ||= []
params.map do |param, value|
value[:type] = 'File' if value.is_a?(Hash) && value[:type] == 'Rack::Multipart::UploadedFile'
items = {}
- 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 create_documentation_class
has 348 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_documentation_class
Class.new(Grape::API) do
class << self
def name
@@class_name
File grape_swagger_modified.rb
has 388 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'kramdown'
module Grape
class API
class << self
attr_reader :combined_routes, :combined_namespaces
Method parse_entity_models
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def parse_entity_models(models)
result = {}
models.each do |model|
name = parse_entity_name(model)
properties = {}
- 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_header_params
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def parse_header_params(params)
params ||= []
params.map do |param, value|
data_type = '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 add_swagger_documentation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_swagger_documentation(options = {})
documentation_class = create_documentation_class
documentation_class.setup({ target_class: self }.merge(options))
mount(documentation_class)
- 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_base_path
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_base_path(base_path, request)
if base_path.is_a?(Proc)
base_path.call(request)
elsif base_path.is_a?(String)
URI(base_path).relative? ? URI.join(request.base_url, base_path).to_s : base_path
- 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_http_codes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parse_http_codes(codes, models)
codes ||= {}
codes.map do |k, v, m|
models << m if m
http_code_hash = {
- 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 combine_namespaces
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def combine_namespaces(app)
app.endpoints.each do |endpoint|
ns = if endpoint.respond_to?(:namespace_stackable)
endpoint.namespace_stackable(:namespace).last
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 parse_path
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_path(path, version)
# adapt format to swagger format
parsed_path = path.gsub('(.:format)', @@hide_format ? '' : '.{format}')
# This is attempting to emulate the behavior of
# Rack::Mount::Strexp. We cannot use Strexp directly because
- 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 content_types_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def content_types_for(target_class)
content_types = (target_class.settings[:content_types] || {}).values
if content_types.empty?
formats = [target_class.settings[:format], target_class.settings[:default_format]].compact.uniq
- 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 layout_template
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def layout_template
set_layouts_base unless env['api.tilt.layouts_base']
ver = env['rack.routing_args'][:route_info].route_version
layout_path = "#{env['api.tilt.layouts_base']}/#{ver}.json.haml"
if File.exist?(layout_path)
- 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 configure_tilt_root
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def configure_tilt_root
say "\n\nConfiguring Tilt for RABL templates..."
say ("-"*80)
if yes?("Will you be using RABL templates? (y/n)")
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def error!(message, status = nil, headers = nil)
if defined?(::Rails) && Rails.respond_to?(:logger)
api_version = "[#{env['rack.routing_args'][:route_info].route_version}]" rescue nil
Rails.logger.warn "[API]#{api_version} Responding with #{status} #{message}"
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 call
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.call(message, backtrace, options, env)
err = { error: { code: 'ERROR', message: message } }
if message.is_a?(Hash) && message[:code].present? && message[:message].present?
full_msg = "[#{message[:code]}] #{message[:message]}"
err = { error: { code: message[:code], message: full_msg } }
- 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
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def call(object, env)
@env = env
@endpoint = env['api.endpoint']
if rablable?
rabl do |template|
- 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"