hopsoft/field_mapper

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

Summary

Maintainability
B
6 hrs
Test Coverage

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 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

              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

      Avoid too many return statements within this method.
      Open

                return plat_instance_list(type, value) if type.plat_list?
      Severity: Major
      Found in lib/field_mapper/standard/field.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                when "Money"                        then return money(value)
        Severity: Major
        Found in lib/field_mapper/standard/field.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

                    when "FieldMapper::Types::Plat"     then return plat_instance(type, value)
            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 type.type.new(unmarshal(value)) if value.is_a?(String)
              Severity: Major
              Found in lib/field_mapper/standard/field.rb - About 30 mins to fix

                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

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

                        def plat_instance(type, value)
                          return value if value.is_a?(FieldMapper::Standard::Plat)
                          return value if value.is_a?(Numeric)
                          return value.to_i if value.is_a?(String) && value =~ /\A\d+\z/
                          return type.type.new(value) if value.is_a?(Hash)
                  Severity: Minor
                  Found in lib/field_mapper/standard/field.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