Showing 2 of 2 total issues
Method formatted_body
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def formatted_body(body, type)
return body if body == " "
return body if body == "[binary data]" # see https://github.com/zipmark/rspec_api_documentation/blob/560c3bdc7bd5581e7c223334390221ecfc910be8/lib/rspec_api_documentation/client_base.rb#L88-L96
if type =~ /json/ && body.present?
JSON.pretty_generate(JSON.parse(body))
- 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 file_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def file_for(file, readme: false)
if Apitome.configuration.remote_url
file = readme ? file : "#{Apitome.configuration.doc_path}/#{file}"
file = CGI.escape("#{Apitome.configuration.remote_url}/#{file}")
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"