Showing 4 of 150 total issues
Method pump_buffer
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def pump_buffer
@mutex.synchronize do
written = 0
begin
written = inner.write_nonblock @buffer unless @buffer.empty?
- 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 add_to_reactor
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def add_to_reactor
@monitor = Reactor.selector.register(inner, :rw) # This can block if this is the main thread and the reactor is busy
monitor.value = proc do
begin
read if monitor.readable?
- 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 start
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start
WebSocket.logger.debug "Starting reactor" unless @reactor
@reactor ||= Thread.start do
Thread.current.abort_on_exception = true
WebSocket.logger.info "Reactor started"
Method try_accept_nonblock
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def try_accept_nonblock(io)
waiting = accept_nonblock io
if [:r, :w].include? waiting
# Only happens on server side ssl negotiation
Reactor.queue_task do
- 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"