Showing 220 of 220 total issues

File test_puma_server.rb has 850 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 81 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 run has a Cognitive Complexity of 62 (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 62 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 parse has a Cognitive Complexity of 54 (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 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 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_on :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 422 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 6 hrs to fix

          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

          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

          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

            Method process_client has a Cognitive Complexity of 35 (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

            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
              
                    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

              File test_integration_cluster.rb has 377 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 TestIntegrationCluster has 38 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 cluster.rb has 371 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 4 hrs to fix

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

                      class Launcher
                        KEYS_NOT_TO_PERSIST_IN_STATE = [
                           :logger, :lowlevel_error_handler,
                           :before_worker_shutdown, :before_worker_boot, :before_worker_fork,
                           :after_worker_boot, :before_fork, :on_restart
                    Severity: Minor
                    Found in lib/puma/launcher.rb - About 4 hrs to fix

                      File client.rb has 363 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      class IO
                        # We need to use this for a jruby work around on both 1.8 and 1.9.
                        # So this either creates the constant (on 1.8), or harmlessly
                        # reopens it (on 1.9).
                        module WaitReadable
                      Severity: Minor
                      Found in lib/puma/client.rb - About 4 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language