Showing 270 of 327 total issues

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

        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

        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

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

                          def check_workers
                            return if @next_check >= Time.now
                      
                            @next_check = Time.now + @options[:worker_check_interval]
                      
                      
                      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

                      Severity
                      Category
                      Status
                      Source
                      Language