mattbeedle/capsule_crm

View on GitHub

Showing 9 of 9 total issues

Method attributes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def attributes
      object.attributes.dup.tap do |attrs|
        attrs.each do |key, value|
          attrs[key] = value.to_s(:db) if value.is_a?(Date)
          if value.is_a?(DateTime)
Severity: Minor
Found in lib/capsule_crm/serializer.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

Method belongs_to has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def belongs_to(association_name, options = {})
          association = CapsuleCRM::Associations::BelongsToAssociation
            .new(association_name, self, options)
          associations[association_name] = association

Severity: Minor
Found in lib/capsule_crm/associations/belongs_to.rb - About 1 hr to fix

    Method normalize_subclass_collection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def normalize_subclass_collection(attrs)
          [].tap do |objects|
            attrs[collection_root.to_s].each do |key, value|
              next unless klass.child_classes.keys.include?(key)
              if value.is_a?(Hash)
    Severity: Minor
    Found in lib/capsule_crm/normalizer.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 has_many has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def has_many(association_name, options = {})
              association = CapsuleCRM::Associations::HasManyAssociation.
                new(association_name, self, options)
              self.associations[association_name] = association
    
    
    Severity: Minor
    Found in lib/capsule_crm/associations/has_many.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(parent, target_klass, target, source, embedded)
    Severity: Minor
    Found in lib/capsule_crm/associations/has_many_proxy.rb - About 35 mins to fix

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

            def create!(attributes = {})
              record = build(attributes).tap do |r|
                record_not_saved(r) unless parent.persisted?
              end
              record if embedded? ? save! : record.save!
      Severity: Minor
      Found in lib/capsule_crm/associations/has_many_proxy.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def create(attributes = {})
              record = build(attributes).tap do |r|
                record_not_saved(r) unless parent.persisted?
              end
              record if embedded? ? save : record.save
      Severity: Minor
      Found in lib/capsule_crm/associations/has_many_proxy.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def save
              if valid?
                run_callbacks(:save) { new_record? ? create_record : update_record }
              else
                false
      Severity: Minor
      Found in lib/capsule_crm/persistence/persistable.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 belongs_to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def belongs_to(association_name, options = {})
                association = CapsuleCRM::Associations::BelongsToAssociation
                  .new(association_name, self, options)
                associations[association_name] = association
      
      
      Severity: Minor
      Found in lib/capsule_crm/associations/belongs_to.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

      Severity
      Category
      Status
      Source
      Language