Showing 328 of 328 total issues

Method run has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run
      time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
      super
      # default values
      @duration ||= 10
Severity: Minor
Found in benchmarks/local/response_time_wrk.rb - About 1 hr to fix

    Method send_request has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def send_request
          uri = URI.parse @control_url
    
          # create server object by scheme
          server =
    Severity: Minor
    Found in benchmarks/local/puma_info.rb - About 1 hr to fix

      Method term_closes_listeners has 48 lines of code (exceeds 25 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

        Method server_gets has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def server_gets(match_obj, time_timeout, log: false)
            error_retries = 0
            line = ''
        
            sleep 0.05 unless @server.is_a?(IO) or Process.clock_gettime(Process::CLOCK_MONOTONIC) > time_timeout
        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 new_socket has a Cognitive Complexity of 15 (exceeds 5 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

        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 parse_query has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_query(qs, d = nil, &unescaper)
              unescaper ||= method(:unescape)
        
              params = {}
        
        
        Severity: Minor
        Found in lib/puma/util.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 redirect_io has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def redirect_io
              stdout = @options[:redirect_stdout]
              stderr = @options[:redirect_stderr]
              append = @options[:redirect_append]
        
        
        Severity: Minor
        Found in lib/puma/runner.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 shutdown_requests has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def shutdown_requests(s1_complete: true, s1_response: nil, post: false, s2_response: nil, **options)
            mutex = Mutex.new
            app_finished = ConditionVariable.new
            server_run(**options) { |env|
              path = env['REQUEST_PATH']
        Severity: Minor
        Found in test/test_puma_server.rb - About 1 hr to fix

          Method ci_test_rps has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def ci_test_rps
                host = ENV['HOST']
                port = ENV['PORT'].to_i
          
                str = 'a' * 65_500
          Severity: Minor
          Found in benchmarks/local/response_time_wrk.rb - About 1 hr to fix

            Method setup_options has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def setup_options
                  OptionParser.new do |o|
                    o.on "-T", "--stream-threads THREADS", OptionParser::DecimalInteger, "request_stream: loops/threads" do |arg|
                      @stream_threads = arg.to_i
                    end
            Severity: Minor
            Found in benchmarks/local/bench_base.rb - About 1 hr to fix

              Method read_response has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def read_response(connection, timeout = nil)
                  timeout ||= RESP_READ_TIMEOUT
                  content_length = nil
                  chunked = nil
                  response = +''
              Severity: Minor
              Found in test/helpers/integration.rb - About 1 hr to fix

                Method spawn_thread has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def spawn_thread
                      @spawned += 1
                
                      trigger_before_thread_start_hooks
                      th = Thread.new(@spawned) do |spawned|
                Severity: Minor
                Found in lib/puma/thread_pool.rb - About 1 hr to fix

                  Method normalize_env has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def normalize_env(env, client)
                        if host = env[HTTP_HOST]
                          # host can be a hostname, ipv4 or bracketed ipv6. Followed by an optional port.
                          if colon = host.rindex("]:") # IPV6 with port
                            env[SERVER_NAME] = host[0, colon+1]
                  Severity: Minor
                  Found in lib/puma/request.rb - About 1 hr to fix

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

                        def initialize(conf, launcher_args={})
                          @runner        = nil
                          @log_writer    = launcher_args[:log_writer] || LogWriter::DEFAULT
                          @events        = launcher_args[:events] || Events.new
                          @argv          = launcher_args[:argv] || []
                    Severity: Minor
                    Found in lib/puma/launcher.rb - About 1 hr to fix

                      Method start has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def start(launcher)
                      
                          hostname = ENV['DYNO']
                          return unless hostname
                      
                      
                      Severity: Minor
                      Found in examples/plugins/redis_stop_puma.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 run_summaries has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def run_summaries(summaries)
                            digits = [4 - Math.log10(@max_100_time).to_i, 3].min
                      
                            fmt_vals = +'%-6s %6d'
                            fmt_vals << (digits < 0 ? "  %6d" : "  %6.#{digits}f")*5
                      Severity: Minor
                      Found in benchmarks/local/response_time_wrk.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_thread_name_linux has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def test_thread_name_linux
                          skip 'Thread.name not supported' unless Thread.current.respond_to?(:name)
                      
                          task_dir = File.join('', 'proc', Process.pid.to_s, 'task')
                          skip 'This test only works under Linux and MRI Ruby with appropriate permissions' if !(File.directory?(task_dir) && File.readable?(task_dir) && Puma::IS_MRI)
                      Severity: Minor
                      Found in test/test_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 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
                      Severity: Minor
                      Found in lib/puma/client.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 read_nonblock has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def read_nonblock(size, *_)
                              # *_ is to deal with keyword args that were added
                              # at some point (and being used in the wild)
                              while true
                                output = engine_read_all
                      Severity: Minor
                      Found in lib/puma/minissl.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 set_host_port_to_config has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def set_host_port_to_config(host, port, config)
                            config.clear_binds! if host || port
                      
                            if host && (host[0,1] == '.' || host[0,1] == '/')
                              config.bind "unix://#{host}"
                      Severity: Minor
                      Found in lib/rack/handler/puma.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

                      Severity
                      Category
                      Status
                      Source
                      Language