dry-rb/dry-validation

View on GitHub

Showing 3 of 16 total issues

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

        def message(rule, tokens: EMPTY_HASH, locale: nil, full: false, path:)
          keys = path.to_a.compact
          msg_opts = tokens.merge(path: keys, locale: locale || messages.default_locale)

          if keys.empty?
Severity: Minor
Found in lib/dry/validation/messages/resolver.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 error? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def error?(result, spec)
        path = Schema::Path[spec]

        if path.multi_value?
          return path.expand.any? { |nested_path| error?(result, nested_path) }
Severity: Minor
Found in lib/dry/validation/contract.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 define has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def define(method_name, external_schema, &block)
          return __schema__ if external_schema.nil? && block.nil?

          unless __schema__.nil?
            raise ::Dry::Validation::DuplicateSchemaError, 'Schema has already been defined'
Severity: Minor
Found in lib/dry/validation/contract/class_interface.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