Showing 327 of 327 total issues

Method test_closed_listener has 27 lines of code (exceeds 25 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
Severity: Minor
Found in test/test_integration_single.rb - About 1 hr to fix

    Method initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(io, env=nil)
          @io = io
          @to_io = io.to_io
          @io_buffer = IOBuffer.new
          @proto_env = env
    Severity: Minor
    Found in lib/puma/client.rb - About 1 hr to fix

      Method with_server has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def with_server(**options, &app)
          @requests_count = 0 # number of requests processed
          @requests_running = 0 # current number of requests running
          @requests_max_running = 0 # max number of requests running in parallel
          @mutex = Mutex.new
      Severity: Minor
      Found in test/test_busy_worker.rb - About 1 hr to fix

        Method test_drain_on_shutdown has 26 lines of code (exceeds 25 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 1 hr to fix

          Method cli_server has 26 lines of code (exceeds 25 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
          Severity: Minor
          Found in test/helpers/integration.rb - About 1 hr to fix

            Method select_loop has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def select_loop
                  close_selector = true
                  begin
                    until @input.closed? && @input.empty?
                      # Wakeup any registered object that receives incoming data.
            Severity: Minor
            Found in lib/puma/reactor.rb - About 1 hr to fix

              Method add_unix_listener has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def add_unix_listener(path, umask=nil, mode=nil, backlog=1024)
                    # Let anyone connect by default
                    umask ||= 0
              
                    begin
              Severity: Minor
              Found in lib/puma/binder.rb - About 1 hr to fix

                Method set_remote_address has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def set_remote_address(val=:socket)
                      case val
                      when :socket
                        @options[:remote_address] = val
                      when :localhost
                Severity: Minor
                Found in lib/puma/dsl.rb - About 1 hr to fix

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                      assert_ssl_client_error_match(false, context: ctx) do |client_ctx|
                        key = "#{CERT_PATH}/client.key"
                        crt = "#{CERT_PATH}/client.crt"
                        client_ctx.key = OpenSSL::PKey::RSA.new File.read(key)
                        client_ctx.cert = OpenSSL::X509::Certificate.new File.read(crt)
                  Severity: Major
                  Found in test/test_puma_server_ssl.rb and 2 other locations - About 1 hr to fix
                  test/test_puma_server_ssl.rb on lines 368..375
                  test/test_puma_server_ssl.rb on lines 407..414

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

                  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

                        key = "#{CERT_PATH}/client.key"
                        crt = "#{CERT_PATH}/client.crt"
                        client_ctx.key = OpenSSL::PKey::RSA.new File.read(key)
                        client_ctx.cert = OpenSSL::X509::Certificate.new File.read(crt)
                        client_ctx.ca_file = "#{CERT_PATH}/ca.crt"
                  Severity: Minor
                  Found in test/test_puma_server_ssl.rb and 1 other location - About 1 hr to fix
                  test/test_puma_server_ssl.rb on lines 423..431

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

                  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

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                      assert_ssl_client_error_match(false, context: ctx) do |client_ctx|
                        key = "#{CERT_PATH}/client.key"
                        crt = "#{CERT_PATH}/client.crt"
                        client_ctx.key = OpenSSL::PKey::RSA.new File.read(key)
                        client_ctx.cert = OpenSSL::X509::Certificate.new File.read(crt)
                  Severity: Major
                  Found in test/test_puma_server_ssl.rb and 2 other locations - About 1 hr to fix
                  test/test_puma_server_ssl.rb on lines 407..414
                  test/test_puma_server_ssl.rb on lines 462..469

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

                  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

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                      assert_ssl_client_error_match(false, context: ctx) do |client_ctx|
                        key = "#{CERT_PATH}/client.key"
                        crt = "#{CERT_PATH}/client.crt"
                        client_ctx.key = OpenSSL::PKey::RSA.new File.read(key)
                        client_ctx.cert = OpenSSL::X509::Certificate.new File.read(crt)
                  Severity: Major
                  Found in test/test_puma_server_ssl.rb and 2 other locations - About 1 hr to fix
                  test/test_puma_server_ssl.rb on lines 368..375
                  test/test_puma_server_ssl.rb on lines 462..469

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

                  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

                        key = "#{CERT_PATH}/client.key"
                        crt = "#{CERT_PATH}/client.crt"
                        client_ctx.key = OpenSSL::PKey::RSA.new File.read(key)
                        client_ctx.cert = OpenSSL::X509::Certificate.new File.read(crt)
                        client_ctx.ca_file = "#{CERT_PATH}/ca.crt"
                  Severity: Minor
                  Found in test/test_puma_server_ssl.rb and 1 other location - About 1 hr to fix
                  test/test_puma_server_ssl.rb on lines 441..449

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

                  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

                  Method curl_and_get_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def curl_and_get_response(url, method: :get, args: nil); require 'open3'
                      cmd = "curl -s -v --show-error #{args} -X #{method.to_s.upcase} -k #{url}"
                      begin
                        out, err, status = Open3.capture3(cmd)
                      rescue Errno::ENOENT
                  Severity: Minor
                  Found in test/test_integration_ssl.rb - About 55 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 run_wrk_parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def run_wrk_parse(cmd, log: false)
                        STDOUT.syswrite cmd.ljust 55
                  
                        if @dly_app
                          cmd.sub! ' -H ', " -H 'Dly: #{@dly_app.round 4}' -H "
                  Severity: Minor
                  Found in benchmarks/local/bench_base.rb - About 55 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 serialize_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def serialize_value(output, value)
                          case value
                          when Hash
                            output << '{'
                            value.each_with_index do |(k, v), index|
                  Severity: Minor
                  Found in lib/puma/json_serialization.rb - About 55 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 write has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def write(data)
                          return 0 if data.empty?
                  
                          data_size = data.bytesize
                          need = data_size
                  Severity: Minor
                  Found in lib/puma/minissl.rb - About 55 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 set_remote_address has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def set_remote_address(val=:socket)
                        case val
                        when :socket
                          @options[:remote_address] = val
                        when :localhost
                  Severity: Minor
                  Found in lib/puma/dsl.rb - About 55 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

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

                    def test_two_back_to_back
                      @client << @valid_request
                      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 69..80

                  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_count
                      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 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

                  Severity
                  Category
                  Status
                  Source
                  Language