am-kantox/dry-mutations

View on GitHub

Showing 17 of 65 total issues

Method Type has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def self.Type type, **params
        case Snake(type)
        when 'string'
          if Falsey?(params[:strip])
            :str?
Severity: Minor
Found in lib/dry/mutations/utils/dry-mutations.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 SnakeSafe has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def self.SnakeSafe(whatever, existing = [], update_existing: true, short: false, symbolize: false)
        result = Snake(whatever, short: short)
        str = loop do
          break result unless existing.include? result
          suffix = result[/(?<=_)\d+(?=\z)/]
Severity: Minor
Found in lib/dry/mutations/utils/generic.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 patch_message_set has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def self.patch_message_set(set)
          return nil if set.empty?

          fail TypeError, "Expected: ::Dry::Validation::MessageSet; got: #{set.class}" unless set.is_a?(::Dry::Validation::MessageSet)

Severity: Minor
Found in lib/dry/mutations/errors/error_atom.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 prepended has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def self.prepended base
          fail ArgumentError, "Can not prepend #{self.class} to #{base.class}: base class must be a ::Mutations::Command descendant." unless base < ::Mutations::Command
          base.extend(DSL::Module) unless base.ancestors.include?(DSL::Module)
          base.extend(Module.new do
            def exceptions_as_errors(value)
Severity: Minor
Found in lib/dry/mutations/extensions/command.rb - About 1 hr to fix

    Method Type has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.Type type, **params
            case Snake(type)
            when 'string'
              if Falsey?(params[:strip])
                :str?
    Severity: Minor
    Found in lib/dry/mutations/utils/dry-mutations.rb - About 1 hr to fix

      Method Either has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.Either input
              case input
              when Class then input.prepend Either unless input.ancestors.include?(Either)
              when Module then input.include Either unless input.ancestors.include?(Either)
              else input.singleton_class.prepend Either unless input.singleton_class.ancestors.include?(Either)
      Severity: Minor
      Found in lib/dry/mutations/extensions/outcome.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 fix_accessors! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def fix_accessors!
                schema.rules.keys.each do |method|
                  next if respond_to?(name = method)
      
                  singleton_class.tap do |c|
      Severity: Minor
      Found in lib/dry/mutations/extensions/command.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 derived_schema has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def derived_schema input_processor:, type:, **options, &block
                this = is_a?(Class) ? self : self.class
      
                parent_with_schema = this.ancestors.drop(1).detect do |klazz|
                  next if [this, ::Mutations::Command, ::Dry::Mutations::Extensions::Command].include?(klazz)
      Severity: Minor
      Found in lib/dry/mutations/dsl/schema.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 array has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def array name, **params, &cb
                current = @current # closure scope
      
                nested =  begin
                            Nested.!(current, &cb)
      Severity: Minor
      Found in lib/dry/mutations/dsl/types.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 Schema has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.Schema(input_processor: nil, type: :schema, **options, &block)
            type = :schema unless type && ::Dry::Mutations.const_defined?(type.to_s.capitalize)
            parent = ::Dry::Mutations.const_get(type.to_s.capitalize)
            ::Dry::Validation.Schema(parent, **options) do
              configure { config.input_processor = input_processor } if input_processor
      Severity: Minor
      Found in lib/dry/mutations.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 prepended has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.prepended base
                fail ArgumentError, "Can not prepend #{self.class} to #{base.class}: base class must be a ::Mutations::Command descendant." unless base < ::Mutations::Command
                base.extend(DSL::Module) unless base.ancestors.include?(DSL::Module)
                base.extend(Module.new do
                  def exceptions_as_errors(value)
      Severity: Minor
      Found in lib/dry/mutations/extensions/command.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 schema has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def schema *args, input_processor: nil, type: :form, **options, &block
                case args.count
                when 0, 1
                  schema, = args
                  @schema ||= patched_schema(schema) \
      Severity: Minor
      Found in lib/dry/mutations/dsl/schema.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 RawInputs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.RawInputs *args
              args.inject(Utils.Hash({})) do |h, arg|
                h.merge! case arg
                         when Hash then arg
                         when ::Dry::Monads::Either::Right then arg.value
      Severity: Minor
      Found in lib/dry/mutations/utils/dry-mutations.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 finalizer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def finalizer(type, outcome)
                fin = self.class.instance_variable_get :@finalizers
                # rubocop:disable Lint/AssignmentInCondition
                return nil unless fin.is_a?(Hash) && finalizer = fin[type]
                # rubocop:enable Lint/AssignmentInCondition
      Severity: Minor
      Found in lib/dry/mutations/extensions/command.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 Outcome has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.Outcome input
              case input
              when ::Mutations::Outcome then input
              when ::Dry::Monads::Either::Left
                ::Mutations::Outcome.new(false, nil, input.value, nil).tap do |outcome|
      Severity: Minor
      Found in lib/dry/mutations/extensions/outcome.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 dig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def dig(predicate, input = schema)
                case input.rules
                when Hash # the whole schema
                  input.rules.map do |k, v|
                    pred = predicates(v).detect do |p|
      Severity: Minor
      Found in lib/dry/mutations/extensions/command.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 extended has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.extended base
                fail Errors::TypeError.new("Extended class [#{base}] should not respond to :call, it is defined by this extension.") if base.respond_to?(:call)
                base.send :define_method, :initialize do |*input|
                  @input = Utils.RawInputs(*input)
                end unless base.instance_methods(false).include?(:initialize)
      Severity: Minor
      Found in lib/dry/mutations/transactions/dsl.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