Showing 327 of 327 total issues
Method initialize
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(name, options = {}, &block)
@not_empty = ConditionVariable.new
@not_full = ConditionVariable.new
@mutex = Mutex.new
Method test_control_clustered
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_control_clustered
skip_unless :fork
skip_unless :unix
url = "unix://#{@tmp_path}"
Method test_chunked_keep_alive_two_back_to_back
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_chunked_keep_alive_two_back_to_back
body = nil
content_length = nil
server_run { |env|
body = env['rack.input'].read
Method initialize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(argv, log_writer = LogWriter.stdio, events = Events.new)
@debug = false
@argv = argv.dup
@log_writer = log_writer
@events = events
Method serialize_value
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def serialize_value(output, value)
case value
when Hash
output << '{'
value.each_with_index do |(k, v), index|
Similar blocks of code found in 3 locations. Consider refactoring. Open
def test_user_port_wins_over_config
user_port = 5001
file_port = 6001
Dir.mktmpdir do |d|
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 52.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def test_port_wins_over_config
user_port = 5001
file_port = 6001
Dir.mktmpdir do |d|
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 52.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def test_config_file_wins_over_port
user_port = 5001
file_port = 6001
Dir.mktmpdir do |d|
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 52.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method issue_cert
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def issue_cert(dn, key, serial, not_before, not_after, extensions, issuer, issuer_key, digest)
Method test_horrible_queries
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_horrible_queries
parser = Puma::HttpParser.new
# then that large header names are caught
10.times do |c|
Method new_socket
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_socket(host: nil, port: nil, path: nil, ctx: nil, session: nil)
port ||= @bind_port
path ||= @bind_path
ip ||= (host || HOST.ip).gsub RE_HOST_TO_IP, '' # in case a URI style IPv6 is passed
Method test_worker_index_is_with_in_options_limit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def test_worker_index_is_with_in_options_limit
skip_unless_signal_exist? :TERM
cli_server "-C test/config/t3_conf.rb test/rackup/hello.ru"
- 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 term_closes_listeners
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def term_closes_listeners(unix: false)
skip_unless_signal_exist? :TERM
cli_server "-w #{workers} -t 0:6 -q test/rackup/sleep_step.ru", unix: unix
threads = []
- 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
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def fast_write(io, str)
n = 0
while true
begin
n = io.syswrite str
- 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 handler_opts
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def handler_opts(options)
begin
info = []
server = Rack::Handler.get(options[:server]) || Rack::Handler.default(options)
if server&.respond_to?(:valid_options)
- 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 cli_server
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def cli_server(argv, # rubocop:disable Metrics/ParameterLists
unix: false, # uses a UNIXSocket for the server listener when true
config: nil, # string to use for config file
no_bind: nil, # bind is defined by args passed or config file
merge_err: false, # merge STDERR into STDOUT
- 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 test_closed_listener
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def test_closed_listener
skip_unless_signal_exist? :TERM
cli_server "test/rackup/close_listeners.ru", merge_err: true
connection = fast_connect
- 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 load
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def load(path)
File.read(path).lines.each do |line|
next if line.start_with? '#'
k,v = line.split ':', 2
next unless v && ALLOWED_FIELDS.include?(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 wait_for_less_busy_worker
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_less_busy_worker(delay_s)
return unless delay_s && delay_s > 0
# Ruby MRI does GVL, this can result
# in processing contention when multiple threads
- 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 lowlevel_error
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def lowlevel_error(e, env, status=500)
if handler = options[:lowlevel_error_handler]
if handler.arity == 1
return handler.call(e)
elsif handler.arity == 2
- 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"