ama-team/ruby-entity-mapper

View on GitHub

Showing 12 of 19 total issues

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

      class Type
        include Mixin::Errors
        include Mixin::Reflection
        include Mixin::HandlerSupport

Severity: Minor
Found in lib/ama-entity-mapper/type.rb - About 2 hrs to fix

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

                def define_denormalizer
                  denormalizer_block do |input, _, ctx|
                    break input if input.is_a?(DateTime)
                    input = input.to_s if input.is_a?(Symbol)
                    break DateTime.iso8601(input, 3) if input.is_a?(String)
    Severity: Minor
    Found in lib/ama-entity-mapper/type/builtin/datetime_type.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 attribute! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def attribute!(name, *types, **options)
              name = name.to_sym
              types = types.map do |type|
                next type if type.is_a?(Parameter)
                next parameter!(type) if type.is_a?(Symbol)
    Severity: Minor
    Found in lib/ama-entity-mapper/type.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 denormalize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

                  def denormalize(source, type, context)
                    return source if type.valid?(source, context)
                    find_candidate_methods(source.class).each do |candidate|
                      begin
                        next unless source.respond_to?(candidate)
    Severity: Minor
    Found in lib/ama-entity-mapper/type/builtin/primitive_type/denormalizer.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 denormalize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

                def denormalize(source, type, context = nil)
                  validate_source!(source, type, context)
                  entity = type.factory.create(type, source, context)
                  type.attributes.values.each do |attribute|
                    next if attribute.virtual
    Severity: Minor
    Found in lib/ama-entity-mapper/handler/entity/denormalizer.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 resolve_parameter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

              def resolve_parameter(parameter, substitution)
                clone.tap do |clone|
                  clone.types = types.each_with_object([]) do |type, carrier|
                    if type == parameter
                      buffer = substitution
    Severity: Minor
    Found in lib/ama-entity-mapper/type/attribute.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 define_denormalizer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

                def define_denormalizer
                  denormalizer_block do |input, _, ctx|
                    break input if input.is_a?(Rational)
                    input = input.to_s if input.is_a?(Symbol)
                    break Rational(input) if input.is_a?(String)
    Severity: Minor
    Found in lib/ama-entity-mapper/type/builtin/rational_type.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 inject has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

                def inject(entity, _type, attribute, value, _context = nil)
    Severity: Minor
    Found in lib/ama-entity-mapper/handler/entity/injector.rb - About 35 mins to fix

      Method normalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                  def normalize(entity, type, context)
                    type.attributes.values.each_with_object({}) do |attribute, data|
                      next if attribute.virtual
                      condition = context.include_sensitive_attributes
                      next if attribute.sensitive && !condition
      Severity: Minor
      Found in lib/ama-entity-mapper/handler/entity/normalizer.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_def has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def to_def
                return @type.to_s if parameters.empty?
                params = parameters.map do |key, value|
                  value = [value] unless value.is_a?(Enumerable)
                  value = value.map(&:to_def)
      Severity: Minor
      Found in lib/ama-entity-mapper/type.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 enumerate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                  def enumerate(entity, type, _context)
                    ::Enumerator.new do |yielder|
                      type.attributes.values.each do |attribute|
                        next if attribute.virtual
                        value = attribute.default
      Severity: Minor
      Found in lib/ama-entity-mapper/handler/entity/enumerator.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 successful has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                def successful(enumerator, error = StandardError, ctx = nil)
                  suppressed = []
                  enumerator.each do |*args|
                    begin
                      return yield(*args)
      Severity: Minor
      Found in lib/ama-entity-mapper/mixin/suppression_support.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