Showing 327 of 327 total issues

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

    def initialize(name, options = {}, &block)
      @not_empty = ConditionVariable.new
      @not_full = ConditionVariable.new
      @mutex = Mutex.new

Severity: Minor
Found in lib/puma/thread_pool.rb - About 1 hr to fix

    Method test_control_clustered has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def test_control_clustered
        skip_unless :fork
        skip_unless :unix
        url = "unix://#{@tmp_path}"
    
    
    Severity: Minor
    Found in test/test_cli.rb - About 1 hr to fix

      Method test_chunked_keep_alive_two_back_to_back has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def test_chunked_keep_alive_two_back_to_back
          body = nil
          content_length = nil
          server_run { |env|
            body = env['rack.input'].read
      Severity: Minor
      Found in test/test_puma_server.rb - About 1 hr to fix

        Method initialize has 30 lines of code (exceeds 25 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 1 hr to fix

          Method serialize_value has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def serialize_value(output, value)
                  case value
                  when Hash
                    output << '{'
                    value.each_with_index do |(k, v), index|
          Severity: Minor
          Found in lib/puma/json_serialization.rb - About 1 hr to fix

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

                def test_user_port_wins_over_config
                  user_port = 5001
                  file_port = 6001
            
                  Dir.mktmpdir do |d|
            Severity: Major
            Found in test/test_rack_handler.rb and 2 other locations - About 1 hr to fix
            test/test_rack_handler.rb on lines 92..105
            test/test_rack_handler.rb on lines 144..157

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

            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 3 locations. Consider refactoring.
            Open

                def test_port_wins_over_config
                  user_port = 5001
                  file_port = 6001
            
                  Dir.mktmpdir do |d|
            Severity: Major
            Found in test/test_rack_handler.rb and 2 other locations - About 1 hr to fix
            test/test_rack_handler.rb on lines 144..157
            test/test_rack_handler.rb on lines 248..261

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

            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 3 locations. Consider refactoring.
            Open

                def test_config_file_wins_over_port
                  user_port = 5001
                  file_port = 6001
            
                  Dir.mktmpdir do |d|
            Severity: Major
            Found in test/test_rack_handler.rb and 2 other locations - About 1 hr to fix
            test/test_rack_handler.rb on lines 92..105
            test/test_rack_handler.rb on lines 248..261

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

            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 issue_cert has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def issue_cert(dn, key, serial, not_before, not_after, extensions, issuer, issuer_key, digest)
            Severity: Major
            Found in examples/puma/client-certs/generate_client_test.rb - About 1 hr to fix

              Method test_horrible_queries has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def test_horrible_queries
                  parser = Puma::HttpParser.new
              
                  # then that large header names are caught
                  10.times do |c|
              Severity: Minor
              Found in test/test_http11.rb - About 1 hr to fix

                Method new_socket has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def new_socket(host: nil, port: nil, path: nil, ctx: nil, session: nil)
                      port  ||= @bind_port
                      path  ||= @bind_path
                      ip ||= (host || HOST.ip).gsub RE_HOST_TO_IP, ''  # in case a URI style IPv6 is passed
                
                
                Severity: Minor
                Found in test/helpers/test_puma/puma_socket.rb - About 1 hr to fix

                  Method test_worker_index_is_with_in_options_limit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def test_worker_index_is_with_in_options_limit
                      skip_unless_signal_exist? :TERM
                  
                      cli_server "-C test/config/t3_conf.rb test/rackup/hello.ru"
                  
                  
                  Severity: Minor
                  Found in test/test_integration_cluster.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 term_closes_listeners has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def term_closes_listeners(unix: false)
                      skip_unless_signal_exist? :TERM
                  
                      cli_server "-w #{workers} -t 0:6 -q test/rackup/sleep_step.ru", unix: unix
                      threads = []
                  Severity: Minor
                  Found in test/test_integration_cluster.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 fast_write has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def fast_write(io, str)
                      n = 0
                      while true
                        begin
                          n = io.syswrite str
                  Severity: Minor
                  Found in test/helpers/integration.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 handler_opts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def handler_opts(options)
                        begin
                          info = []
                          server = Rack::Handler.get(options[:server]) || Rack::Handler.default(options)
                          if server&.respond_to?(:valid_options)
                  Severity: Minor
                  Found in lib/puma/rack/builder.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 cli_server has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def cli_server(argv,  # rubocop:disable Metrics/ParameterLists
                        unix: false,      # uses a UNIXSocket for the server listener when true
                        config: nil,      # string to use for config file
                        no_bind: nil,     # bind is defined by args passed or config file
                        merge_err: false, # merge STDERR into STDOUT
                  Severity: Minor
                  Found in test/helpers/integration.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 test_closed_listener has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def test_closed_listener
                      skip_unless_signal_exist? :TERM
                  
                      cli_server "test/rackup/close_listeners.ru", merge_err: true
                      connection = fast_connect
                  Severity: Minor
                  Found in test/test_integration_single.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 load has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def load(path)
                        File.read(path).lines.each do |line|
                          next if line.start_with? '#'
                          k,v = line.split ':', 2
                          next unless v && ALLOWED_FIELDS.include?(k)
                  Severity: Minor
                  Found in lib/puma/state_file.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 wait_for_less_busy_worker has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def wait_for_less_busy_worker(delay_s)
                        return unless delay_s && delay_s > 0
                  
                        # Ruby MRI does GVL, this can result
                        # in processing contention when multiple threads
                  Severity: Minor
                  Found in lib/puma/thread_pool.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

                  Severity
                  Category
                  Status
                  Source
                  Language