ruby-concurrency/concurrent-ruby

View on GitHub
lib/concurrent-ruby/concurrent/promise.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Class Promise has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Promise < IVar

    # Initialize a new Promise with the provided options.
    #
    # @!macro executor_and_deref_options
Severity: Minor
Found in lib/concurrent-ruby/concurrent/promise.rb - About 3 hrs to fix

    Method then has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def then(*args, &block)
          if args.last.is_a?(::Hash)
            executor = args.pop[:executor]
            rescuer = args.first
          else
    Severity: Minor
    Found in lib/concurrent-ruby/concurrent/promise.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 aggregate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.aggregate(method, *promises)
          composite = Promise.new do
            completed = promises.collect do |promise|
              promise.execute if promise.unscheduled?
              promise.wait
    Severity: Minor
    Found in lib/concurrent-ruby/concurrent/promise.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 zip has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.zip(*promises)
          opts = promises.last.is_a?(::Hash) ? promises.pop.dup : {}
          opts[:executor] ||= ImmediateExecutor.new
          zero = if !opts.key?(:execute) || opts.delete(:execute)
            fulfill([], opts)
    Severity: Minor
    Found in lib/concurrent-ruby/concurrent/promise.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 set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def set(value = NULL, &block)
          raise PromiseExecutionError.new('supported only on root promise') unless root?
          check_for_block_or_value!(block_given?, value)
          synchronize do
            if @state != :unscheduled
    Severity: Minor
    Found in lib/concurrent-ruby/concurrent/promise.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