Showing 4 of 4 total issues
Method get_response
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_response(url, wait_sec, redirect_url = nil, redirect_count = 0, retry_count = 0)
result = HttpStatusChecker::Connection.get_header(redirect_url || url)
parse_response(redirect_count, redirect_url, result, url, wait_sec)
rescue => e
if retry_count < RETRY_MAX
- 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 get_response
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def get_response(url, wait_sec, redirect_url = nil, redirect_count = 0, retry_count = 0)
Method parse_response
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def parse_response(redirect_count, redirect_url, result, url, wait_sec)
Method parse_response
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def parse_response(redirect_count, redirect_url, result, url, wait_sec)
location_url = result['location']
if !location_url.nil? && (redirect_url || url) != location_url
raise InvalidRedirectError if redirect_count >= REDIRECT_MAX
get_response(url, wait_sec, location_url, redirect_count + 1, 0)
- 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"