Showing 35 of 35 total issues
Method route
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def route(verb, path, options = {}, &block)
no_swagger = options[:no_swagger]
options.delete(:no_swagger)
if (verb == 'HEAD') || no_swagger
super(verb, path, options, &block)
- 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
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def process(current_hash, current_field_name, current_fields, top_level_hash)
result = {}
current_hash.each_pair do |current_key, current_value|
key_sym = current_key.to_sym
- 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 to_swagger
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def to_swagger
result = {}
if @type
if @type == TYPE_ARRAY
- 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 to_swagger
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def to_swagger
result = {
:name => @name,
:in => @how_to_pass,
:required => @required
- 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 run
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def run(app, block_params, &block)
parsed_body = {}
if JSON_CONTENT_TYPE.like?(app.env['CONTENT_TYPE'])
body = app.request.body.read
unless body.empty?
- 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 to_swagger
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def to_swagger
result = @other_properties.clone
if @type
if @type == TYPE_ARRAY
- 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 route
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def route(verb, path, options = {}, &block)
no_swagger = options[:no_swagger]
options.delete(:no_swagger)
if (verb == 'HEAD') || no_swagger
super(verb, path, options, &block)
Method validate_limit_parameter
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate_limit_parameter(type, params, limit_param_name, exclusive_limit_param_name)
parameter_value = nil
if params.key? limit_param_name
unless [TYPE_INTEGER, TYPE_NUMBER].include? @type
raise SwaggerInvalidException.new("Parameter #{limit_param_name} can only be specified for types #{TYPE_INTEGER} or #{TYPE_NUMBER} and not for [#{@type}]")
- 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 to_swagger
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_swagger
result = {}
if @type
if @type == TYPE_ARRAY
Method to_swagger
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_swagger
result = {
:name => @name,
:in => @how_to_pass,
:required => @required
Method create_request_processor
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_request_processor(swagger_endpoint)
request_processor = Sinatra::SwaggerExposer::Processing::SwaggerRequestProcessor.new(swagger_endpoint.produces)
swagger_endpoint.parameters.each do |parameter|
if TYPE_FILE == parameter.type
Method create_parameter_value_processor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_parameter_value_processor(parameter)
type_name = parameter.type
if type_name == TYPE_ARRAY
if PRIMITIVE_TYPES.include? parameter.items
processor_for_values = Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValueProcessor.new(
Method initialize
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(type, sinatra_path, parameters, responses, summary, description, tags, explicit_path, produces)
Method run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(app, block_params, &block)
parsed_body = {}
if JSON_CONTENT_TYPE.like?(app.env['CONTENT_TYPE'])
body = app.request.body.read
unless body.empty?
Method process
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process(current_hash, current_field_name, current_fields, top_level_hash)
result = {}
current_hash.each_pair do |current_key, current_value|
key_sym = current_key.to_sym
Method to_swagger
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_swagger
result = {
swagger: '2.0',
consumes: ['application/json'],
produces: ['application/json'],
Method validate_response_content_type
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_response_content_type(content_type, response_status)
if content_type.nil? && (response_status == 204)
# No content and no content type => everything is OK
elsif @produces
# if there is no content type Sinatra will default to html so we simulate it here
- 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_length_parameter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_length_parameter(type, params, length_param_name)
if params.key? length_param_name
if type == TYPE_STRING
parameter_value = params[length_param_name]
unless parameter_value.is_a? Integer
- 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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(name, description, how_to_pass, required, type, params, known_types)
check_name(name)
@name = name
if description
- 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 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(name, description, how_to_pass, required, type, params, known_types)