ReactiveX/Rx.rb

View on GitHub
lib/rx/operators/aggregates.rb

Summary

Maintainability
F
4 days
Test Coverage

Method sequence_eql? has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

    def sequence_eql?(other)
      AnonymousObservable.new do |observer|
        gate = Mutex.new
        left_done = false
        right_done = false
Severity: Minor
Found in lib/rx/operators/aggregates.rb - About 1 day 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

File aggregates.rb has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'thread'
require 'rx/subscriptions/composite_subscription'
require 'rx/core/observer'
require 'rx/core/observable'
require 'rx/operators/single'
Severity: Minor
Found in lib/rx/operators/aggregates.rb - About 6 hrs to fix

    Method sequence_eql? has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def sequence_eql?(other)
          AnonymousObservable.new do |observer|
            gate = Mutex.new
            left_done = false
            right_done = false
    Severity: Major
    Found in lib/rx/operators/aggregates.rb - About 3 hrs to fix

      Method extrema_by has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def extrema_by(is_min = false, &block)
            AnonymousObservable.new do |observer|
              has_value = false
              last_key = nil
              list = []
      Severity: Minor
      Found in lib/rx/operators/aggregates.rb - About 3 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 extrema_by has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def extrema_by(is_min = false, &block)
            AnonymousObservable.new do |observer|
              has_value = false
              last_key = nil
              list = []
      Severity: Minor
      Found in lib/rx/operators/aggregates.rb - About 1 hr to fix

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

            def single(&block)
              return select(&block).single 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 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 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

        Method last has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def last(&block)
              return select(&block).last if block_given?
              AnonymousObservable.new do |observer|
        
                value = nil
        Severity: Minor
        Found in lib/rx/operators/aggregates.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 last_or_default has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def last_or_default(default_value = nil, &block)
              return select(&block).last_or_default(default_value) if block_given?
              AnonymousObservable.new do |observer|
        
                value = nil
        Severity: Minor
        Found in lib/rx/operators/aggregates.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

        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

        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

        There are no issues that match your filters.

        Category
        Status