ReactiveX/RxRuby

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

Summary

Maintainability
D
2 days
Test Coverage

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

File single.rb has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rx/subscriptions/subscription'
require 'rx/subscriptions/composite_subscription'
require 'rx/subscriptions/ref_count_subscription'
require 'rx/subscriptions/single_assignment_subscription'
require 'rx/core/observer'
Severity: Minor
Found in lib/rx/operators/single.rb - About 3 hrs to fix

    Method window_with_count has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def window_with_count(count, skip)
          raise ArgumentError.new 'Count must be greater than zero' if count <= 0
          raise ArgumentError.new 'Skip must be greater than zero' if skip <= 0
    
          AnonymousObservable.new do |observer|
    Severity: Minor
    Found in lib/rx/operators/single.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 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 window_with_count has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def window_with_count(count, skip)
            raise ArgumentError.new 'Count must be greater than zero' if count <= 0
            raise ArgumentError.new 'Skip must be greater than zero' if skip <= 0
      
            AnonymousObservable.new do |observer|
      Severity: Minor
      Found in lib/rx/operators/single.rb - About 1 hr to fix

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

            def take_last(count, scheduler = CurrentThreadScheduler.instance)
              raise ArgumentError.new 'Count cannot be less than zero' if count < 0
              AnonymousObservable.new do |observer|
                q = []
                g = CompositeSubscription.new
        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 distinct_until_changed has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def distinct_until_changed(&key_selector)
              key_selector ||= lambda {|x| x}
              AnonymousObservable.new do |observer|
                current_key = nil
                has_current = nil
        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 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

          There are no issues that match your filters.

          Category
          Status