ReactiveX/RxRuby

View on GitHub

Showing 124 of 124 total issues

Method combine_latest has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def combine_latest(other, &result_selector)
      AnonymousObservable.new do |observer|
        has_left = false
        has_right = false

Severity: Major
Found in lib/rx/operators/multiple.rb - About 2 hrs to fix

    Method delay_time_span has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def delay_time_span(due_time, scheduler)
          AnonymousObservable.new do |observer|
            active = false
            cancelable = SerialSubscription.new
            exception = nil
    Severity: Major
    Found in lib/rx/linq/observable/delay.rb - About 2 hrs to fix

      Method delay_with_selector has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def delay_with_selector(subscription_delay, delay_duration_selector = nil)
            if Proc === subscription_delay
              selector = subscription_delay
            else
              sub_delay = subscription_delay
      Severity: Major
      Found in lib/rx/linq/observable/delay_with_selector.rb - About 2 hrs to fix

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

                obs2 = Observer.configure do |o|
                  o.on_next do |x|
                    gate.synchronize do
                      if left_queue.length > 0
                        v = left_queue.shift
        Severity: Major
        Found in lib/rx/operators/aggregates.rb and 1 other location - About 2 hrs to fix
        lib/rx/operators/aggregates.rb on lines 355..387

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

        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

                obs1 = Observer.configure do |o|
                  o.on_next do |x|
                    gate.synchronize do
                      if right_queue.length > 0
                        v = right_queue.shift
        Severity: Major
        Found in lib/rx/operators/aggregates.rb and 1 other location - About 2 hrs to fix
        lib/rx/operators/aggregates.rb on lines 395..427

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

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

            def skip_while_with_index(&block)
              AnonymousObservable.new do |observer|
                running = false
                i = 0
        
        
        Severity: Minor
        Found in lib/rx/operators/standard_query_operators.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 take_while_with_index has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def take_while_with_index(&block)
              AnonymousObservable.new do |observer|
                running = true
                i = 0
        
        
        Severity: Minor
        Found in lib/rx/operators/standard_query_operators.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 rescue_error has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def rescue_error(*args)
                AnonymousObservable.new do |observer|
                  gate = AsyncLock.new
                  disposed = false
                  e = args.length == 1 && args[0].is_a?(Enumerator) ? args[0] : args.to_enum
        Severity: Minor
        Found in lib/rx/operators/multiple.rb - About 1 hr to fix

          Method fork_join has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def fork_join(*all_sources)
                AnonymousObservable.new {|subscriber|
                  count = all_sources.length
                  if count == 0
                    subscriber.on_completed
          Severity: Minor
          Found in lib/rx/linq/observable/fork_join.rb - About 1 hr to fix

            Method distinct has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def distinct(&key_selector)
                  key_selector ||= lambda {|x| x}
            
                  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 generate has a Cognitive Complexity of 15 (exceeds 5 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

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

                  def combine_latest(*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 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 merge_concurrent has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def merge_concurrent(max_concurrent = 1)
                  AnonymousObservable.new do |observer|
                    gate = Monitor.new
                    q = []
                    stopped = false
            Severity: Minor
            Found in lib/rx/operators/multiple.rb - About 1 hr to fix

              Method scan has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def scan(*args, &block)
                    has_seed = false
                    seed = nil
                    action = nil
              
              
              Severity: Minor
              Found in lib/rx/operators/single.rb - About 1 hr to fix

                Method tap has a Cognitive Complexity of 14 (exceeds 5 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

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

                    def do(observer_or_on_next = nil, on_error_func = nil, on_completed_func = nil)
                      if block_given?
                        on_next_func = Proc.new
                      elsif Proc === observer_or_on_next
                        on_next_func = observer_or_on_next
                Severity: Minor
                Found in lib/rx/linq/observable/do.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 combine_latest has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def combine_latest(*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 1 hr to fix

                  Method on_error_resume_next has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def on_error_resume_next(*args)
                          AnonymousObservable.new do |observer|
                            gate = AsyncLock.new
                            disposed = false
                            e = args.length == 1 && args[0].is_a?(Enumerator) ? args[0] : args.to_enum
                  Severity: Minor
                  Found in lib/rx/operators/multiple.rb - About 1 hr to fix

                    Method concat has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def concat(*args)
                            AnonymousObservable.new do |observer|
                              disposed = false
                              e = args.length == 1 && args[0].is_a?(Enumerator) ? args[0] : args.to_enum
                              subscription = SerialSubscription.new
                    Severity: Minor
                    Found in lib/rx/operators/multiple.rb - About 1 hr to fix

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

                          def sample(intervalOrSampler, scheduler = DefaultScheduler.instance, &recipe)
                            sampler = if intervalOrSampler.is_a? Numeric
                              Observable.interval(intervalOrSampler, scheduler)
                            else
                              intervalOrSampler
                      Severity: Minor
                      Found in lib/rx/linq/observable/sample.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

                      Severity
                      Category
                      Status
                      Source
                      Language