ruby-concurrency/concurrent-ruby

View on GitHub
lib/concurrent-ruby-edge/concurrent/edge/channel.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Channel has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Channel < Concurrent::Synchronization::Object

      # TODO (pitr-ch 06-Jan-2019): rename to Conduit?, to be able to place it into Concurrent namespace?
      # TODO (pitr-ch 14-Jan-2019): better documentation, do few examples from go
      # TODO (pitr-ch 12-Dec-2018): implement channel closing,
Severity: Minor
Found in lib/concurrent-ruby-edge/concurrent/edge/channel.rb - About 4 hrs to fix

    Method ns_pop_op has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

          def ns_pop_op(matcher, probe, include_channel)
            message = ns_shift_message matcher
    
            # got message from buffer
            if message != NOTHING
    Severity: Minor
    Found in lib/concurrent-ruby-edge/concurrent/edge/channel.rb - About 4 hrs 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_consume_pending_push has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def ns_consume_pending_push(matcher, remove = true)
            i = 0
            while true
              message, pushed = @PendingPush[i, 2]
              return NOTHING unless pushed
    Severity: Minor
    Found in lib/concurrent-ruby-edge/concurrent/edge/channel.rb - About 2 hrs 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_try_push has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def ns_try_push(message)
            i = 0
            while true
              probe, include_channel, matcher = @Probes[i, 3]
              break unless probe
    Severity: Minor
    Found in lib/concurrent-ruby-edge/concurrent/edge/channel.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 ns_pop_op has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def ns_pop_op(matcher, probe, include_channel)
            message = ns_shift_message matcher
    
            # got message from buffer
            if message != NOTHING
    Severity: Minor
    Found in lib/concurrent-ruby-edge/concurrent/edge/channel.rb - About 1 hr to fix

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

            def pop_matching(matcher, timeout = nil, timeout_value = nil)
              # TODO (pitr-ch 27-Jan-2019): should it try to match pending pushes if it fails to match in the buffer? Maybe only if the size is zero. It could be surprising if it's used as a throttle it might be expected that it will not pop if buffer is full of messages which di not match, it might it expected it will block until the message is added to the buffer
              # that it returns even if the buffer is full. User might expect that it has to be in the buffer first.
              probe = @Mutex.synchronize do
                message = ns_shift_message matcher
      Severity: Minor
      Found in lib/concurrent-ruby-edge/concurrent/edge/channel.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 push has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def push(message, timeout = nil)
              pushed_op = @Mutex.synchronize do
                return timeout ? true : self if ns_try_push(message)
      
                pushed = Promises.resolvable_future
      Severity: Minor
      Found in lib/concurrent-ruby-edge/concurrent/edge/channel.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_shift_message has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def ns_shift_message(matcher, remove = true)
              i = 0
              while true
                message = @Messages.fetch(i, NOTHING)
                return NOTHING if message == NOTHING
      Severity: Minor
      Found in lib/concurrent-ruby-edge/concurrent/edge/channel.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

      There are no issues that match your filters.

      Category
      Status