dry-rb/dry-struct

View on GitHub

Showing 4 of 4 total issues

Class Struct has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Struct
    # Class-level interface of {Struct} and {Value}
    module ClassInterface
      include Core::ClassAttributes

Severity: Minor
Found in lib/dry/struct/class_interface.rb - About 3 hrs to fix

    Method build_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_type(name, type, &block)
            type_object =
              if type.is_a?(String)
                Dry::Types[type]
              elsif block.nil? && type.nil?
    Severity: Minor
    Found in lib/dry/struct/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

    Method [] has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.[](value)
            if value.respond_to?(:to_hash)
              if RUBY_VERSION >= '2.4'
                value.to_hash.transform_values { |v| self[v] }
              else
    Severity: Minor
    Found in lib/dry/struct/hashify.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 meta has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def meta(meta = Undefined)
            if meta.equal?(Undefined)
              @meta
            else
              Class.new(self) do
    Severity: Minor
    Found in lib/dry/struct/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