fatfreecrm/fat_free_crm

View on GitHub

Showing 91 of 91 total issues

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 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

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 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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  def index
    @accounts = get_accounts(page: page_param, per_page: per_page_param)

    respond_with @accounts do |format|
      format.xls { render layout: 'header' }
Severity: Minor
Found in app/controllers/entities/accounts_controller.rb and 3 other locations - About 20 mins to fix
app/controllers/entities/campaigns_controller.rb on lines 13..18
app/controllers/entities/contacts_controller.rb on lines 13..18
app/controllers/entities/opportunities_controller.rb on lines 15..20

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  def index
    @contacts = get_contacts(page: page_param, per_page: per_page_param)

    respond_with @contacts do |format|
      format.xls { render layout: 'header' }
Severity: Minor
Found in app/controllers/entities/contacts_controller.rb and 3 other locations - About 20 mins to fix
app/controllers/entities/accounts_controller.rb on lines 13..18
app/controllers/entities/campaigns_controller.rb on lines 13..18
app/controllers/entities/opportunities_controller.rb on lines 15..20

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  def index
    @opportunities = get_opportunities(page: page_param, per_page: per_page_param)

    respond_with @opportunities do |format|
      format.xls { render layout: 'header' }
Severity: Minor
Found in app/controllers/entities/opportunities_controller.rb and 3 other locations - About 20 mins to fix
app/controllers/entities/accounts_controller.rb on lines 13..18
app/controllers/entities/campaigns_controller.rb on lines 13..18
app/controllers/entities/contacts_controller.rb on lines 13..18

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  def index
    @campaigns = get_campaigns(page: page_param, per_page: per_page_param)

    respond_with @campaigns do |format|
      format.xls { render layout: 'header' }
Severity: Minor
Found in app/controllers/entities/campaigns_controller.rb and 3 other locations - About 20 mins to fix
app/controllers/entities/accounts_controller.rb on lines 13..18
app/controllers/entities/contacts_controller.rb on lines 13..18
app/controllers/entities/opportunities_controller.rb on lines 15..20

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      def discard(uid)
        if @dry_run
          log "Not discarding message"
        else
          @imap.uid_copy(uid, @settings[:move_invalid_to_folder]) if @settings[:move_invalid_to_folder]
Severity: Minor
Found in lib/fat_free_crm/mail_processor/base.rb and 1 other location - About 20 mins to fix
lib/fat_free_crm/mail_processor/base.rb on lines 136..144

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      def archive(uid)
        if @dry_run
          log "Not archiving message"
        else
          @imap.uid_copy(uid, @settings[:move_to_folder]) if @settings[:move_to_folder]
Severity: Minor
Found in lib/fat_free_crm/mail_processor/base.rb and 1 other location - About 20 mins to fix
lib/fat_free_crm/mail_processor/base.rb on lines 124..132

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language