test/test_thread_pool.rb

Summary

Maintainability
B
6 hrs
Test Coverage

File test_thread_pool.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "helper"

require "puma/thread_pool"

class TestThreadPool < Minitest::Test
Severity: Minor
Found in test/test_thread_pool.rb - About 2 hrs to fix

    Class TestThreadPool has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class TestThreadPool < Minitest::Test
    
      def teardown
        @pool.shutdown(1) if defined?(@pool)
      end
    Severity: Minor
    Found in test/test_thread_pool.rb - About 2 hrs to fix

      Method test_thread_name_linux has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def test_thread_name_linux
          skip 'Thread.name not supported' unless Thread.current.respond_to?(:name)
      
          task_dir = File.join('', 'proc', Process.pid.to_s, 'task')
          skip 'This test only works under Linux and MRI Ruby with appropriate permissions' if !(File.directory?(task_dir) && File.readable?(task_dir) && Puma::IS_MRI)
      Severity: Minor
      Found in test/test_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

      There are no issues that match your filters.

      Category
      Status