fatfreecrm/fat_free_crm

View on GitHub

Showing 75 of 90 total issues

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

  def web_presence_icons(person)
    %i[blog linkedin facebook twitter skype].map do |site|
      url = person.send(site)
      next if url.blank?

Severity: Minor
Found in app/helpers/application_helper.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 from_array has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.from_array(items = [])
      return '' if items.empty?

      # Infer column types from the first item in the array
      klass = items.first.class
Severity: Minor
Found in lib/fat_free_crm/export_csv.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 brief_account_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def brief_account_info(contact)
    text = ""
    title = contact.title
    department = contact.department
    account = contact.account
Severity: Minor
Found in app/helpers/accounts_helper.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 activity_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def activity_user
    return nil if current_user.pref[:activity_user] == "all_users"
    return nil unless current_user.pref[:activity_user]

    is_email = current_user.pref[:activity_user].include?("@")
Severity: Minor
Found in app/controllers/home_controller.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_with_account_and_permissions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def save_with_account_and_permissions(params)
    # Quick sanitization, makes sure Account will not search for blank id.
    params[:account].delete(:id) if params[:account][:id].blank?
    account = Account.create_or_select_for(self, params[:account])
    self.account_opportunity = AccountOpportunity.new(account: account, opportunity: self) unless account.id.blank?
Severity: Minor
Found in app/models/entities/opportunity.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 account_with_title_and_department has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def account_with_title_and_department(contact)
    text = if !contact.title.blank? && contact.account
             # works_at: "{{h(job_title)}} at {{h(company)}}"
             content_tag :div, t(:works_at, job_title: h(contact.title), company: h(account_with_url_for(contact))).html_safe
           elsif !contact.title.blank?
Severity: Minor
Found in app/helpers/accounts_helper.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 connect! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def connect!(options = {})
        log "connecting & logging in to #{@settings[:server]}..."
        @imap = Net::IMAP.new(@settings[:server], @settings[:port], @settings[:ssl])
        @imap.login(@settings[:user], @settings[:password])
        log "logged in to #{@settings[:server]}, checking folders..."
Severity: Minor
Found in lib/fat_free_crm/mail_processor/base.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_update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def after_update(item)
    original = @@opportunities.delete(item.id)
    if original
      if original.stage != "won" && item.stage == "won" # :other to :won -- add to total campaign revenue.
        update_campaign_revenue(item.campaign, item.amount.to_f - item.discount.to_f)
Severity: Minor
Found in app/models/observers/opportunity_observer.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 custom_validator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def custom_validator(obj)
    super
    # validate when we get to 2nd of the pair
    if pair_id.present?
      start = CustomFieldPair.find(pair_id)
Severity: Minor
Found in app/models/fields/custom_field_date_pair.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 performance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def performance(actual, target)
    if target.to_i.positive? && actual.to_i.positive?
      if target > actual
        n = 100 - actual * 100 / target
        html = content_tag(:span, "(-#{number_to_percentage(n, precision: 1)})", class: "warn")
Severity: Minor
Found in app/helpers/campaigns_helper.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 contact_summary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def contact_summary(contact)
    summary = ['']
    summary << contact.title.titleize if contact.title?
    summary << contact.department if contact.department?
    summary.last += " #{t(:at)} #{contact.account.name}" if contact.account&.name?
Severity: Minor
Found in app/helpers/contacts_helper.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 log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def log(message, email = nil)
        unless %w[test cucumber].include?(Rails.env)
          klass = self.class.to_s.split("::").last
          klass << " [Dry Run]" if @dry_run
          puts "[#{Time.now.rfc822}] #{klass}: #{message}"
Severity: Minor
Found in lib/fat_free_crm/mail_processor/base.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    get_campaigns
    @comment_body = params[:comment_body]

    respond_with(@lead) do |_format|
Severity: Minor
Found in app/controllers/entities/leads_controller.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 redirection_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def redirection_url
    # Try to redirect somewhere sensible. Note: not all controllers have an index action
    if current_user.present?
      respond_to?(:index) && action_name != 'index' ? { action: 'index' } : root_url
    else
Severity: Minor
Found in app/controllers/application_controller.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 bucket_empty? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.bucket_empty?(bucket, user, view = "pending")
    return false if bucket.blank? || !ALLOWED_VIEWS.include?(view)
    return false unless Setting.task_bucket.map(&:to_s).include?(bucket.to_s)

    if view == "assigned"
Severity: Minor
Found in app/models/polymorphic/task.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