hopsoft/field_mapper

View on GitHub

Showing 29 of 29 total issues

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 standard_keys_to_custom_keys has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

                def standard_keys_to_custom_keys(standard_keyed_params)
                  standard_keyed_params.reduce({}) do |memo, standard_param|
                    key = standard_param.first
                    value = standard_param.last
                    field = fields_by_standard_name[key.to_sym]
        Severity: Minor
        Found in lib/field_mapper/custom/plat.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

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

            class Field
              include FieldMapper::Marshaller
        
              attr_reader(
                :name,
        Severity: Minor
        Found in lib/field_mapper/standard/field.rb - About 2 hrs to fix

          Method get_raw_custom_value has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def get_raw_custom_value(custom_field, raw_standard_value, custom_instance)
                  strategy = custom_field.flip_strategy(:standard_to_custom)
                  custom_flipper = custom_field.custom_flipper?(:standard_to_custom)
          
                  if !custom_flipper
          Severity: Minor
          Found in lib/field_mapper/standard/converter.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 get_raw_standard_value has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def get_raw_standard_value(custom_field, raw_custom_value, standard_instance)
                  strategy = custom_field.flip_strategy(:custom_to_standard)
                  custom_flipper = custom_field.custom_flipper?(:custom_to_standard)
          
                  if !custom_flipper
          Severity: Minor
          Found in lib/field_mapper/custom/converter.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 find_raw_standard_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def find_raw_standard_value(custom_field, raw_custom_value)
                  return raw_custom_value unless custom_field.standard_field.has_values?
          
                  if custom_field.has_values?
                    custom_value = custom_field.find_value(raw_custom_value)
          Severity: Minor
          Found in lib/field_mapper/custom/converter.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 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 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

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

            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

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

                    def cast_value(type, value, as_single_value: false)
                      return nil if value.nil?
                      case type.name
                      when "String"                       then return string(value)
                      when "FieldMapper::Types::Boolean"  then return boolean(value)
              Severity: Minor
              Found in lib/field_mapper/standard/field.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

              Avoid too many return statements within this method.
              Open

                      when "Integer"                      then return value.to_i
              Severity: Major
              Found in lib/field_mapper/standard/field.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return find_raw_standard_value(custom_field, raw_custom_value)
                Severity: Major
                Found in lib/field_mapper/custom/converter.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          when "Float"                        then return value.to_f
                  Severity: Major
                  Found in lib/field_mapper/standard/field.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return raw_standard_value.map do |single_raw_standard_value|
                                  find_raw_custom_value(custom_field, single_raw_standard_value)
                                end
                    Severity: Major
                    Found in lib/field_mapper/standard/converter.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                return cast_value(type.type, value) if as_single_value
                      Severity: Major
                      Found in lib/field_mapper/standard/field.rb - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language