lib/puma/server.rb

Summary

Maintainability
F
5 days
Test Coverage

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

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

    Method process_client has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_client(client)
          # Advertise this server into the thread
          Thread.current[THREAD_LOCAL_KEY] = self
    
          clean_thread_locals = options[:clean_thread_locals]
    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

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

      class Server
        include Puma::Const
        include Request
    
        attr_reader :options
    Severity: Minor
    Found in lib/puma/server.rb - About 4 hrs to fix

      Method handle_servers has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def handle_servers
            begin
              check = @check
              sockets = [check] + @binder.ios
              pool = @thread_pool
      Severity: Major
      Found in lib/puma/server.rb - About 3 hrs to fix

        Method process_client has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def process_client(client)
              # Advertise this server into the thread
              Thread.current[THREAD_LOCAL_KEY] = self
        
              clean_thread_locals = options[:clean_thread_locals]
        Severity: Major
        Found in lib/puma/server.rb - About 2 hrs to fix

          Method initialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(app, events = nil, options = {})
                @app = app
                @events = events || Events.new
          
                @check, @notify = nil
          Severity: Minor
          Found in lib/puma/server.rb - About 1 hr to fix

            Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(app, events = nil, options = {})
                  @app = app
                  @events = events || Events.new
            
                  @check, @notify = nil
            Severity: Minor
            Found in lib/puma/server.rb - About 1 hr 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 lowlevel_error has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def lowlevel_error(e, env, status=500)
                  if handler = options[:lowlevel_error_handler]
                    if handler.arity == 1
                      return handler.call(e)
                    elsif handler.arity == 2
            Severity: Minor
            Found in lib/puma/server.rb - About 1 hr 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

            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

              Method add_ssl_listener has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def add_ssl_listener(host, port, ctx, optimize_for_latency = true,
                                       backlog = 1024)
              Severity: Minor
              Found in lib/puma/server.rb - About 35 mins to fix

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

                    def run(background=true, thread_name: 'srv')
                      BasicSocket.do_not_reverse_lookup = true
                
                      @events.fire :state, :booting
                
                
                Severity: Minor
                Found in lib/puma/server.rb - About 35 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 reactor_wakeup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def reactor_wakeup(client)
                      shutdown = !@queue_requests
                      if client.try_to_finish || (shutdown && !client.can_close?)
                        @thread_pool << client
                      elsif shutdown || client.timeout == 0
                Severity: Minor
                Found in lib/puma/server.rb - About 35 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 graceful_shutdown has a Cognitive Complexity of 6 (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 25 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

                There are no issues that match your filters.

                Category
                Status