Showing 12 of 15 total issues
Class API
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class Midori::API
class << self
# @!attribute routes
# @return [Hash] merged routes defined in the instance
# @!attribute scope_middlewares
Method receive
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def receive(request, connection = nil)
@routes[request.method].each do |route|
params = route.path.params(request.path)
next unless params # Skip if not matched
request.params = params
- 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 receive
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def receive(request, connection = nil)
@routes[request.method].each do |route|
params = route.path.params(request.path)
next unless params # Skip if not matched
request.params = params
Method initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
@header = HTTPHeader.new
@parsed = false
@body_parsed = false
@is_websocket = false
Method send
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send(msg)
output = []
payload_length = []
if msg.size < 126
payload_length << msg.size
Method parse
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parse(data)
# Call parser if header not parsed
if @parsed
@body += data
else
- 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 receive_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def receive_data(socket)
begin
@request.ip, @request.port = @peer_addr
if @request.parsed? && !(@request.body_parsed?)
data = socket.read @request.body.bytesize - @request.header['Content-Length']
- 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 middleware_exec
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private def middleware_exec(middlewares, clean_room, request, response=nil)
result = response.nil? ? request : response
middlewares.each do |middleware|
if response.nil?
result = Midori::Sandbox.run(
- 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 send
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def send(msg)
output = []
payload_length = []
if msg.size < 126
payload_length << msg.size
- 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 initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize
@header = HTTPHeader.new
@parsed = false
@body_parsed = false
@is_websocket = false
- 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 listen
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def listen
Fiber.schedule do
until @socket.closed?
receive_data(@socket)
if !@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 set
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set(option, value = (not_set = true), read_only = false)
raise ArgumentError if not_set
setter = proc { |val| set option, val }
getter = proc { value }
- 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"