openjaf/cenit

View on GitHub
lib/mongoff/record.rb

Summary

Maintainability
F
3 days
Test Coverage

Method []= has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

    def []=(field, value)
      field = field.to_sym
      @changed = true
      @validated = false
      field = :_id if %w(id _id).include?(field.to_s)
Severity: Minor
Found in lib/mongoff/record.rb - About 1 day 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

File record.rb has 396 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Mongoff
  class Record
    include Savable
    include Destroyable
    include Edi::Filler
Severity: Minor
Found in lib/mongoff/record.rb - About 5 hrs to fix

    Class Record has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Record
        include Savable
        include Destroyable
        include Edi::Filler
        include Edi::Formatter
    Severity: Minor
    Found in lib/mongoff/record.rb - About 5 hrs to fix

      Method prepare_attributes has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          def prepare_attributes
            document[:_type] = orm_model.to_s if orm_model.type_polymorphic?
            @fields.each do |field, value|
              nested = (association = orm_model.associations[field]) && association.nested?
              if nested || document[field].nil?
      Severity: Minor
      Found in lib/mongoff/record.rb - About 3 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

      Method []= has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def []=(field, value)
            field = field.to_sym
            @changed = true
            @validated = false
            field = :_id if %w(id _id).include?(field.to_s)
      Severity: Major
      Found in lib/mongoff/record.rb - About 3 hrs to fix

        Method send has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def send(*args)
              name = args[0].to_s
              property_name = (assigning = name.end_with?('=')) ? name.chop : name
              if (method = orm_model.data_type.records_methods.detect { |alg| alg.name == name })
                args = args.dup
        Severity: Minor
        Found in lib/mongoff/record.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 set_not_new_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_not_new_record
              return unless new_record?
              self.new_record = false
              @fields.each do |field, value|
                next unless value && (association = orm_model.associations[field]) && association.nested?
        Severity: Minor
        Found in lib/mongoff/record.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 before_save_callbacks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def before_save_callbacks
              success = true
              if (data_type = (model = orm_model).data_type).records_model == model
                data_type.before_save_callbacks.each do |callback|
                  next unless success
        Severity: Minor
        Found in lib/mongoff/record.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(model, attributes = nil, new_record = true)
              @orm_model = model
              @document = BSON::Document.new
              @fields = {}
              @new_record = new_record || false
        Severity: Minor
        Found in lib/mongoff/record.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 after_save_callbacks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def after_save_callbacks
              success = true
              if (data_type = (model = orm_model).data_type).records_model == model
                data_type.after_save_callbacks.each do |callback|
                  next unless success
        Severity: Minor
        Found in lib/mongoff/record.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_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_s
              if orm_model
                case (template = orm_model.label_template)
                when String
                  template
        Severity: Minor
        Found in lib/mongoff/record.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

        There are no issues that match your filters.

        Category
        Status