Showing 222 of 222 total issues

Method decode_chunk has 73 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 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

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

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

        Method redirect_io has a Cognitive Complexity of 20 (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 2 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 TestCLI has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class TestCLI < Minitest::Test
          include SSLHelper if ::Puma::HAS_SSL
          include TmpPath
        
          def setup
        Severity: Minor
        Found in test/test_cli.rb - About 2 hrs to fix

          File request.rb has 276 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Puma
          
            # The methods here are included in Server, but are separated into this file.
            # All the methods here pertain to passing the request to the app, then
            # writing the response back to the client.
          Severity: Minor
          Found in lib/puma/request.rb - About 2 hrs to fix

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

              class Client
                # The object used for a request with no body. All requests with
                # no body share this one object since it has no state.
                EmptyBody = NullIO.new
            
            
            Severity: Minor
            Found in lib/puma/client.rb - About 2 hrs to fix

              Class Configuration has 23 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Configuration
                  include ConfigDefault
              
                  def initialize(user_options={}, default_options = {}, &block)
                    default_options = self.puma_default_options.merge(default_options)
              Severity: Minor
              Found in lib/puma/configuration.rb - About 2 hrs to fix

                File test_puma_server_ssl.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require_relative "helper"
                
                if ::Puma::HAS_SSL
                  require "puma/minissl"
                  require "puma/events"
                Severity: Minor
                Found in test/test_puma_server_ssl.rb - About 2 hrs to fix

                  Method shutdown_requests has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def shutdown_requests(s1_complete: true, s1_response: nil, post: false, s2_response: nil, **options)
                      @server = Puma::Server.new @app, @events, options
                      mutex = Mutex.new
                      app_finished = ConditionVariable.new
                      server_run app: ->(env) {
                  Severity: Minor
                  Found in test/test_puma_server.rb - About 2 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 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def normalize_env(env, client)
                        if host = env[HTTP_HOST]
                          if colon = host.index(":")
                            env[SERVER_NAME] = host[0, colon]
                            env[SERVER_PORT] = host[colon+1, host.bytesize]
                  Severity: Minor
                  Found in lib/puma/request.rb - About 2 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 start has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def start(launcher)
                      path = File.join("tmp", "restart.txt")
                  
                      orig = nil
                  
                  
                  Severity: Minor
                  Found in lib/puma/plugin/tmp_restart.rb - About 2 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 integration.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "puma/control_cli"
                  require "open3"
                  require_relative 'tmp_path'
                  
                  # Only single mode tests go here. Cluster and pumactl tests
                  Severity: Minor
                  Found in test/helpers/integration.rb - About 2 hrs to fix

                    Method handle_servers has 59 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 2 hrs to fix

                      Method process_client has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def process_client(client, buffer)
                            # Advertise this server into the thread
                            Thread.current[ThreadLocalKey] = self
                      
                            clean_thread_locals = @options[:clean_thread_locals]
                      Severity: Major
                      Found in lib/puma/server.rb - About 2 hrs to fix

                        Class Events has 22 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                          class Events
                            class DefaultFormatter
                              def call(str)
                                str
                              end
                        Severity: Minor
                        Found in lib/puma/events.rb - About 2 hrs to fix

                          Method setup_body has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def setup_body
                                @body_read_start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
                          
                                if @env[HTTP_EXPECT] == CONTINUE
                                  # TODO allow a hook here to check the headers before
                          Severity: Minor
                          Found in lib/puma/client.rb - About 2 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 send_signal has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def send_signal
                                unless @pid
                                  raise 'Neither pid nor control url available'
                                end
                          
                          
                          Severity: Minor
                          Found in lib/puma/control_cli.rb - About 2 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 wait_workers has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def wait_workers
                                @workers.reject! do |w|
                                  next false if w.pid.nil?
                                  begin
                                    if Process.wait(w.pid, Process::WNOHANG)
                          Severity: Minor
                          Found in lib/puma/cluster.rb - About 2 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 str_headers has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def str_headers(env, status, headers, res_info, lines)
                                line_ending = LINE_END
                                colon = COLON
                          
                                http_11 = env[HTTP_VERSION] == HTTP_11
                          Severity: Major
                          Found in lib/puma/request.rb - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language