dry-rb/dry-types

View on GitHub

Showing 97 of 97 total issues

Class has too many lines. [266/150]
Open

    class Printer
      MAPPING = {
        Nominal => :visit_nominal,
        Constructor => :visit_constructor,
        Hash::Constructor => :visit_constructor,
Severity: Minor
Found in lib/dry/types/printer.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class has too many lines. [186/150]
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 by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [38/22]
Open

      def try(input)
        if primitive?(input)
          success = true
          output = {}
          result = {}
Severity: Minor
Found in lib/dry/types/schema.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for try is too high. [29.27/20]
Open

      def try(input)
        if primitive?(input)
          success = true
          output = {}
          result = {}
Severity: Minor
Found in lib/dry/types/schema.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for coerce is too high. [28.88/20]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

    Method has too many lines. [29/22]
    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 by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [28/22]
    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 by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for type_constants is too high. [26.53/20]
    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 by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [28/22]
    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 by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Class Schema has 22 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

      Perceived complexity for try is too high. [12/7]
      Open

            def try(input)
              if primitive?(input)
                success = true
                output = {}
                result = {}
      Severity: Minor
      Found in lib/dry/types/schema.rb by rubocop

      This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

      Example:

      def my_method                   # 1
        if cond                       # 1
          case var                    # 2 (0.8 + 4 * 0.2, rounded)
          when 1 then func_one
          when 2 then func_two
          when 3 then func_three
          when 4..10 then func_other
          end
        else                          # 1
          do_something until a && b   # 2
        end                           # ===
      end                             # 7 complexity points

      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

        Assignment Branch Condition size for visit_schema is too high. [24.92/20]
        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 by rubocop

        This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

        Perceived complexity for visit_callable is too high. [11/7]
        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 by rubocop

        This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

        Example:

        def my_method                   # 1
          if cond                       # 1
            case var                    # 2 (0.8 + 4 * 0.2, rounded)
            when 1 then func_one
            when 2 then func_two
            when 3 then func_three
            when 4..10 then func_other
            end
          else                          # 1
            do_something until a && b   # 2
          end                           # ===
        end                             # 7 complexity points

        Perceived complexity for type_constants is too high. [11/7]
        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 by rubocop

        This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

        Example:

        def my_method                   # 1
          if cond                       # 1
            case var                    # 2 (0.8 + 4 * 0.2, rounded)
            when 1 then func_one
            when 2 then func_two
            when 3 then func_three
            when 4..10 then func_other
            end
          else                          # 1
            do_something until a && b   # 2
          end                           # ===
        end                             # 7 complexity points

        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 has too many lines. [25/22]
        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 by rubocop

        This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

        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

        Severity
        Category
        Status
        Source
        Language