Showing 76 of 91 total issues
Method get_users
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_users(options = {})
self.current_page = options[:page] if options[:page]
self.current_query = params[:query] if params[:query]
@search = klass.ransack(params[:q])
- 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 find_all_grouped
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.find_all_grouped(user, view)
return {} unless ALLOWED_VIEWS.include?(view)
settings = (view == "completed" ? Setting.task_completed : Setting.task_bucket)
Hash[
- 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 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?
- 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 link_to_email
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def link_to_email(email, length = nil, &_block)
name = (length ? truncate(email, length: length) : email)
bcc = Setting&.email_dropbox
mailto = if bcc && bcc[:address].present?
"#{email}?bcc=#{bcc[:address]}"
- 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 totals
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.totals(user, view = "pending")
return {} unless ALLOWED_VIEWS.include?(view)
settings = (view == "completed" ? Setting.task_completed : Setting.task_bucket)
settings.each_with_object(HashWithIndifferentAccess[all: 0]) do |key, hash|
- 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 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?("@")
- 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 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..."
- 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 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)
- 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 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"
- 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 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")
- 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 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
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def create
get_campaigns
@comment_body = params[:comment_body]
respond_with(@lead) do |_format|
- 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 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)
- 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 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}"
- 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 render
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def render(value)
case as
when 'checkbox'
value.to_s == '0' ? "no" : "yes"
when 'date'
- 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 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?
- 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"