dry-rb/dry-schema

View on GitHub

Showing 12 of 63 total issues

Class DSL has 30 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 3 hrs to fix

    Method extract_type_spec has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

            def extract_type_spec(*args, nullable: false, set_type: true)
              type_spec = args[0]
    
              is_type_spec = type_spec.is_a?(Dry::Schema::Processor) ||
                             type_spec.is_a?(Symbol) &&
    Severity: Minor
    Found in lib/dry/schema/macros/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 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 value has a Cognitive Complexity of 11 (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(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 initialize_placeholders! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize_placeholders!
            return @placeholders = EMPTY_HASH if empty?
    
            @placeholders = paths.reduce(EMPTY_HASH.dup) do |hash, path|
              curr_idx = 0
    Severity: Minor
    Found in lib/dry/schema/message_set.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 key_spec has a Cognitive Complexity of 7 (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 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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

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

            def visit_predicate(node)
              pred, args = node
    
              if pred.equal?(:type?)
                EMPTY_ARRAY
    Severity: Minor
    Found in lib/dry/schema/predicate_inferrer.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(&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