dry-rb/dry-effects

View on GitHub

Showing 12 of 12 total issues

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

        def initialize(scope, default: Undefined, writer: true, as: scope)
          super()

          read = State.new(type: :state, name: :read, scope: scope)
          write = State.new(type: :state, name: :write, scope: scope)
Severity: Minor
Found in lib/dry/effects/effects/state.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 initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def initialize(scope, default: Undefined, writer: true, as: scope)
          super()

          read = State.new(type: :state, name: :read, scope: scope)
          write = State.new(type: :state, name: :write, scope: scope)
Severity: Minor
Found in lib/dry/effects/effects/state.rb - About 1 hr to fix

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

            def initialize(scope = nil, shared: false, **kw)
              super()
    
              if !kw.empty?
                scope, as = kw.to_a[0]
    Severity: Minor
    Found in lib/dry/effects/effects/cache.rb - About 1 hr to fix

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

            def call(effect)
              if effect.is_a?(Effect) && (provider = provider(effect))
                if effect.keywords.empty?
                  provider.public_send(effect.name, *effect.payload)
                else
      Severity: Minor
      Found in lib/dry/effects/stack.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def initialize(scope = nil, shared: false, **kw)
                super()
      
                if !kw.empty?
                  scope, as = kw.to_a[0]
      Severity: Minor
      Found in lib/dry/effects/effects/cache.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
                super
      
                module_eval do
                  define_method(:lock) do |key, meta: Undefined, &block|
      Severity: Minor
      Found in lib/dry/effects/effects/lock.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 build_generator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def build_generator(options)
                case options
                when Undefined
                  DEFAULT
                when ::Hash
      Severity: Minor
      Found in lib/dry/effects/providers/random.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 yield has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def yield(effect)
              result = ::Fiber.yield(effect)
      
              if result.is_a?(Instruction)
                result.()
      Severity: Minor
      Found in lib/dry/effects.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 build_generator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def build_generator(generator, step: Undefined, initial: Undefined, overridable: false)
                if overridable
                  parent = ::Dry::Effects.yield(Locate) { nil }
                else
                  parent = nil
      Severity: Minor
      Found in lib/dry/effects/providers/current_time.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 spawn_fiber has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def spawn_fiber(stack)
                fiber = ::Fiber.new do
                  self.stack = stack
                  yield
                end
      Severity: Minor
      Found in lib/dry/effects/frame.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 rand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def rand(range_or_limit = nil)
                range_or_limit ||= DEFAULT_RANGE
      
                if range_or_limit.is_a?(::Range)
                  low = range_or_limit.begin
      Severity: Minor
      Found in lib/dry/effects/providers/random.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 build_generator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def build_generator(generator, step: Undefined, initial: Undefined, overridable: false)
                if overridable
                  parent = ::Dry::Effects.yield(Locate) { nil }
                else
                  parent = nil
      Severity: Minor
      Found in lib/dry/effects/providers/timestamp.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

      Severity
      Category
      Status
      Source
      Language