ruby-concurrency/concurrent-ruby

View on GitHub
lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class RubyThreadPoolExecutor has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class RubyThreadPoolExecutor < RubyExecutorService

    # @!macro thread_pool_executor_constant_default_max_pool_size
    DEFAULT_MAX_POOL_SIZE      = 2_147_483_647 # java.lang.Integer::MAX_VALUE

Severity: Minor
Found in lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb - About 3 hrs to fix

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

        def ns_initialize(opts)
          @min_length      = opts.fetch(:min_threads, DEFAULT_MIN_POOL_SIZE).to_i
          @max_length      = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
          @idletime        = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
          @max_queue       = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
    Severity: Minor
    Found in lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.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 ns_assign_worker has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def ns_assign_worker(*args, &task)
          # keep growing if the pool is not at the minimum yet
          worker, _ = (@ready.pop if @pool.size >= @min_length) || ns_add_busy_worker
          if worker
            worker << [task, args]
    Severity: Minor
    Found in lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.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 ns_ready_worker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def ns_ready_worker(worker, last_message, success = true)
          task_and_args = @queue.shift
          if task_and_args
            worker << task_and_args
          else
    Severity: Minor
    Found in lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.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

    Method ns_prune_pool has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def ns_prune_pool
          now = Concurrent.monotonic_time
          stopped_workers = 0
          while !@ready.empty? && (@pool.size - stopped_workers > @min_length)
            worker, last_message = @ready.first
    Severity: Minor
    Found in lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.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