dry-rb/dry-types

View on GitHub

Showing 40 of 40 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

    File printer.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Dry
      module Types
        # @api private
        class Printer
          MAPPING = {
    Severity: Minor
    Found in lib/dry/types/printer.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)
                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 try has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

                def try(input, &block)
                  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 visit_callable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def visit_callable(callable)
                fn = callable.is_a?(String) ? FnContainer[callable] : callable
        
                case fn
                when ::Method
        Severity: Minor
        Found in lib/dry/types/printer.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 visit_options has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def visit_options(options, meta = EMPTY_HASH)
                if options.empty? && meta.empty?
                  yield ""
                else
                  opts = options.empty? ? "" : " options=#{options.inspect}"
        Severity: Minor
        Found in lib/dry/types/printer.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)
                  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 visit_schema has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def visit_schema(schema)
                  options = schema.options.dup
                  size = schema.count
                  key_fn_str = ""
                  type_fn_str = ""
          Severity: Minor
          Found in lib/dry/types/printer.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)
                    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 visit_sum_constructors has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def visit_sum_constructors(sum)
                      case sum.left
                      when Sum
                        visit_sum_constructors(sum.left) do |left|
                          case sum.right
              Severity: Minor
              Found in lib/dry/types/printer.rb - About 1 hr to fix

                Method visit_callable has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def visit_callable(callable)
                        fn = callable.is_a?(String) ? FnContainer[callable] : callable
                
                        case fn
                        when ::Method
                Severity: Minor
                Found in lib/dry/types/printer.rb - About 1 hr to fix

                  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 visit_sum_constructors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def visit_sum_constructors(sum)
                          case sum.left
                          when Sum
                            visit_sum_constructors(sum.left) do |left|
                              case sum.right
                  Severity: Minor
                  Found in lib/dry/types/printer.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 fallback has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def fallback(value = Undefined, shared: false, &_fallback)
                          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 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

                  Severity
                  Category
                  Status
                  Source
                  Language