Showing 327 of 327 total issues
Method reset
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def reset(fast_check=true)
@parser.reset
@io_buffer.reset
@read_header = true
@read_proxy = !!@expect_proxy_proto
- 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 try_to_finish
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def try_to_finish
if env[CONTENT_LENGTH] && above_http_content_limit(env[CONTENT_LENGTH].to_i)
@http_content_length_limit_exceeded = true
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def test_ssl_run_with_encrypted_pem
skip_if :jruby
config = <<~RUBY
key_path = '#{File.expand_path '../examples/puma/encrypted_puma_keypair.pem', __dir__}'
- 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 68.
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 2 locations. Consider refactoring. Open
def test_ssl_run_with_encrypted_key
skip_if :jruby
config = <<~RUBY
key_path = '#{File.expand_path '../examples/puma/encrypted_puma_keypair.pem', __dir__}'
- 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 68.
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 test_verify_client_cert_roundtrip
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_verify_client_cert_roundtrip(tls1_2 = nil)
cert_path = File.expand_path '../examples/puma/client-certs', __dir__
bind_port
config = <<~CONFIG
Method aggregated_results
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def aggregated_results(io)
is_github_actions = ENV['GITHUB_ACTIONS'] == 'true'
filtered_results = results.dup
if options[:verbose]
Method initialize
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(app, events = nil, options = {})
@app = app
@events = events || Events.new
@check, @notify = nil
Method call
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
unless authenticate(env)
return rack_response(403, 'Invalid auth token', 'text/plain')
end
Method try_to_finish
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def try_to_finish
if env[CONTENT_LENGTH] && above_http_content_limit(env[CONTENT_LENGTH].to_i)
@http_content_length_limit_exceeded = true
end
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 aggregated_results
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def aggregated_results(io)
is_github_actions = ENV['GITHUB_ACTIONS'] == 'true'
filtered_results = results.dup
if options[:verbose]
- 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 ci_test_rps
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def ci_test_rps
host = ENV['HOST']
port = ENV['PORT'].to_i
str = 'a' * 65_500
- 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 oob_server
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def oob_server(**options)
@request_count = 0
@oob_count = 0
in_oob = Mutex.new
@mutex = Mutex.new
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
unless authenticate(env)
return rack_response(403, 'Invalid auth token', 'text/plain')
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 generate_restart_data
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def generate_restart_data
if dir = @options[:directory]
@restart_dir = dir
elsif Puma.windows?
- 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 config
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def config(app, options = {})
require_relative '../../puma'
require_relative '../../puma/configuration'
require_relative '../../puma/log_writer'
require_relative '../../puma/launcher'
Method read_response_array
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_response_array(skts, resp_count: nil, body_only: nil)
results = Array.new skts.length
Thread.new do
until skts.compact.empty?
skts.each_with_index do |skt, idx|
Method setup_signals
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_signals
if @options[:fork_worker]
Signal.trap "SIGURG" do
fork_worker!
end
Method initialize
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
sleep 5 # wait for server to boot
@thread_loops = nil
@clients_per_thread = nil
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"