dry-rb/dry-schema

View on GitHub

Showing 18 of 21 total issues

Class DSL has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

    class DSL
      Types = Schema::Types

      extend Dry::Initializer

Severity: Minor
Found in lib/dry/schema/dsl.rb - About 4 hrs to fix

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

            def call(*predicates, **opts, &block)
              schema = predicates.detect { |predicate| predicate.is_a?(Processor) }
    
              type_spec = opts[:type_spec]
    
    
    Severity: Minor
    Found in lib/dry/schema/macros/value.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 extract_type_spec has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

            def extract_type_spec(*args, nullable: false, set_type: true)
              type_spec = args[0] unless schema_or_predicate?(args[0])
    
              predicates = Array(type_spec ? args[1..-1] : args)
              type_rule = nil
    Severity: Minor
    Found in lib/dry/schema/macros/dsl.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

    Class MessageCompiler has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class MessageCompiler
          extend Dry::Initializer
    
          resolve_key_predicate = proc { |node, opts|
            *arg_vals, val = node.map(&:last)
    Severity: Minor
    Found in lib/dry/schema/message_compiler.rb - About 2 hrs to fix

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

            def call(result)
              input = result.to_h
      
              input_paths = key_paths(input)
              key_paths = key_map.to_dot_notation
      Severity: Minor
      Found in lib/dry/schema/key_validator.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 value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def value(*args, **opts, &block)
                type(:array)
      
                extract_type_spec(*args, set_type: false) do |*predicates, type_spec:, type_rule:|
                  type(schema_dsl.array[type_spec]) if type_spec
      Severity: Minor
      Found in lib/dry/schema/macros/array.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 call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              def call(*args, &block)
                if args.size >= 1 && args[0].respond_to?(:keys)
                  hash_type = args[0]
                  type_predicates = predicate_inferrer[hash_type]
                  all_predicats = type_predicates + args.drop(1)
      Severity: Minor
      Found in lib/dry/schema/macros/hash.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 key_spec has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def key_spec(name, type)
              if type.respond_to?(:keys)
                {name => key_map(type.name_key_map)}
              elsif type.respond_to?(:member)
                kv = key_spec(name, type.member)
      Severity: Minor
      Found in lib/dry/schema/dsl.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 call has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def call(*predicates, **opts, &block)
                schema = predicates.detect { |predicate| predicate.is_a?(Processor) }
      
                type_spec = opts[:type_spec]
      
      
      Severity: Minor
      Found in lib/dry/schema/macros/value.rb - About 1 hr to fix

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

              def call(input)
                if input.success?
                  type_schema[input.to_h]
                else
                  type_schema.each_with_object(EMPTY_HASH.dup) do |key, hash|
        Severity: Minor
        Found in lib/dry/schema/value_coercer.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 to_h has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def to_h(value = EMPTY_ARRAY.dup)
                curr_idx = 0
                last_idx = keys.size - 1
                hash = EMPTY_HASH.dup
                node = hash
        Severity: Minor
        Found in lib/dry/schema/path.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 visit_set has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def visit_set(node, opts = EMPTY_HASH)
                  target = (key = opts[:key]) ? self.class.new : self
        
                  node.each { |child| target.visit(child, opts) }
        
        
        Severity: Minor
        Found in lib/dry/schema/extensions/info/schema_compiler.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 [] has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def self.[](left, right, messages)
                  msgs = [left, right].flatten
                  paths = msgs.map(&:path)
        
                  if paths.uniq.size == 1
        Severity: Minor
        Found in lib/dry/schema/message/or.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def call(*args)
                  if args.size >= 1 && args[0].is_a?(::Class) && args[0] <= ::Dry::Struct
                    if block_given?
                      raise ArgumentError, "blocks are not supported when using "\
                                           "a struct class (#{name.inspect} => #{args[0]})"
        Severity: Minor
        Found in lib/dry/schema/extensions/struct.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 method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def method_missing(meth, *args, &block)
                if meth.to_s.end_with?(QUESTION_MARK)
                  if ::Dry::Schema::Trace::INVALID_PREDICATES.include?(meth)
                    ::Kernel.raise InvalidSchemaError, "#{meth} predicate cannot be used in this context"
                  end
        Severity: Minor
        Found in lib/dry/schema/trace.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 exclude? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                  def exclude?(messages, opts)
                    Array(messages).all? do |msg|
                      hints = opts
                        .hints
                        .reject { |hint| msg == hint }
        Severity: Minor
        Found in lib/dry/schema/extensions/hints/message_compiler_methods.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 define has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def define(*args, &block)
                  definition = schema_dsl.new(path: schema_dsl.path, &block)
                  schema = definition.call
                  type_schema =
                    if array_type?(parent_type)
        Severity: Minor
        Found in lib/dry/schema/macros/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 evaluate_predicates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def evaluate_predicates(predicates)
                predicates.flat_map do |predicate|
                  if predicate.respond_to?(:call)
                    predicate
                  elsif predicate.is_a?(::Array)
        Severity: Minor
        Found in lib/dry/schema/trace.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