fatfreecrm/fat_free_crm

View on GitHub

Showing 76 of 91 total issues

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

  def upload_avatar
    if params[:gravatar]
      @user.avatar = nil
      @user.save
      render
Severity: Minor
Found in app/controllers/users_controller.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 included has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def self.included(base)
        if base.instance_methods.include?(:assignee) || base.instance_methods.include?('assignee')
          define_method :assigned_to_full_name do
            user = assignee
            user ? user.full_name : ''
Severity: Minor
Found in lib/fat_free_crm/exportable.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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    respond_with(@opportunity) do |_format|
      if @opportunity.update_with_account_and_permissions(params.permit!)
        if called_from_index_page?
          get_data_for_sidebar
Severity: Minor
Found in app/controllers/entities/opportunities_controller.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 setup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def setup
        log "connecting to #{@settings[:server]}..."
        connect!(setup: true) || (return nil)
        log "logged in to #{@settings[:server]}, checking folders..."
        folders = [@settings[:scan_folder]]
Severity: Minor
Found in lib/fat_free_crm/mail_processor/base.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 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 update_sidebar has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def update_sidebar
    @view = view
    @task_total = Task.totals(current_user, @view)

    # Update filters session if we added, deleted, or completed a task.
Severity: Minor
Found in app/controllers/tasks_controller.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 with_new_emails has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def with_new_emails
        @imap.uid_search(%w[NOT SEEN]).each do |uid|
          begin
            email = Mail.new(@imap.uid_fetch(uid, 'RFC822').first.attr['RFC822'])
            log "fetched new message...", email
Severity: Minor
Found in lib/fat_free_crm/mail_processor/base.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 opportunity_closes_on_message has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def opportunity_closes_on_message(opportunity, won_or_lost)
    if opportunity.closes_on
      if won_or_lost
        if opportunity.closes_on >= Date.today
          t(:closing_date, l(opportunity.closes_on, format: :mmddyy))
Severity: Minor
Found in app/helpers/opportunities_helper.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 get_list_of_records has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_list_of_records(options = {})
        options[:query]  ||= params[:query]                        if params[:query]
        self.current_page  = options[:page]                        if options[:page]
        query, tags        = parse_query_and_tags(options[:query])
        self.current_query = query
    Severity: Minor
    Found in app/controllers/entities_controller.rb - About 1 hr to fix

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

        def show
          respond_with(@campaign) do |format|
            format.html do
              @stage = Setting.unroll(:opportunity_stage)
              @comment = Comment.new
      Severity: Minor
      Found in app/controllers/entities/campaigns_controller.rb - About 1 hr to fix

        Method create_for has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.create_for(model, account, opportunity, params)
            attributes = {
              lead_id:     model.id,
              user_id:     params[:account][:user_id] || account.user_id,
              assigned_to: params[:account][:assigned_to],
        Severity: Minor
        Found in app/models/entities/contact.rb - About 1 hr to fix

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

                def hook(method, caller, context = {}, &block)
          
                  # In a view template context, hooks are able to replace, append or prepend content.
                  if caller.is_a?(ActionView::Base)
                    hooks = FatFreeCRM::Callback.view_hook(method, caller, context)
          Severity: Minor
          Found in lib/fat_free_crm/callback.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 method_missing has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def method_missing(method_id, *args, &block)
                  if method_id.to_s.match?(/\Acf_.*[^=]\Z/)
                    # Refresh columns and try again.
                    self.class.reset_column_information
                    # If new record, create new object from class, else reload class
          Severity: Minor
          Found in lib/fat_free_crm/fields.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 create_for has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.create_for(model, account, params)
              opportunity = Opportunity.new(params)
          
              # Save the opportunity if its name was specified and account has no errors.
              if opportunity.name? && account.errors.empty?
          Severity: Minor
          Found in app/models/entities/opportunity.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 opportunity_summary has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def opportunity_summary(opportunity)
              summary = []
              amount = []
              summary << (opportunity.stage ? t(opportunity.stage) : t(:other))
              summary << number_to_currency(opportunity.weighted_amount, precision: 0)
          Severity: Minor
          Found in app/helpers/opportunities_helper.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 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 parse_version has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse_version(attr_name, change)
              if attr_name =~ /\Acf_/ && (field = CustomField.where(name: attr_name).first).present?
                label = field.label
                first = field.render(change.first)
                second = field.render(change.second)
          Severity: Minor
          Found in app/helpers/versions_helper.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 parse_query_and_tags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse_query_and_tags(search_string)
              return ['', ''] if search_string.blank?
          
              query = []
              tags = []
          Severity: Minor
          Found in app/controllers/entities_controller.rb - About 45 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