Showing 76 of 91 total issues
File application_helper.rb
has 384 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ApplicationHelper
def tabs(tabs = nil)
tabs ||= controller_path.match?(/admin/) ? FatFreeCRM::Tabs.admin : FatFreeCRM::Tabs.main
if tabs
@current_tab ||= tabs.first[:text] # Select first tab by default.
Method get_list_of_records
has a Cognitive Complexity of 22 (exceeds 5 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
- Read upRead up
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
Class ApplicationController
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_devise_parameters, if: :devise_controller?
before_action :authenticate_user!
Class EntitiesController
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class EntitiesController < ApplicationController
before_action :set_current_tab, only: %i[index show]
before_action :set_view, only: %i[index show redraw]
before_action :set_options, only: :index
Method create_for
has a Cognitive Complexity of 19 (exceeds 5 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],
- Read upRead up
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 task_summary
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def task_summary(task)
summary = [task.category.blank? ? t(:other) : t(task.category)]
if @view != "completed"
if @view == "pending" && task.user != current_user
summary << t(:task_from, task.user.full_name)
- Read upRead up
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 16 (exceeds 5 allowed). Consider refactoring. Open
def create
@comment_body = params[:comment_body]
respond_with(@opportunity) do |_format|
if @opportunity.save_with_account_and_permissions(params.permit!)
@opportunity.add_comment_by_user(@comment_body, current_user)
- Read upRead up
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 timeline
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def timeline
state = params[:state].to_s
if %w[Collapsed Expanded].include?(state)
if (model_type = params[:type].to_s).present?
if %w[comment email].include?(model_type)
- Read upRead up
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 view_buttons
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def view_buttons
views = FatFreeCRM::ViewFactory.views_for(controller: controller.controller_name,
action: show_or_index_action)
return nil unless views.size > 1
- Read upRead up
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 respond_to_destroy
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def respond_to_destroy(method)
if method == :ajax
if called_from_index_page?
get_data_for_sidebar
@opportunities = get_opportunities
- Read upRead up
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 links_to_export
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def links_to_export(action = :index)
token = current_user.authentication_token
url_params = { action: action }
url_params[:id] = params[:id] unless params[:id].blank?
url_params[:query] = params[:query] unless params[:query].blank?
- Read upRead up
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 13 (exceeds 5 allowed). Consider refactoring. Open
def create
@comment_body = params[:comment_body]
respond_with(@contact) do |_format|
if @contact.save_with_account_and_permissions(params.permit!)
@contact.add_comment_by_user(@comment_body, current_user)
- Read upRead up
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 respond_to_destroy
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def respond_to_destroy(method)
if method == :ajax
if called_from_index_page? # Called from Leads index.
get_data_for_sidebar
@leads = get_leads
- Read upRead up
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_revenue_message
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def opportunity_revenue_message(opportunity, detailed = false)
msg = []
won_or_lost = %w[won lost].include?(opportunity.stage)
msg << content_tag(:b, number_to_currency(opportunity.weighted_amount, precision: 0)) if opportunity.weighted_amount != 0
- Read upRead up
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 respond_to_destroy
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def respond_to_destroy(method)
if method == :ajax
if called_from_index_page?
@contacts = get_contacts
if @contacts.blank?
- Read upRead up
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 lead_summary
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def lead_summary(lead)
summary = []
summary << (lead.status ? t(lead.status) : t(:other))
if lead.company? && lead.title?
- Read upRead up
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 plain_text_body
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def plain_text_body(email)
# Extract all parts including nested
parts = if email.multipart?
email.parts.map { |p| p.multipart? ? p.parts : p }.flatten
else
- Read upRead up
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 36 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(", ")
Method new
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def new
@opportunity.attributes = { user: current_user, stage: Opportunity.default_stage, access: Setting.default_access, assigned_to: nil }
@account = Account.new(user: current_user, access: Setting.default_access)
@accounts = Account.my(current_user).order('name')
- Read upRead up
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
@view = view
@task = Task.tracked_by(current_user).find(params[:id])
@task_before_update = @task.dup
- Read upRead up
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"