ReactiveX/RxRuby

View on GitHub

Showing 124 of 124 total issues

Method unsubscribe has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def unsubscribe
      subscription = nil
      @gate.synchronize do
        if @subscription
          unless @primary_unsubscribed
Severity: Minor
Found in lib/rx/subscriptions/ref_count_subscription.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 advance_to has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def advance_to(time)
      due_to_clock = time<=>clock
      raise 'Time is out of range' if due_to_clock < 0 

      return if due_to_clock == 0
Severity: Minor
Found in lib/rx/concurrency/virtual_time_scheduler.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 invoke_recursive has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def invoke_recursive(scheduler, pair)
      group = CompositeSubscription.new
      gate = Mutex.new
      state = pair[:state]
      action = pair[:action]
Severity: Minor
Found in lib/rx/concurrency/scheduler.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 run_trampoline has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def run_trampoline(queue)
        while item = queue.shift
          unless item.cancelled?
            wait = item.due_time - Scheduler.now.to_i
            sleep wait if wait > 0
Severity: Minor
Found in lib/rx/concurrency/current_thread_scheduler.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 single_or_default has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def single_or_default(default_value = nil, &block)
      return select(&block).single_or_default(default_value) if block_given?
      AnonymousObservable.new do |observer|
        seen_value = false
        value = nil
Severity: Minor
Found in lib/rx/operators/aggregates.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 invoke_recursive has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def invoke_recursive(scheduler, pair)
      group = CompositeSubscription.new
      gate = Mutex.new
      state = pair[:state]
      action = pair[:action]
Severity: Minor
Found in lib/rx/concurrency/scheduler.rb - About 1 hr to fix

    Method tap has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def tap(observer)
          raise ArgumentError.new 'Observer cannot be nil' unless observer
          AnonymousObservable.new do |obs|
            new_obs = Rx::Observer.configure do |o|
    
    
    Severity: Minor
    Found in lib/rx/operators/single.rb - About 1 hr to fix

      Method while has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def while(condition, source)
            enum = Enumerator.new {|y|
              while condition.call
                y << source
              end
      Severity: Minor
      Found in lib/rx/linq/observable/while.rb - About 1 hr to fix

        Method when has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def when(*plans)
              AnonymousObservable.new do |observer|
                active_plans = []
                external_subscriptions = {}
                out_observer = Observer.configure {|o|
        Severity: Minor
        Found in lib/rx/linq/observable/when.rb - About 1 hr to fix

          Method generate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def generate(initial_state, condition, iterate, result_selector, scheduler = CurrentThreadScheduler.instance)
                  AnonymousObservable.new do |observer|
                    state = initial_state
                    first = true
                    
          Severity: Minor
          Found in lib/rx/operators/creation.rb - About 1 hr to fix

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

                def take(count, scheduler = ImmediateScheduler.instance)
                  return Observable.empty(scheduler) if count == 0
            
                  AnonymousObservable.new do |observer|
            
            
            Severity: Minor
            Found in lib/rx/operators/standard_query_operators.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 skip_until has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def skip_until(other)
                  raise ArgumentError.new 'Other cannot be nil' unless other
            
                  AnonymousObservable.new do |observer|
                    source_subscription = SingleAssignmentSubscription.new
            Severity: Minor
            Found in lib/rx/operators/multiple.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 match has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def match
                  has_values = true
                  @join_observer_array.each {|v|
                    if v.queue.length == 0
                      has_values = false
            Severity: Minor
            Found in lib/rx/joins/active_plan.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 from has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def from(iterable, map_fn = nil, scheduler = CurrentThreadScheduler.instance)
                  it = iterable.to_enum
                  AnonymousObservable.new {|observer|
                    i = 0
                    scheduler.schedule_recursive lambda {|this|
            Severity: Minor
            Found in lib/rx/linq/observable/from.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 configure has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def configure(options = {})
                  options.each {|key,_|
                    unless [:created, :subscribed, :disposed].include? key
                      raise ArgumentError, "Should be specified whether :created, :subscribed or :disposed, but the #{key.inspect}"
                    end
            Severity: Minor
            Found in lib/rx/testing/test_scheduler.rb - About 1 hr to fix

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

                  def merge_all
                    AnonymousObservable.new do |observer|
                      gate = Monitor.new
                      stopped = false
                      m = SingleAssignmentSubscription.new
              Severity: Minor
              Found in lib/rx/operators/multiple.rb - About 1 hr to fix

                Method from has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def from(iterable, map_fn = nil, scheduler = CurrentThreadScheduler.instance)
                      it = iterable.to_enum
                      AnonymousObservable.new {|observer|
                        i = 0
                        scheduler.schedule_recursive lambda {|this|
                Severity: Minor
                Found in lib/rx/linq/observable/from.rb - About 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        AnonymousObservable.new do |observer|
                  
                          value = nil
                          seen_value = false
                  
                  
                  Severity: Major
                  Found in lib/rx/operators/aggregates.rb and 1 other location - About 1 hr to fix
                  lib/rx/operators/aggregates.rb on lines 17..39

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 48.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        AnonymousObservable.new do |observer|
                          value = nil
                          has_value = false
                  
                          new_obs = Observer.configure do |o|
                  Severity: Major
                  Found in lib/rx/operators/aggregates.rb and 1 other location - About 1 hr to fix
                  lib/rx/operators/aggregates.rb on lines 253..276

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 48.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Method concat_map_observer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def concat_map_observer(on_next, on_error, on_completed)
                        AnonymousObservable.new do |observer|
                          index = 0
                  
                          subscribe(
                  Severity: Minor
                  Found in lib/rx/linq/observable/concat_map_observer.rb - About 55 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