Method handle_request
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def handle_request(request)
unless json_msg = message_from_request(request)
error 'Received request with no message: ?', format_request(request)
return [400, TYPE_TEXT, ['Bad request']]
end
- 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 handle_request
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_request(request)
unless json_msg = message_from_request(request)
error 'Received request with no message: ?', format_request(request)
return [400, TYPE_TEXT, ['Bad request']]
end
Method handle_websocket
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def handle_websocket(request)
options = {:extensions => @extensions, :ping => @options[:ping]}
ws = Faye::WebSocket.new(request.env, [], options)
client_id = nil
- 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 call
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
Faye.ensure_reactor_running!
request = Rack::Request.new(env)
unless request.path_info =~ @endpoint_re
- 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
Avoid too many return
statements within this method. Open
return handle_eventsource(request) if Faye::EventSource.eventsource?(env)
Method initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(app = nil, options = nil, &block)
@app = app if app.respond_to?(:call)
@options = [app, options].grep(Hash).first || {}
::WebSocket::Driver.validate_options(@options, [:engine, :mount, :ping, :timeout, :extensions, :websocket_extensions])
- 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"