dry-rb/dry-types

View on GitHub

Showing 32 of 32 total issues

Class Schema has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Schema < Hash
      NO_TRANSFORM = Dry::Types::FnContainer.register { |x| x }
      SYMBOLIZE_KEY = Dry::Types::FnContainer.register(:to_sym.to_proc)

      include ::Enumerable
Severity: Minor
Found in lib/dry/types/schema.rb - About 2 hrs to fix

    Class Compiler has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Compiler
          extend ::Dry::Core::Deprecations[:"dry-types"]
    
          attr_reader :registry
    
    
    Severity: Minor
    Found in lib/dry/types/compiler.rb - About 2 hrs to fix

      Method try has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

              def try(input, &block) # rubocop:disable Metrics/PerceivedComplexity
                if primitive?(input)
                  output = []
      
                  result = input.map { |el| member.try(el) }
      Severity: Minor
      Found in lib/dry/types/array/member.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 try has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def try(input)
              if primitive?(input)
                success = true
                output = {}
                result = {}
      Severity: Minor
      Found in lib/dry/types/schema.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 infer_predicate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              def infer_predicate(type) # rubocop:disable Metrics/PerceivedComplexity
                pred = TYPE_TO_PREDICATE.fetch(type) do
                  if type.name.nil? || self.class.infer_predicate_by_class_name.equal?(false)
                    nil
                  else
      Severity: Minor
      Found in lib/dry/types/predicate_inferrer.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 try has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def try(input)
              if primitive?(input)
                success = true
                output = {}
                result = {}
      Severity: Minor
      Found in lib/dry/types/schema.rb - About 1 hr to fix

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

              def type_constants(*namespaces, default: Undefined, **aliases)
                if namespaces.empty? && aliases.empty? && Undefined.equal?(default)
                  default_ns = :Strict
                elsif Undefined.equal?(default)
                  default_ns = Undefined
        Severity: Minor
        Found in lib/dry/types/module.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 resolve_missing_keys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def resolve_missing_keys(hash, options) # rubocop:disable Metrics/PerceivedComplexity
                skip_missing = options.fetch(:skip_missing, false)
                resolve_defaults = options.fetch(:resolve_defaults, true)
        
                keys.each do |key|
        Severity: Minor
        Found in lib/dry/types/schema.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 infer_predicate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def infer_predicate(type) # rubocop:disable Metrics/PerceivedComplexity
                  pred = TYPE_TO_PREDICATE.fetch(type) do
                    if type.name.nil? || self.class.infer_predicate_by_class_name.equal?(false)
                      nil
                    else
        Severity: Minor
        Found in lib/dry/types/predicate_inferrer.rb - About 1 hr to fix

          Method fallback has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def fallback(value = Undefined, shared: false, &_fallback) # rubocop:disable Metrics/PerceivedComplexity
                  if Undefined.equal?(value) && !block_given?
                    raise ::ArgumentError, "fallback value or a block must be given"
                  end
          
          
          Severity: Minor
          Found in lib/dry/types/builder.rb - About 1 hr to fix

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

                  def fallback(value = Undefined, shared: false, &_fallback) # rubocop:disable Metrics/PerceivedComplexity
                    if Undefined.equal?(value) && !block_given?
                      raise ::ArgumentError, "fallback value or a block must be given"
                    end
            
            
            Severity: Minor
            Found in lib/dry/types/builder.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 [] has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.[](name)
                  type_map.fetch_or_store(name) do
                    case name
                    when ::String
                      result = name.match(TYPE_SPEC_REGEX)
            Severity: Minor
            Found in lib/dry/types.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 try has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def try(input, &block)
                      result = type.try(input)
            
                      if result.success?
                        validation = rule.(result.input)
            Severity: Minor
            Found in lib/dry/types/constrained/coercible.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_safe has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def call_safe(input)
                      if primitive?(input)
                        failed = false
            
                        result = input.each_with_object([]) do |el, output|
            Severity: Minor
            Found in lib/dry/types/array/member.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 coerce has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def coerce(input)
                    unless primitive?(input)
                      return failure(
                        input, CoercionError.new("#{input.inspect} must be an instance of #{primitive}")
                      )
            Severity: Minor
            Found in lib/dry/types/map.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 to_ast has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def to_ast(meta: true)
                      if member.respond_to?(:to_ast)
                        [:array, [member.to_ast(meta: meta), meta ? self.meta : EMPTY_HASH]]
                      else
                        [:array, [member, meta ? self.meta : EMPTY_HASH]]
            Severity: Minor
            Found in lib/dry/types/array/member.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 define_constants has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def define_constants(constants, mod = self)
                    constants.each do |name, value|
                      case value
                      when ::Hash
                        if mod.const_defined?(name, false)
            Severity: Minor
            Found in lib/dry/types/module.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.[](fn)
                      raise ::ArgumentError, "Missing constructor block" if fn.nil?
            
                      if fn.is_a?(Function)
                        fn
            Severity: Minor
            Found in lib/dry/types/constructor/function.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 to_decimal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                    def self.to_decimal(input, &_block)
                      if input.is_a?(::Float)
                        input.to_d
                      else
                        BigDecimal(input)
            Severity: Minor
            Found in lib/dry/types/coercions/json.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 Constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def Constructor(klass, cons = nil, &block) # rubocop:disable Metrics/PerceivedComplexity:
                    if klass.is_a?(Type)
                      if cons || block
                        klass.constructor(cons || block)
                      else
            Severity: Minor
            Found in lib/dry/types/builder_methods.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

            Severity
            Category
            Status
            Source
            Language