Showing 327 of 327 total issues

Avoid deeply nested control flow statements.
Open

              @buffer = nil if @buffer.empty?
Severity: Major
Found in lib/puma/client.rb - About 45 mins to fix

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

        def start
          require_relative 'cli'
    
          run_args = []
    
    
    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 u = params['backlog']
                    backlog = Integer(u)
                  end
    Severity: Major
    Found in lib/puma/binder.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      @worker_write << "#{Puma::Const::PipeRequest::FORK}#{pid}:#{idx}\n" rescue nil
      Severity: Major
      Found in lib/puma/cluster/worker.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if md[1]
                        @peerip = md[1].split(" ")[0]
                      end
        Severity: Major
        Found in lib/puma/client.rb - About 45 mins to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def send_http_read_response(req = GET_11, host: nil, port: nil, path: nil, ctx: nil,
                  session: nil, len: nil, timeout: nil)
                skt = send_http req, host: host, port: port, path: path, ctx: ctx, session: session
                skt.read_response timeout: timeout, len: len
              end
          Severity: Minor
          Found in test/helpers/test_puma/puma_socket.rb and 1 other location - About 45 mins to fix
          test/helpers/test_puma/puma_socket.rb on lines 130..134

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 39.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def send_http_read_resp_body(req = GET_11, host: nil, port: nil, path: nil, ctx: nil,
                  session: nil, len: nil, timeout: nil)
                skt = send_http req, host: host, port: port, path: path, ctx: ctx, session: session
                skt.read_body timeout: timeout, len: len
              end
          Severity: Minor
          Found in test/helpers/test_puma/puma_socket.rb and 1 other location - About 45 mins to fix
          test/helpers/test_puma/puma_socket.rb on lines 168..172

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 39.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            def thread_run_pid(replies, delay, sleep_time, mutex, refused, unix: false)
          Severity: Minor
          Found in test/test_integration_cluster.rb - About 35 mins to fix

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

                def fast_write_response(socket, body, io_buffer, chunked, content_length)
            Severity: Minor
            Found in lib/puma/request.rb - About 35 mins to fix

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

                  def prepare_response(status, headers, res_body, requests, client)
              Severity: Minor
              Found in lib/puma/request.rb - About 35 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/binder.rb - About 35 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 teardown has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def teardown
                        @server.stop(true)
                        # Errno::EBADF raised on macOS
                        @ios.each do |io|
                          begin
                    Severity: Minor
                    Found in test/test_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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(argv, log_writer = LogWriter.stdio, events = Events.new)
                          @debug = false
                          @argv = argv.dup
                          @log_writer = log_writer
                          @events = events
                    Severity: Minor
                    Found in lib/puma/cli.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 timeout_workers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def timeout_workers
                          @workers.each do |w|
                            if !w.term? && w.ping_timeout <= Time.now
                              details = if w.booted?
                                          "(Worker #{w.index} failed to check in within #{@options[:worker_timeout]} seconds)"
                    Severity: Minor
                    Found in lib/puma/cluster.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 assert_file_contents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def assert_file_contents(path, include = FILE_STR)
                        retries = 0
                        retries_max = 50 # 5 seconds
                        File.open(path) do |file|
                          begin
                    Severity: Minor
                    Found in test/test_redirect_io.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def add(client)
                              if client.env['REQUEST_PATH'] == '/s2'
                                Thread.pass until @pool.instance_variable_get(:@shutdown)
                              end
                              super
                    Severity: Minor
                    Found in test/test_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 assert_ssl_client_error_match has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def assert_ssl_client_error_match(error, subject: nil, context: CTX, &blk)
                        port = 0
                    
                        app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
                    
                    
                    Severity: Minor
                    Found in test/test_puma_server_ssl.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 send_http_array has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def send_http_array(req = GET_11, len, dly: 0.000_1, max_retries: 5)
                          Array.new(len) {
                            retries = 0
                            begin
                              skt = send_http req
                    Severity: Minor
                    Found in test/helpers/test_puma/puma_socket.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 test_tls_v1_3 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def test_tls_v1_3
                        skip("TLSv1.3 protocol can not be set") unless OpenSSL::SSL::SSLContext.instance_methods(false).include?(:min_version=)
                    
                        start_server
                    
                    
                    Severity: Minor
                    Found in test/test_puma_server_ssl.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

                    Severity
                    Category
                    Status
                    Source
                    Language