akretion/ooor

View on GitHub
lib/ooor/type_casting.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

    def cast_association(k)
      if self.class.one2many_associations[k]
        if @loaded_associations[k]
          v = @loaded_associations[k].select {|i| i.changed?}
          v = @associations[k] if v.empty?
Severity: Minor
Found in lib/ooor/type_casting.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 sanitize_association has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def sanitize_association(skey, value)
      if value.is_a?(Ooor::Base) || value.is_a?(Array) && value.all? {|i| i.is_a?(Ooor::Base)}
        value
      elsif value.is_a?(Array) && !self.class.many2one_associations.keys.index(skey)
        value.reject {|i| i == ''}.map {|i| i.is_a?(String) ? i.to_i : i}
Severity: Minor
Found in lib/ooor/type_casting.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 sanitize_attribute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def sanitize_attribute(skey, value)
      type = self.class.fields[skey]['type']
      if type == 'boolean' && (value == 1 || value == "1")
        true
      elsif type == 'boolean'&& (value == 0 || value == "0")
Severity: Minor
Found in lib/ooor/type_casting.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 value_to_openerp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def value_to_openerp(v)
        if v == nil || v == ""
          return false
        elsif !v.is_a?(Integer) && !v.is_a?(Float) && v.is_a?(Numeric) && v.respond_to?(:to_f)
          return v.to_f
Severity: Minor
Found in lib/ooor/type_casting.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 cast_o2m_association has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def cast_o2m_association(v)
      v.collect do |value|
        if value.is_a?(Base)
          if value.new_record?
            [0, 0, value.to_openerp_hash]
Severity: Minor
Found in lib/ooor/type_casting.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 too many return statements within this method.
Open

          return false
Severity: Major
Found in lib/ooor/type_casting.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return Base64.encode64(v.read())
    Severity: Major
    Found in lib/ooor/type_casting.rb - About 30 mins to fix

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

              def cast_map_to_ruby!(map)
                map.each do |k, v|
                  if self.t.fields[k] && v.is_a?(String) && !v.empty?
                    case self.t.fields[k]['type']
                    when 'datetime'
      Severity: Minor
      Found in lib/ooor/type_casting.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 cast_answer_to_ruby! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def cast_answer_to_ruby!(answer)
              def cast_map_to_ruby!(map)
                map.each do |k, v|
                  if self.t.fields[k] && v.is_a?(String) && !v.empty?
                    case self.t.fields[k]['type']
      Severity: Minor
      Found in lib/ooor/type_casting.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