Method fast_write_response
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
def fast_write_response(socket, body, io_buffer, chunked, content_length)
if body.is_a?(::File) && body.respond_to?(:read)
if chunked # would this ever happen?
while chunk = body.read(BODY_LEN_MAX)
io_buffer.append chunk.bytesize.to_s(16), LINE_END, chunk, LINE_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 str_headers
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def str_headers(env, status, headers, res_body, io_buffer, force_keep_alive)
line_ending = LINE_END
colon = COLON
- 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
File request.rb
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Puma
#———————————————————————— DO NOT USE — this class is for internal use only ———
# The methods here are included in Server, but are separated into this file.
Method prepare_response
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def prepare_response(status, headers, res_body, requests, client)
env = client.env
socket = client.io
io_buffer = client.io_buffer
- 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 a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def handle_request(client, requests)
env = client.env
io_buffer = client.io_buffer
socket = client.io # io may be a MiniSSL::Socket
app_body = 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 normalize_env
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def normalize_env(env, client)
if host = env[HTTP_HOST]
# host can be a hostname, ipv4 or bracketed ipv6. Followed by an optional port.
if colon = host.rindex("]:") # IPV6 with port
env[SERVER_NAME] = host[0, colon+1]
- 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 prepare_response
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_response(status, headers, res_body, requests, client)
env = client.env
socket = client.io
io_buffer = client.io_buffer
Method fast_write_response
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fast_write_response(socket, body, io_buffer, chunked, content_length)
if body.is_a?(::File) && body.respond_to?(:read)
if chunked # would this ever happen?
while chunk = body.read(BODY_LEN_MAX)
io_buffer.append chunk.bytesize.to_s(16), LINE_END, chunk, LINE_END
Method handle_request
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_request(client, requests)
env = client.env
io_buffer = client.io_buffer
socket = client.io # io may be a MiniSSL::Socket
app_body = nil
Method str_headers
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def str_headers(env, status, headers, res_body, io_buffer, force_keep_alive)
line_ending = LINE_END
colon = COLON
Method normalize_env
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def normalize_env(env, client)
if host = env[HTTP_HOST]
# host can be a hostname, ipv4 or bracketed ipv6. Followed by an optional port.
if colon = host.rindex("]:") # IPV6 with port
env[SERVER_NAME] = host[0, colon+1]
Method str_early_hints
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def str_early_hints(headers)
eh_str = +""
headers.each_pair do |k, vs|
next if illegal_header_key?(k)
- 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 req_env_post_parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def req_env_post_parse(env)
to_delete = nil
to_add = nil
env.each do |k,v|
- 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 fast_write_str
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def fast_write_str(socket, str)
n = 0
byte_size = str.bytesize
while n < byte_size
begin
- 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 str_headers
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def str_headers(env, status, headers, res_body, io_buffer, force_keep_alive)
Avoid deeply nested control flow statements. Open
if empty_body
io_buffer << CLOSE_CHUNKED
fast_write_str socket, io_buffer.read_and_reset
else
fast_write_str socket, CLOSE_CHUNKED
Avoid deeply nested control flow statements. Open
next if (byte_size = part.bytesize).zero?
Avoid deeply nested control flow statements. Open
if io_buffer.length > IO_BUFFER_LEN_MAX
fast_write_str socket, io_buffer.read_and_reset
end
Avoid deeply nested control flow statements. Open
if io_buffer.length > IO_BUFFER_LEN_MAX
fast_write_str socket, io_buffer.read_and_reset
end
Avoid deeply nested control flow statements. Open
next if part.bytesize.zero?
Avoid deeply nested control flow statements. Open
next if part.nil? || (byte_size = part.bytesize).zero?
Avoid deeply nested control flow statements. Open
next if part.bytesize.zero?
Method fast_write_response
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def fast_write_response(socket, body, io_buffer, chunked, content_length)
Method prepare_response
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def prepare_response(status, headers, res_body, requests, client)