Showing 224 of 224 total issues

File test_puma_server.rb has 948 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "helper"
require "puma/events"
require "net/http"
require "nio"

Severity: Major
Found in test/test_puma_server.rb - About 2 days to fix

    Class TestPumaServer has 91 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class TestPumaServer < Minitest::Test
      parallelize_me! unless JRUBY_HEAD
    
      def setup
        @host = "127.0.0.1"
    Severity: Major
    Found in test/test_puma_server.rb - About 1 day to fix

      Method parse has a Cognitive Complexity of 86 (exceeds 5 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: Minor
      Found in lib/puma/binder.rb - About 1 day 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 has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
      Open

          def run
            @status = :run
      
            output_header "cluster"
      
      
      Severity: Minor
      Found in lib/puma/cluster.rb - About 1 day 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 DSL has 64 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class DSL
          include ConfigDefault
      
          # convenience method so logic can be used in CI
          # @see ssl_bind
      Severity: Major
      Found in lib/puma/dsl.rb - About 1 day to fix

        Method run has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
        Open

              def run
                title  = "puma: cluster worker #{index}: #{master}"
                title += " [#{@options[:tag]}]" if @options[:tag] && !@options[:tag].empty?
                $0 = title
        
        
        Severity: Minor
        Found in lib/puma/cluster/worker.rb - About 7 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_servers has a Cognitive Complexity of 46 (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 7 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 a Cognitive Complexity of 44 (exceeds 5 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: Minor
        Found in lib/puma/client.rb - About 6 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 hot_restart_does_not_drop_connections has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

          def hot_restart_does_not_drop_connections(num_threads: 1, total_requests: 500)
            skipped = true
            skip_if :jruby, suffix: <<-MSG
         - file descriptors are not preserved on exec on JRuby; connection reset errors are expected during restarts
            MSG
        Severity: Minor
        Found in test/helpers/integration.rb - About 6 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 server.rb has 407 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'stringio'
        
        require 'puma/thread_pool'
        require 'puma/const'
        require 'puma/events'
        Severity: Minor
        Found in lib/puma/server.rb - About 5 hrs to fix

          File cluster.rb has 396 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'puma/runner'
          require 'puma/util'
          require 'puma/plugin'
          require 'puma/cluster/worker_handle'
          require 'puma/cluster/worker'
          Severity: Minor
          Found in lib/puma/cluster.rb - About 5 hrs to fix

            Method process_client has a Cognitive Complexity of 36 (exceeds 5 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: Minor
            Found in lib/puma/server.rb - About 5 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 a Cognitive Complexity of 36 (exceeds 5 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: Minor
            Found in lib/puma/request.rb - About 5 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 context has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
            Open

                  def context
                    ctx = MiniSSL::Context.new
            
                    if defined?(JRUBY_VERSION)
                      unless params['keystore']
            Severity: Minor
            Found in lib/puma/minissl/context_builder.rb - About 5 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_integration_cluster.rb has 391 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require_relative "helper"
            require_relative "helpers/integration"
            
            class TestIntegrationCluster < TestIntegration
              parallelize_me! if ::Puma.mri?
            Severity: Minor
            Found in test/test_integration_cluster.rb - About 5 hrs to fix

              Class TestBinder has 40 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class TestBinder < TestBinderBase
                parallelize_me!
              
                def test_synthesize_binds_from_activated_fds_no_sockets
                  binds = ['tcp://0.0.0.0:3000']
              Severity: Minor
              Found in test/test_binder.rb - About 5 hrs to fix

                Class TestIntegrationCluster has 40 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class TestIntegrationCluster < TestIntegration
                  parallelize_me! if ::Puma.mri?
                
                  def workers ; 2 ; end
                
                
                Severity: Minor
                Found in test/test_integration_cluster.rb - About 5 hrs to fix

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

                  require 'puma/events'
                  require 'puma/detect'
                  require 'puma/cluster'
                  require 'puma/single'
                  require 'puma/const'
                  Severity: Minor
                  Found in lib/puma/launcher.rb - About 5 hrs to fix

                    Method handle_request has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def handle_request(client, lines)
                          env = client.env
                          io  = client.io   # io may be a MiniSSL::Socket
                    
                          return false if closed_socket?(io)
                    Severity: Minor
                    Found in lib/puma/request.rb - About 5 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_if has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def skip_if(*engs, suffix: '', bt: caller)
                        engs.each do |eng|
                          skip_msg = case eng
                            when :darwin      then "Skipped if darwin#{suffix}"      if Puma::IS_OSX
                            when :jruby       then "Skipped if JRuby#{suffix}"       if Puma::IS_JRUBY
                    Severity: Minor
                    Found in test/helper.rb - About 5 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

                    Severity
                    Category
                    Status
                    Source
                    Language