Showing 325 of 325 total issues

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

require_relative "helper"
require "puma/events"
require "puma/server"
require "net/http"
require "nio"
Severity: Major
Found in test/test_puma_server.rb - About 3 days to fix

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

    class TestPumaServer < Minitest::Test
      parallelize_me!
    
      STATUS_CODES = ::Puma::HTTP_STATUS_CODES
    
    
    Severity: Major
    Found in test/test_puma_server.rb - About 2 days to fix

      Method parse has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(binds, log_writer = nil, log_msg = 'Listening')
            log_writer ||= @log_writer
            binds.each do |str|
              uri = URI.parse str
              case uri.scheme
      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 89 (exceeds 5 allowed). Consider refactoring.
      Open

          def run
            @status = :run
      
            @idle_workers = {}
      
      
      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 77 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class DSL
          ON_WORKER_KEY = [String, Symbol].freeze
      
          # 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 handle_servers has a Cognitive Complexity of 68 (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 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 fast_write_response has a Cognitive Complexity of 67 (exceeds 5 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: Minor
        Found in lib/puma/request.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 ssl_bind_str has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.ssl_bind_str(host, port, opts)
              verify = opts.fetch(:verify_mode, 'none').to_s
        
              tls_str =
                if opts[:no_tlsv1_1]  then '&no_tlsv1_1=true'
        Severity: Minor
        Found in lib/puma/dsl.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 decode_chunk has a Cognitive Complexity of 64 (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 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

        File test_integration_cluster.rb has 565 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require_relative "helper"
        require_relative "helpers/integration"
        
        require "puma/configuration"
        
        
        Severity: Major
        Found in test/test_integration_cluster.rb - About 1 day to fix

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

          require_relative "helper"
          require_relative "helpers/config_file"
          
          require "puma/configuration"
          require 'puma/log_writer'
          Severity: Major
          Found in test/test_config.rb - About 1 day to fix

            Method read_response_array has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
            Open

                def read_response_array(skts, resp_count: nil, body_only: nil)
                  results = Array.new skts.length
                  Thread.new do
                    until skts.compact.empty?
                      skts.each_with_index do |skt, idx|
            Severity: Minor
            Found in test/helpers/test_puma/puma_socket.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 hot_restart_does_not_drop_connections has a Cognitive Complexity of 53 (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 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 context has a Cognitive Complexity of 53 (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 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 TestIntegrationCluster has 54 methods (exceeds 20 allowed). Consider refactoring.
            Open

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

              File client.rb has 471 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 7 hrs to fix

                Method run has a Cognitive Complexity of 45 (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 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

                Class TestConfigFile has 49 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 6 hrs to fix

                  File server.rb has 450 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

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

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

                    require_relative "helper"
                    
                    if ::Puma::HAS_SSL
                      require "puma/minissl"
                      require_relative "helpers/test_puma/puma_socket"
                    Severity: Minor
                    Found in test/test_puma_server_ssl.rb - About 6 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language