Showing 327 of 327 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def test_post_then_get
    @client << @valid_post
    sz = @body[0].size.to_s

    assert_equal "HTTP/1.1 200 OK\r\nX-Header: Works\r\nContent-Length: #{sz}\r\n\r\n", lines(4)
Severity: Minor
Found in test/test_persistent.rb and 1 other location - About 55 mins to fix
test/test_persistent.rb on lines 55..66

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 44.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

  def test_chunked_request_pause_before_closing_cr_lf
    body = nil
    content_length = nil
    server_run { |env|
      body = env['rack.input'].read
Severity: Major
Found in test/test_puma_server.rb and 6 other locations - About 55 mins to fix
test/test_puma_server.rb on lines 959..977
test/test_puma_server.rb on lines 980..998
test/test_puma_server.rb on lines 1001..1019
test/test_puma_server.rb on lines 1022..1040
test/test_puma_server.rb on lines 1043..1061
test/test_puma_server.rb on lines 1094..1113

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 44.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

  def test_chunked_request_pause_between_closing_cr_lf
    body = nil
    content_length = nil
    server_run { |env|
      body = env['rack.input'].read
Severity: Major
Found in test/test_puma_server.rb and 6 other locations - About 55 mins to fix
test/test_puma_server.rb on lines 959..977
test/test_puma_server.rb on lines 980..998
test/test_puma_server.rb on lines 1001..1019
test/test_puma_server.rb on lines 1022..1040
test/test_puma_server.rb on lines 1043..1061
test/test_puma_server.rb on lines 1116..1135

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 44.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

  def test_chunked_request_pause_before_value
    body = nil
    content_length = nil
    server_run { |env|
      body = env['rack.input'].read
Severity: Major
Found in test/test_puma_server.rb and 6 other locations - About 55 mins to fix
test/test_puma_server.rb on lines 980..998
test/test_puma_server.rb on lines 1001..1019
test/test_puma_server.rb on lines 1022..1040
test/test_puma_server.rb on lines 1043..1061
test/test_puma_server.rb on lines 1094..1113
test/test_puma_server.rb on lines 1116..1135

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 44.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

  def test_chunked_request_pause_mid_value
    body = nil
    content_length = nil
    server_run { |env|
      body = env['rack.input'].read
Severity: Major
Found in test/test_puma_server.rb and 6 other locations - About 55 mins to fix
test/test_puma_server.rb on lines 959..977
test/test_puma_server.rb on lines 980..998
test/test_puma_server.rb on lines 1001..1019
test/test_puma_server.rb on lines 1022..1040
test/test_puma_server.rb on lines 1094..1113
test/test_puma_server.rb on lines 1116..1135

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 44.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

  def test_chunked_request_pause_before_count_newline
    body = nil
    content_length = nil
    server_run { |env|
      body = env['rack.input'].read
Severity: Major
Found in test/test_puma_server.rb and 6 other locations - About 55 mins to fix
test/test_puma_server.rb on lines 959..977
test/test_puma_server.rb on lines 980..998
test/test_puma_server.rb on lines 1001..1019
test/test_puma_server.rb on lines 1043..1061
test/test_puma_server.rb on lines 1094..1113
test/test_puma_server.rb on lines 1116..1135

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 44.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

  def test_chunked_request_pause_between_chunks
    body = nil
    content_length = nil
    server_run { |env|
      body = env['rack.input'].read
Severity: Major
Found in test/test_puma_server.rb and 6 other locations - About 55 mins to fix
test/test_puma_server.rb on lines 959..977
test/test_puma_server.rb on lines 1001..1019
test/test_puma_server.rb on lines 1022..1040
test/test_puma_server.rb on lines 1043..1061
test/test_puma_server.rb on lines 1094..1113
test/test_puma_server.rb on lines 1116..1135

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 44.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def test_tls_v1_1_rejection
    start_server { |ctx| ctx.no_tlsv1_1 = true }

    assert_raises(OpenSSL::SSL::SSLError) do
      send_http_read_response ctx: new_ctx { |c|
Severity: Minor
Found in test/test_puma_server_ssl.rb and 1 other location - About 45 mins to fix
test/test_puma_server_ssl.rb on lines 132..146

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 41.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def test_tls_v1_rejection
    start_server { |ctx| ctx.no_tlsv1 = true }

    assert_raises(OpenSSL::SSL::SSLError) do
      send_http_read_resp_body ctx: new_ctx { |c|
Severity: Minor
Found in test/test_puma_server_ssl.rb and 1 other location - About 45 mins to fix
test/test_puma_server_ssl.rb on lines 150..164

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 41.

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

Further Reading

Avoid deeply nested control flow statements.
Open

                    rescue EOFError
                      break
Severity: Major
Found in test/helpers/test_puma/puma_socket.rb - About 45 mins to fix

    Method spawn_workers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def spawn_workers
          diff = @options[:workers] - @workers.size
          return if diff < 1
    
          master = Process.pid
    Severity: Minor
    Found in lib/puma/cluster.rb - About 45 mins to fix

    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)
    Severity: Minor
    Found in lib/puma/request.rb - About 45 mins to fix

      Method test_ssl_v3_rejection has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def test_ssl_v3_rejection
          skip("SSLv3 protocol is unavailable") if Puma::MiniSSL::OPENSSL_NO_SSL3
          start_server
      
          assert_raises(OpenSSL::SSL::SSLError) do
      Severity: Minor
      Found in test/test_puma_server_ssl.rb - About 45 mins to fix

      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

      Avoid deeply nested control flow statements.
      Open

                        if !booted && @workers.none? {|worker| worker.last_status.empty?}
                          @events.fire_on_booted!
                          debug_loaded_extensions("Loaded Extensions - master:") if @log_writer.debug?
                          booted = true
                        end
      Severity: Major
      Found in lib/puma/cluster.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                          if idle_workers[pid]
                            idle_workers.delete pid
                          else
                            idle_workers[pid] = true
                          end
        Severity: Major
        Found in lib/puma/cluster.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            if in_phased_restart && workers_not_booted.positive? && w0 = worker_at(0)
                              w0.ping!(status)
                              @events.fire(:ping!, w0)
                            end
          Severity: Major
          Found in lib/puma/cluster.rb - About 45 mins to fix

            Method test_drain_on_shutdown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def test_drain_on_shutdown(drain=true)
                num_connections = 10
            
                wait = Queue.new
                server_run(drain_on_shutdown: drain, max_threads: 1) do
            Severity: Minor
            Found in test/test_puma_server.rb - About 45 mins to fix

            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 thread_run_step has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def thread_run_step(replies, delay, sleep_time, step, mutex, refused, unix: false)
            Severity: Minor
            Found in test/test_integration_cluster.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                w.term unless w.term?
              Severity: Major
              Found in lib/puma/cluster.rb - About 45 mins to fix

                Method test_verify_client_cert_roundtrip has a Cognitive Complexity of 8 (exceeds 5 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
                Severity: Minor
                Found in test/test_integration_ssl.rb - About 45 mins to fix

                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

                Severity
                Category
                Status
                Source
                Language