Showing 222 of 222 total issues

File test_config.rb has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "helper"
require_relative "helpers/config_file"

require "puma/configuration"
require 'puma/events'
Severity: Minor
Found in test/test_config.rb - About 4 hrs to fix

    Method handle_servers has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_servers
          begin
            check = @check
            sockets = [check] + @binder.ios
            pool = @thread_pool
    Severity: Minor
    Found in lib/puma/server.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

    Method handle_request has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def handle_request(client, lines)
          env = client.env
          io = client.io
    
          return false if closed_socket?(io)
    Severity: Major
    Found in lib/puma/request.rb - About 4 hrs to fix

      File test_binder.rb has 342 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 "puma/binder"
      Severity: Minor
      Found in test/test_binder.rb - About 4 hrs to fix

        Method hot_restart_does_not_drop_connections has 105 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def hot_restart_does_not_drop_connections(num_threads: 1, total_requests: 500)
            skipped = true
            skip_on :jruby, suffix: <<-MSG
         - file descriptors are not preserved on exec on JRuby; connection reset errors are expected during restarts
            MSG
        Severity: Major
        Found in test/helpers/integration.rb - About 4 hrs to fix

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

              def setup_options
                @conf = Configuration.new do |user_config, file_config|
                  @parser = OptionParser.new do |o|
                    o.on "-b", "--bind URI", "URI to bind to (tcp://, unix://, ssl://)" do |arg|
                      user_config.bind arg
          Severity: Major
          Found in lib/puma/cli.rb - About 4 hrs to fix

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

            class TestConfigFile < TestConfigFileBase
              parallelize_me!
            
              def test_default_max_threads
                max_threads = 16
            Severity: Minor
            Found in test/test_config.rb - About 4 hrs to fix

              File test_cli.rb has 332 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 "puma/cli"
              Severity: Minor
              Found in test/test_cli.rb - About 4 hrs to fix

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

                    def run
                      @status = :run
                
                      output_header "cluster"
                
                
                Severity: Major
                Found in lib/puma/cluster.rb - About 3 hrs to fix

                  Method spawn_thread has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def spawn_thread
                        @spawned += 1
                  
                        th = Thread.new(@spawned) do |spawned|
                          Puma.set_thread_name 'threadpool %03i' % 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 parse has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def parse(binds, logger, log_msg = 'Listening')
                        binds.each do |str|
                          uri = URI.parse str
                          case uri.scheme
                          when "tcp"
                  Severity: Major
                  Found in lib/puma/binder.rb - About 3 hrs to fix

                    File binder.rb has 321 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require 'uri'
                    require 'socket'
                    
                    require 'puma/const'
                    require 'puma/util'
                    Severity: Minor
                    Found in lib/puma/binder.rb - About 3 hrs to fix

                      Class Server has 30 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                        class Server
                      
                          include Puma::Const
                          include Request
                          extend Forwardable
                      Severity: Minor
                      Found in lib/puma/server.rb - About 3 hrs to fix

                        Method run has 90 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

                          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

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

                              def graceful_shutdown
                                if @options[:shutdown_debug]
                                  threads = Thread.list
                                  total = threads.size
                          
                          
                          Severity: Minor
                          Found in lib/puma/server.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 send_request has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def send_request
                                uri = URI.parse @control_url
                          
                                # create server object by scheme
                                server =
                          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

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

                            def skip_on(*engs, suffix: '', bt: caller)
                              engs.each do |eng|
                                skip_msg = case eng
                                  when :darwin   then "Skipped on darwin#{suffix}"    if RUBY_PLATFORM[/darwin/]
                                  when :jruby    then "Skipped on JRuby#{suffix}"     if Puma.jruby?
                          Severity: Minor
                          Found in test/helper.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 initialize has 77 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

                            File dsl.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            require 'puma/const'
                            
                            module Puma
                              # The methods that are available for use inside the configuration file.
                              # These same methods are used in Puma cli and the rack handler
                            Severity: Minor
                            Found in lib/puma/dsl.rb - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language