Showing 23 of 23 total issues
Method stop
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def stop(_notification = nil)
@config.openapi_specs.each do |url_path, doc|
unless doc_version(doc).start_with?('2')
doc[:paths]&.each_pair do |_k, v|
v.each_pair do |_verb, 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 build_query_string_part
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def build_query_string_part(param, value, swagger_doc)
name = param[:name]
escaped_name = CGI.escape(name.to_s)
# OAS 3: https://swagger.io/docs/specification/serialization/
- 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_headers
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def add_headers(request, metadata, swagger_doc, parameters, example)
tuples = parameters
.select { |p| p[:in] == :header }
.map { |p| [p[:name], example.send(extract_getter(p)).to_s] }
- 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 build_query_string_part
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_query_string_part(param, value, swagger_doc)
name = param[:name]
escaped_name = CGI.escape(name.to_s)
# OAS 3: https://swagger.io/docs/specification/serialization/
Method stop
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stop(_notification = nil)
@config.openapi_specs.each do |url_path, doc|
unless doc_version(doc).start_with?('2')
doc[:paths]&.each_pair do |_k, v|
v.each_pair do |_verb, value|
Method add_path
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def add_path(request, metadata, swagger_doc, parameters, example)
open_api_3_doc = doc_version(swagger_doc).start_with?('3')
uses_base_path = swagger_doc[:basePath].present?
if open_api_3_doc && uses_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 validate_headers!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def validate_headers!(metadata, headers)
header_schemas = (metadata[:response][:headers] || {})
expected = header_schemas.keys
expected.each do |name|
nullable_attribute = header_schemas.dig(name.to_s, :schema, :nullable)
- 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_test!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run_test!(description = nil, *args, **options, &block)
# rswag metadata value defaults to true
options[:rswag] = true unless options.key?(:rswag)
description ||= "returns a #{metadata[:response][:code]} response"
- 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_headers
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_headers(request, metadata, swagger_doc, parameters, example)
tuples = parameters
.select { |p| p[:in] == :header }
.map { |p| [p[:name], example.send(extract_getter(p)).to_s] }
Method upgrade_oauth!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def upgrade_oauth!(swagger_doc)
# find flow in securitySchemes (securityDefinitions will have been re-written)
schemes = swagger_doc.dig(:components, :securitySchemes)
return unless schemes&.any? { |_k, v| v.key?(:flow) }
- 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 example_group_finished
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def example_group_finished(notification)
metadata = if RSPEC_VERSION > 2
notification.group.metadata
else
notification.metadata
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
path = env['PATH_INFO']
# Sanitize the filename for directory traversal by expanding, and ensuring
# its starts with the root directory.
openapi_root = @config.resolve_openapi_root(env)
- 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
Consider simplifying this complex logical expression. Open
if is_hash && value[:parameters]
schema_param = value[:parameters]&.find { |p| (p[:in] == :body || p[:in] == :formData) && p[:schema] }
mime_list = value[:consumes] || doc[:consumes]
if value && schema_param && mime_list
Method add_path
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_path(request, metadata, swagger_doc, parameters, example)
Method example
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def example(mime, name, value, summary=nil, description=nil)
Method add_headers
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_headers(request, metadata, swagger_doc, parameters, example)
Method expand_parameters
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def expand_parameters(metadata, swagger_doc, example)
operation_params = metadata[:operation][:parameters] || []
path_item_params = metadata[:path_item][:parameters] || []
security_params = derive_security_params(metadata, swagger_doc)
- 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 "#{escaped_name}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(separator)
Avoid too many return
statements within this method. Open
return "#{escaped_name}=#{CGI.escape(value.to_s)}" unless type&.to_sym == :array
Avoid too many return
statements within this method. Open
return "#{name}=#{value}"