Showing 3 of 3 total issues
Method get_with_caching
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.get_with_caching(path, options={})
return get_without_caching(path, options) unless get_cache
key = path.downcase # this makes a copy of path
key << options[:query].to_s if defined? options[:query]
if res = get_cache.read(key)
- 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 included
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.included(receiver) #:nodoc:
receiver.extend ClassMethods
receiver.class_eval do
# Get reponse from network
Method cache_response?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.cache_response?(response)
return false if !response.body
return false unless response.code.to_s == "200"
timeout = response.headers['cache-control'] && response.headers['cache-control'][/max-age=(\d+)/, 1].to_i()
return false unless timeout && timeout != 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"