hopsoft/field_mapper

View on GitHub
lib/field_mapper/standard/plat.rb

Summary

Maintainability
D
2 days
Test Coverage

Method to_hash has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

      def to_hash(flatten: false, history: {}, include_meta: true, placeholders: false)
        history[object_id] = true
        hash = self.class.fields.values.reduce(HashWithIndifferentAccess.new) do |memo, field|
          name = field.name
          value = instance_variable_get("@#{attr_name(name)}")
Severity: Minor
Found in lib/field_mapper/standard/plat.rb - About 7 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

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

    class Plat
      include FieldMapper::NameHelper
      include FieldMapper::Marshaller

      class << self
Severity: Minor
Found in lib/field_mapper/standard/plat.rb - About 3 hrs to fix

    File plat.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "digest/md5"
    require_relative "../errors"
    require_relative "../name_helper"
    require_relative "../marshaller"
    require_relative "field"
    Severity: Minor
    Found in lib/field_mapper/standard/plat.rb - About 2 hrs to fix

      Method to_hash has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def to_hash(flatten: false, history: {}, include_meta: true, placeholders: false)
              history[object_id] = true
              hash = self.class.fields.values.reduce(HashWithIndifferentAccess.new) do |memo, field|
                name = field.name
                value = instance_variable_get("@#{attr_name(name)}")
      Severity: Major
      Found in lib/field_mapper/standard/plat.rb - About 2 hrs to fix

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

                def symbolize_hash(hash)
                  hash.reduce({}) do |memo, pair|
                    key = pair.first.intern
                    value = pair.last
                    value = symbolize_hash(value) if value.is_a?(Hash)
        Severity: Minor
        Found in lib/field_mapper/standard/plat.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 assign_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def assign_params(params)
                pending_assignments.clear
                params.each do |name, value|
                  field = self.class.fields[name]
                  next if field.nil?
        Severity: Minor
        Found in lib/field_mapper/standard/plat.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 add_pending_assignment_for_plat_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_pending_assignment_for_plat_list(field, value)
                pending_assignments << lambda do |descendant_plats|
                  list = value.reduce([]) do |memo, val|
                    if val.is_a?(Numeric)
                      plat = descendant_plats[val]
        Severity: Minor
        Found in lib/field_mapper/standard/plat.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

        Avoid deeply nested control flow statements.
        Open

                            if history[oid].nil?
                              history[oid] = true
                              val.to_hash(
                                flatten: flatten,
                                history: history,
        Severity: Major
        Found in lib/field_mapper/standard/plat.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            value = marshal(value) if flatten
          Severity: Major
          Found in lib/field_mapper/standard/plat.rb - About 45 mins to fix

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

                  def add_pending_assignment_for_plat(field, value)
                    pending_assignments << lambda do |descendant_plats|
                      if value.is_a?(Numeric)
                        plat = descendant_plats[value]
                        assign_param field.name, plat unless plat.nil?
            Severity: Minor
            Found in lib/field_mapper/standard/plat.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

            There are no issues that match your filters.

            Category
            Status