toy/in_threads

View on GitHub

Showing 4 of 4 total issues

Method run_in_threads_use_block_result has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run_in_threads_use_block_result(method, *args, &block)
    pool = Pool.new(thread_count)
    enum_a = QueueEnum.new
    enum_b = QueueEnum.new(thread_count - 1)
    results = SizedQueue.new(thread_count - 1)
Severity: Minor
Found in lib/in_threads.rb - About 1 hr to fix

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

      def run_in_threads_ignore_block_result(method, *args, &block)
        pool = Pool.new(thread_count)
        wait = SizedQueue.new(thread_count - 1)
        begin
          pool.catch do
    Severity: Minor
    Found in lib/in_threads.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(thread_count)
          @queue = Queue.new
          @mutex = Mutex.new
          @pool = Array.new(thread_count) do
            Thread.new do
    Severity: Minor
    Found in lib/in_threads.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 run_in_threads_use_block_result has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def run_in_threads_use_block_result(method, *args, &block)
        pool = Pool.new(thread_count)
        enum_a = QueueEnum.new
        enum_b = QueueEnum.new(thread_count - 1)
        results = SizedQueue.new(thread_count - 1)
    Severity: Minor
    Found in lib/in_threads.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

    Severity
    Category
    Status
    Source
    Language