dry-rb/dry-monads

View on GitHub

Showing 205 of 206 total issues

Class has too many lines. [187/100]
Open

    class List
      class << self
        # Builds a list.
        #
        # @param values [Array<Object>] List elements
Severity: Minor
Found in lib/dry/monads/list.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class has too many lines. [124/100]
Open

    class Task
      # @api private
      class Promise < Concurrent::Promise
        public :on_fulfill, :on_reject
      end
Severity: Minor
Found in lib/dry/monads/task.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class List has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

    class List
      class << self
        # Builds a list.
        #
        # @param values [Array<Object>] List elements
Severity: Minor
Found in lib/dry/monads/list.rb - About 3 hrs to fix

    Class Task has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Task
          # @api private
          class Promise < Concurrent::Promise
            public :on_fulfill, :on_reject
          end
    Severity: Minor
    Found in lib/dry/monads/task.rb - About 2 hrs to fix

      Method has too many lines. [17/10]
      Open

                def initialize(wrappers)
                  super()
      
                  @wrappers = wrappers
                  tracker = self
      Severity: Minor
      Found in lib/dry/monads/do/all.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [16/10]
      Open

            def or(&block)
              child = Promise.new(
                parent: promise,
                executor: Concurrent::ImmediateExecutor.new
              )
      Severity: Minor
      Found in lib/dry/monads/task.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [14/10]
      Open

            def typed(type = nil)
              if type.nil?
                if size.zero?
                  raise ArgumentError, "Cannot infer a monad for an empty list"
                else
      Severity: Minor
      Found in lib/dry/monads/list.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [13/10]
      Open

            def to_s
              state = case promise.state
                      when :fulfilled
                        if Unit.equal?(value!)
                          'value=()'
      Severity: Minor
      Found in lib/dry/monads/task.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Assignment Branch Condition size for typed is too high. [18.11/15]
      Open

            def typed(type = nil)
              if type.nil?
                if size.zero?
                  raise ArgumentError, "Cannot infer a monad for an empty list"
                else
      Severity: Minor
      Found in lib/dry/monads/list.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for or is too high. [18.28/15]
      Open

            def or(&block)
              child = Promise.new(
                parent: promise,
                executor: Concurrent::ImmediateExecutor.new
              )
      Severity: Minor
      Found in lib/dry/monads/task.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Method has too many lines. [13/10]
      Open

            def initialize(error, **options)
              @mod = Module.new do
                define_method(:Failure) do |value|
                  if error === value
                    Failure.new(value, RightBiased::Left.trace_caller)
      Severity: Minor
      Found in lib/dry/monads/result/fixed.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [13/10]
      Open

              def bind(*args, **kwargs)
                if args.empty? && !kwargs.empty?
                  vargs, vkwargs = destructure(@value)
                  kw = [kwargs.merge(vkwargs)]
                else
      Severity: Minor
      Found in lib/dry/monads/right_biased.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [12/10]
      Open

              def coerce(value, type = nil)
                if value.nil?
                  List.new([], type)
                elsif value.respond_to?(:to_ary)
                  values = value.to_ary
      Severity: Minor
      Found in lib/dry/monads/list.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Cyclomatic complexity for compare_promises is too high. [7/6]
      Open

            def compare_promises(x, y)
              x.equal?(y) ||
                x.fulfilled? && y.fulfilled? && x.value == y.value ||
                x.rejected? && y.rejected? && x.reason == y.reason
            end
      Severity: Minor
      Found in lib/dry/monads/task.rb by rubocop

      This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

      An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

      Method has too many lines. [11/10]
      Open

                def extended(object)
                  super
      
                  wrapper = ::Module.new
                  object.singleton_class.prepend(wrapper)
      Severity: Minor
      Found in lib/dry/monads/do/all.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [11/10]
      Open

            def collect
              if block_given?
                collected = value.each_with_object([]) do |x, ys|
                  y = yield(x)
                  ys << y.value! if y.some?
      Severity: Minor
      Found in lib/dry/monads/list.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [11/10]
      Open

              def unfold(state, type = nil)
                xs = []
      
                loop do
                  m = yield(state)
      Severity: Minor
      Found in lib/dry/monads/list.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Perceived complexity for coerce is too high. [8/7]
      Open

              def coerce(value, type = nil)
                if value.nil?
                  List.new([], type)
                elsif value.respond_to?(:to_ary)
                  values = value.to_ary
      Severity: Minor
      Found in lib/dry/monads/list.rb by rubocop

      This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

      Example:

      def my_method                   # 1
        if cond                       # 1
          case var                    # 2 (0.8 + 4 * 0.2, rounded)
          when 1 then func_one
          when 2 then func_two
          when 3 then func_three
          when 4..10 then func_other
          end
        else                          # 1
          do_something until a && b   # 2
        end                           # ===
      end                             # 7 complexity points

      Assignment Branch Condition size for coerce is too high. [15.84/15]
      Open

              def coerce(value, type = nil)
                if value.nil?
                  List.new([], type)
                elsif value.respond_to?(:to_ary)
                  values = value.to_ary
      Severity: Minor
      Found in lib/dry/monads/list.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

            def collect
              if block_given?
                collected = value.each_with_object([]) do |x, ys|
                  y = yield(x)
                  ys << y.value! if y.some?
      Severity: Minor
      Found in lib/dry/monads/list.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

      Severity
      Category
      Status
      Source
      Language