Showing 5 of 5 total issues
Method env_for
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
Open
def env_for(uri, env)
env = default_env.merge(env)
env['HTTP_HOST'] ||= [uri.host, (uri.port if uri.port != uri.default_port)].compact.join(':')
- 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
Class Session
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Session
extend Forwardable
include Rack::Test::Utils
def_delegators :@rack_mock_session, :clear_cookies, :set_cookie, :last_response, :last_request
Method env_for
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def env_for(uri, env)
env = default_env.merge(env)
env['HTTP_HOST'] ||= [uri.host, (uri.port if uri.port != uri.default_port)].compact.join(':')
Method custom_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def custom_request(verb, uri, params = {}, env = {}, &block)
Method parse_uri
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def parse_uri(path, env)
URI.parse(path).tap do |uri|
uri.path = "/#{uri.path}" unless uri.path[0] == '/'
uri.host ||= @default_host
uri.scheme ||= 'https' if env['HTTPS'] == 'on'
- 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"