Showing 6 of 9 total issues
Method method
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.method(url, options = {})
is_valid_url?(url)
# normalize url
url = Addressable::URI.parse(url).normalize
- 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 method
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.method(url, options = {})
is_valid_url?(url)
# normalize url
url = Addressable::URI.parse(url).normalize
Method rescue_faraday_error
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.rescue_faraday_error(error, response)
if error.is_a?(Faraday::ResourceNotFound)
{ "errors" => [{ "status" => 404, "title" => "Not found" }] }
elsif error.message == "the server responded with status 401" || error.try(:response) && error.response[:status] == 401
{ "errors" => [{ "status" => 401, "title" => "Unauthorized" }] }
- 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 faraday_conn
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.faraday_conn(options = {})
# make sure we have headers
options[:headers] ||= {}
# set redirect limit
- 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 set_request_headers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.set_request_headers(_url, options = {})
header_options = { "html" => "text/html;charset=UTF-8",
"xml" => "application/xml;charset=UTF-8",
"json" => "application/json;charset=UTF-8" }
- 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_success_response
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_success_response(string, options = {})
return nil if options[:method] == "head"
string = parse_response(string, options)
- 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"