Showing 270 of 327 total issues

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
Severity: Minor
Found in test/test_puma_server.rb - About 1 hr to fix

    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
    Severity: Minor
    Found in lib/puma/cli.rb - About 1 hr to fix

      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|
      Severity: Minor
      Found in lib/puma/json_serialization.rb - About 1 hr to fix

        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)
        Severity: Major
        Found in examples/puma/client-certs/generate_client_test.rb - About 1 hr to fix

          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|
          Severity: Minor
          Found in test/test_http11.rb - About 1 hr to fix

            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
            
            
            Severity: Minor
            Found in test/helpers/test_puma/puma_socket.rb - About 1 hr to fix

              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"
              
              
              Severity: Minor
              Found in test/test_integration_cluster.rb - About 1 hr 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 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 = []
              Severity: Minor
              Found in test/test_integration_cluster.rb - About 1 hr 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 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
              Severity: Minor
              Found in test/helpers/integration.rb - About 1 hr 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 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)
              Severity: Minor
              Found in lib/puma/rack/builder.rb - About 1 hr 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 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
              Severity: Minor
              Found in test/helpers/integration.rb - About 1 hr 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 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
              Severity: Minor
              Found in test/test_integration_single.rb - About 1 hr 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 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)
              Severity: Minor
              Found in lib/puma/state_file.rb - About 1 hr 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 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
              Severity: Minor
              Found in lib/puma/thread_pool.rb - About 1 hr 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 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
              Severity: Minor
              Found in lib/puma/server.rb - About 1 hr 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 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
                        Severity
                        Category
                        Status
                        Source
                        Language