Showing 327 of 327 total issues

Method check_workers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def check_workers
      return if @next_check >= Time.now

      @next_check = Time.now + @options[:worker_check_interval]

Severity: Minor
Found in lib/puma/cluster.rb - About 45 mins 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 teardown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def teardown
    return if skipped?
    @server.stop(true)
    assert_empty @log_writer.stdout.string
    assert_empty @log_writer.stderr.string
Severity: Minor
Found in test/test_puma_server_hijack.rb - About 45 mins 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 partial_hijack_closes_body has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def partial_hijack_closes_body(hdrs, body)
    server_run do
      if @available
        @available = false
        [200, hdrs, body]
Severity: Minor
Found in test/test_puma_server_hijack.rb - About 45 mins 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

Avoid deeply nested control flow statements.
Open

              if u = params['mode']
                mode = Integer('0'+u)
              end
Severity: Major
Found in lib/puma/binder.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

              if empty_body
                io_buffer << CLOSE_CHUNKED
                fast_write_str socket, io_buffer.read_and_reset
              else
                fast_write_str socket, CLOSE_CHUNKED
    Severity: Major
    Found in lib/puma/request.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    if u = params['umask']
                      # Use Integer() to respect the 0 prefix as octal
                      umask = Integer(u)
                    end
      Severity: Major
      Found in lib/puma/binder.rb - About 45 mins to fix

        Method synthesize_binds_from_activated_fs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def synthesize_binds_from_activated_fs(binds, only_matching)
              return binds unless activated_sockets.any?
        
              activated_binds = []
        
        
        Severity: Minor
        Found in lib/puma/binder.rb - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                    next if (byte_size = part.bytesize).zero?
        Severity: Major
        Found in lib/puma/request.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if io_buffer.length > IO_BUFFER_LEN_MAX
                        fast_write_str socket, io_buffer.read_and_reset
                      end
          Severity: Major
          Found in lib/puma/request.rb - About 45 mins to fix

            Method read_chunked_body has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def read_chunked_body
                  while true
                    begin
                      chunk = @io.read_nonblock(4096, @read_buffer)
                    rescue IO::WaitReadable
            Severity: Minor
            Found in lib/puma/client.rb - About 45 mins 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 closed_socket? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def closed_socket?(socket)
                    skt = socket.to_io
                    return false unless skt.kind_of?(TCPSocket) && @precheck_closing
            
                    begin
            Severity: Minor
            Found in lib/puma/server.rb - About 45 mins 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 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def run
                  return start if @command == 'start'
                  prepare_configuration
            
                  if Puma.windows? || @control_url && !NO_REQ_COMMANDS.include?(@command)
            Severity: Minor
            Found in lib/puma/control_cli.rb - About 45 mins 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

            Avoid deeply nested control flow statements.
            Open

                        if io_buffer.length > IO_BUFFER_LEN_MAX
                          fast_write_str socket, io_buffer.read_and_reset
                        end
            Severity: Major
            Found in lib/puma/request.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          next if part.bytesize.zero?
              Severity: Major
              Found in lib/puma/request.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            next if part.nil? || (byte_size = part.bytesize).zero?
                Severity: Major
                Found in lib/puma/request.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                    @worker_write << "#{PipeRequest::IDLE}#{Process.pid}\n" rescue nil
                  Severity: Major
                  Found in lib/puma/server.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  start_of_rest = if rest.start_with?(CHUNK_VALID_ENDING)
                                    CHUNK_VALID_ENDING_SIZE
                                  else # we have started a trailer section, which we do not support. skip it!
                                    rest.index(CHUNK_VALID_ENDING*2) + CHUNK_VALID_ENDING_SIZE*2
                                  end
                    Severity: Major
                    Found in lib/puma/client.rb - About 45 mins to fix

                      Method wait_until_not_full has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def wait_until_not_full
                            with_mutex do
                              while true
                                return if @shutdown
                      
                      
                      Severity: Minor
                      Found in lib/puma/thread_pool.rb - About 45 mins 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

                      Avoid deeply nested control flow statements.
                      Open

                                  next if part.bytesize.zero?
                      Severity: Major
                      Found in lib/puma/request.rb - About 45 mins to fix

                        Method create_activated_fds has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def create_activated_fds(env_hash)
                              @log_writer.debug "ENV['LISTEN_FDS'] #{ENV['LISTEN_FDS'].inspect}  env_hash['LISTEN_PID'] #{env_hash['LISTEN_PID'].inspect}"
                              return [] unless env_hash['LISTEN_FDS'] && env_hash['LISTEN_PID'].to_i == $$
                              env_hash['LISTEN_FDS'].to_i.times do |index|
                                sock = TCPServer.for_fd(socket_activation_fd(index))
                        Severity: Minor
                        Found in lib/puma/binder.rb - About 45 mins 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