ReactiveX/RxRuby

View on GitHub

Showing 124 of 124 total issues

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

    def rescue_error(other = nil, &action)
      return Observable.rescue_error(other) if other && !block_given?
      raise ArgumentError.new 'Invalid arguments' if other.nil? && !block_given?

      AnonymousObservable.new do |observer|
Severity: Minor
Found in lib/rx/operators/multiple.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

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

    def select_with_index(&block)
      AnonymousObservable.new do |observer|
        i = 0

        new_observer = Observer.configure do |o|
Severity: Minor
Found in lib/rx/operators/standard_query_operators.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

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

    def reduce(*args, &block)
      # Argument parsing to support:
      # 1. (seed, Symbol) || (seed, &block)
      # 2. (Symbol) || (&block)
      if (args.length == 2 && args[1].is_a?(Symbol)) || (args.length == 1 && block_given?)
Severity: Minor
Found in lib/rx/operators/aggregates.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

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

subscription = source.subscribe(
    lambda {|child|
        child.to_a.subscribe(
            lambda {|x|
                puts 'Child Next: ' + x.to_s
Severity: Minor
Found in examples/window_with_time.rb and 1 other location - About 45 mins to fix
examples/window_with_time.rb on lines 46..65

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 41.

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

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

subscription = source.subscribe(
    lambda {|child|

        child.to_a.subscribe(
            lambda {|x|
Severity: Minor
Found in examples/window_with_time.rb and 1 other location - About 45 mins to fix
examples/window_with_time.rb on lines 8..26

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 41.

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 zip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def zip(*args, &result_selector)
        AnonymousObservable.new do |observer|
          result_selector ||= lambda {|*inner_args| inner_args }
          n = args.length

Severity: Minor
Found in lib/rx/operators/multiple.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 _subscribe has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _subscribe(observer)

      auto_detach_observer = AutoDetachObserver.new observer

      if CurrentThreadScheduler.schedule_required?
Severity: Minor
Found in lib/rx/core/observable.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(source, on_error)
      super Observer.configure {|o|
        o.on_next {|notification|
          if !@is_disposed
            if notification.on_error?
Severity: Minor
Found in lib/rx/joins/join_observer.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 debounce has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def debounce(due_time, scheduler = DefaultScheduler.instance)
      AnonymousObservable.new do |observer|
        cancelable = SerialSubscription.new
        hasvalue = false
        value = nil
Severity: Minor
Found in lib/rx/linq/observable/debounce.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 while has a Cognitive Complexity of 8 (exceeds 5 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 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 start has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def start
      unless @enabled
        @enabled = true

        begin
Severity: Minor
Found in lib/rx/concurrency/virtual_time_scheduler.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 generate has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def generate(initial_state, condition, iterate, result_selector, scheduler = CurrentThreadScheduler.instance)
Severity: Minor
Found in lib/rx/operators/creation.rb - About 35 mins to fix

    Method subscription= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def subscription=(new_subscription)
          raise 'Subscription already set' if @set
    
          @set = true
          should_unsubscribe = false
    Severity: Minor
    Found in lib/rx/subscriptions/single_assignment_subscription.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 timer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def timer(due_time, period_or_scheduler = DefaultScheduler.instance, scheduler = DefaultScheduler.instance)
          case period_or_scheduler
          when Numeric
            period = period_or_scheduler
          when Scheduler
    Severity: Minor
    Found in lib/rx/linq/observable/timer.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 to_async has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_async(func, context = nil, scheduler = DefaultScheduler.instance)
          lambda() {|*args|
            subject = AsyncSubject.new
    
            scheduler.schedule lambda {
    Severity: Minor
    Found in lib/rx/linq/observable/to_async.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 schedule_relative_with_state has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def schedule_relative_with_state(state, due_time, action) 
            return self.schedule_with_state state, action if due_time <= 0
    
            m = SingleAssignmentSubscription.new
    
    
    Severity: Minor
    Found in lib/rx/concurrency/immediate_scheduler.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 on_completed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def on_completed
          os = nil
          v = nil
          hv = false
    
    
    Severity: Minor
    Found in lib/rx/subjects/async_subject.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 ref_count has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def ref_count
          count = 0
          AnonymousObservable.new do |observer|
            count += 1
            should_connect = true if count == 1
    Severity: Minor
    Found in lib/rx/linq/connectable_observable.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 concat_map has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def concat_map(selector, result_selector = nil)
          if Proc === result_selector
            return concat_map(lambda {|x, i|
              selector_result = selector.call(x, i)
              if selector_result.respond_to?(:each)
    Severity: Minor
    Found in lib/rx/linq/observable/concat_map.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 release has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def release
          subscription = nil
          @gate.synchronize do
            if @subscription
              @count -= 1
    Severity: Minor
    Found in lib/rx/subscriptions/ref_count_subscription.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

    Severity
    Category
    Status
    Source
    Language