Showing 328 of 328 total issues

Class Launcher has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Launcher
    autoload :BundlePruner, 'puma/launcher/bundle_pruner'

    # Returns an instance of Launcher
    #
Severity: Minor
Found in lib/puma/launcher.rb - About 4 hrs to fix

    Method send_request has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def send_request
          uri = URI.parse @control_url
    
          host = uri.host
    
    
    Severity: Minor
    Found in lib/puma/control_cli.rb - About 4 hrs 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

    Class Cluster has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Cluster < Runner
        def initialize(launcher)
          super(launcher)
    
          @phase = 0
    Severity: Minor
    Found in lib/puma/cluster.rb - About 4 hrs to fix

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

            def run
              title  = "puma: cluster worker #{index}: #{master}"
              title += " [#{@options[:tag]}]" if @options[:tag] && !@options[:tag].empty?
              $0 = title
      
      
      Severity: Major
      Found in lib/puma/cluster/worker.rb - About 3 hrs to fix

        File launcher.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require_relative 'log_writer'
        require_relative 'events'
        require_relative 'detect'
        require_relative 'cluster'
        require_relative 'single'
        Severity: Minor
        Found in lib/puma/launcher.rb - About 3 hrs to fix

          Method run has a Cognitive Complexity of 27 (exceeds 5 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 3 hrs 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 normalize_env has a Cognitive Complexity of 27 (exceeds 5 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 3 hrs 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 spawn_thread has a Cognitive Complexity of 26 (exceeds 5 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 3 hrs 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 decode_chunk has 92 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def decode_chunk(chunk)
                if @partial_part_left > 0
                  if @partial_part_left <= chunk.size
                    if @partial_part_left > 2
                      write_chunk(chunk[0..(@partial_part_left-3)]) # skip the \r\n
          Severity: Major
          Found in lib/puma/client.rb - About 3 hrs to fix

            Method wait_workers has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                def wait_workers
                  # Reap all children, known workers or otherwise.
                  # If puma has PID 1, as it's common in containerized environments,
                  # then it's responsible for reaping orphaned processes, so we must reap
                  # all our dead children, regardless of whether they are workers we spawned
            Severity: Minor
            Found in lib/puma/cluster.rb - About 3 hrs 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

            File minissl.rb has 311 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            begin
              require 'io/wait' unless Puma::HAS_NATIVE_IO_WAIT
            rescue LoadError
            end
            
            
            Severity: Minor
            Found in lib/puma/minissl.rb - About 3 hrs to fix

              Class Client has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Client # :nodoc:
              
                  # this tests all values but the last, which must be chunked
                  ALLOWED_TRANSFER_ENCODING = %w[compress deflate gzip].freeze
              
              
              Severity: Minor
              Found in lib/puma/client.rb - About 3 hrs to fix

                Method handle_servers has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def handle_servers
                      begin
                        check = @check
                        sockets = [check] + @binder.ios
                        pool = @thread_pool
                Severity: Major
                Found in lib/puma/server.rb - About 3 hrs to fix

                  Method prepare_response has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def prepare_response(status, headers, res_body, requests, client)
                        env = client.env
                        socket = client.io
                        io_buffer = client.io_buffer
                  
                  
                  Severity: Major
                  Found in lib/puma/request.rb - About 3 hrs to fix

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

                        def initialize(argv, stdout=STDOUT, stderr=STDERR)
                          @state = nil
                          @quiet = false
                          @pidfile = nil
                          @pid = nil
                    Severity: Major
                    Found in lib/puma/control_cli.rb - About 3 hrs to fix

                      Method initialize has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def initialize(argv, stdout=STDOUT, stderr=STDERR)
                            @state = nil
                            @quiet = false
                            @pidfile = nil
                            @pid = nil
                      Severity: Minor
                      Found in lib/puma/control_cli.rb - About 3 hrs 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

                      File test_cli.rb has 293 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require_relative "helper"
                      require_relative "helpers/ssl" if ::Puma::HAS_SSL
                      require_relative "helpers/tmp_path"
                      require_relative "helpers/test_puma/puma_socket"
                      
                      
                      Severity: Minor
                      Found in test/test_cli.rb - About 3 hrs to fix

                        Method setup_body has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def setup_body
                              @body_read_start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
                        
                              if @env[HTTP_EXPECT] == CONTINUE
                                # TODO allow a hook here to check the headers before
                        Severity: Major
                        Found in lib/puma/client.rb - About 2 hrs to fix

                          Method fast_write_response has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def fast_write_response(socket, body, io_buffer, chunked, content_length)
                                if body.is_a?(::File) && body.respond_to?(:read)
                                  if chunked  # would this ever happen?
                                    while chunk = body.read(BODY_LEN_MAX)
                                      io_buffer.append chunk.bytesize.to_s(16), LINE_END, chunk, LINE_END
                          Severity: Major
                          Found in lib/puma/request.rb - About 2 hrs to fix

                            Method parse! has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def parse!(args)
                                  options = {}
                                  opt_parser = OptionParser.new("", 24, '  ') do |opts|
                                    opts.banner = "Usage: rackup [ruby options] [rack options] [rackup config]"
                            
                            
                            Severity: Major
                            Found in lib/puma/rack/builder.rb - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language