fatfreecrm/fat_free_crm

View on GitHub
lib/fat_free_crm/mail_processor/dropbox.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method attach has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def attach(email, asset, strip_first_line = false)
        # If 'sent_to' email cannot be found, default to Dropbox email address
        to = email.to.blank? ? @settings[:address] : email.to.join(", ")
        cc = email.cc.blank? ? nil : email.cc.join(", ")

Severity: Minor
Found in lib/fat_free_crm/mail_processor/dropbox.rb - About 1 hr to fix

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

          def find_or_create_and_attach(email, data)
            klass = data["Type"].constantize
    
            if data["Email"] && klass.new.respond_to?(:email)
              conditions = [
    Severity: Minor
    Found in lib/fat_free_crm/mail_processor/dropbox.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 default_values has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def default_values(klass, data)
            data = data.dup
            keyword = data.delete("Type").capitalize
    
            defaults = {
    Severity: Minor
    Found in lib/fat_free_crm/mail_processor/dropbox.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_or_create_and_attach has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def find_or_create_and_attach(email, data)
            klass = data["Type"].constantize
    
            if data["Email"] && klass.new.respond_to?(:email)
              conditions = [
    Severity: Minor
    Found in lib/fat_free_crm/mail_processor/dropbox.rb - About 1 hr to fix

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

            def attach(email, asset, strip_first_line = false)
              # If 'sent_to' email cannot be found, default to Dropbox email address
              to = email.to.blank? ? @settings[:address] : email.to.join(", ")
              cc = email.cc.blank? ? nil : email.cc.join(", ")
      
      
      Severity: Minor
      Found in lib/fat_free_crm/mail_processor/dropbox.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 with_recipients has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def with_recipients(email, _options = {})
              recipients = []
              recipients += email.to_addrs unless email.to.blank?
              recipients += email.cc_addrs unless email.cc.blank?
      
      
      Severity: Minor
      Found in lib/fat_free_crm/mail_processor/dropbox.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