Showing 267 of 502 total issues
Method notify_mentions!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def notify_mentions!
return unless eventable.newly_mentioned_users.any?
if eventable.respond_to?(:discussion) && eventable.discussion.present?
eventable.newly_mentioned_users.each do |guest|
if !eventable.group.members.exists?(guest.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
Function subtractRange
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
subtractRange(whole, part) {
if ((part.length === 0) || (part[0] > whole[1]) || (part[1] < whole[0])) { return [whole]; }
if ((part[0] <= whole[0]) && (part[1] >= whole[1])) { return []; }
if ((part[0] > whole[0]) && (part[1] < whole[1])) { return [[whole[0], part[0] - 1], [part[1] + 1, whole[1]]]; }
if ((part[0] === whole[0]) && (part[1] < whole[1])) { return [[part[1] + 1, whole[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 group_privacy
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def group_privacy
if is_visible_to_public?
self.public_discussions_only? ? 'open' : 'closed'
elsif parent_id && is_visible_to_parent_members?
'closed'
- 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 subtract_range
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.subtract_range(whole, part)
# examples
# read nothing
return [whole] if part.empty? || (part.first > whole.last) || (part.last < whole.first)
- 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 initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
super(user)
can :show, ::Membership do |membership|
membership.user_id == user.id || membership.group.admins.exists?(user.id) || membership.inviter_id == user.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 dump_i18n
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def dump_i18n
out = {}
[
:title,
:title_placeholder,
- 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 translate_group_record
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.translate_group_record(group, record, locale, cache_only = false, ignore: [])
translate_record = if source_record_id = group.info.dig('source_record_ids', "#{record.class.to_s}-#{record.id}")
record.class.find(source_record_id)
else
record
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def self.create(group:, actor: , skip_authorize: false)
actor.ability.authorize!(:create, group) unless skip_authorize
return false unless group.valid?
- 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 tracked_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def tracked_url(model, args = {})
args.merge!({utm_medium: 'email', utm_campaign: @event&.kind })
if model.is_a?(Poll) or model.is_a?(Outcome)
if stance = model.poll.stances.latest.find_by(participant: @recipient)
- 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 authorize!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.authorize!(user: LoggedOutUser.new, chain: start, params: )
discussion_ids = []
poll_ids = []
discussion_ids.concat(Comment.where(id: params[:comment_ids]).pluck(:discussion_id)) if params[:comment_ids]
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def self.create(model:, to:)
locale = locale_for_google(to)
translation = model.translations.find_by(language: locale) ||
Translation.new(translatable: model, language: locale, fields: {})
- 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 reply_to_address_with_group_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def reply_to_address_with_group_name(model:, user:)
return nil unless user.is_logged_in?
return nil unless model.respond_to?(:discussion) && model.discussion.present?
if model.discussion.group.present?
"\"#{I18n.transliterate(model.discussion.group.full_name).truncate(50).delete('"')}\" <#{reply_to_address(model: model, user: 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 rewrite_inline_images
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.rewrite_inline_images(host = nil)
ActiveStorage::Attachment.where(name: 'image_files').includes(:record).order('id desc').each do |attachment|
record = attachment.record
column_name = names[attachment.record_type]
next unless record[column_name].present?
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def self.update(stance: , actor: , params: )
actor.ability.authorize!(:update, stance)
is_update = !!stance.cast_at
new_stance = stance.build_replacement
- 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
Avoid too many return
statements within this function. Open
return this.findByKeys(q);
Avoid too many return
statements within this function. Open
return 'group_form.confirm_change_to_private_discussions_only';
Avoid too many return
statements within this function. Open
return this.findByIds(q);
Avoid too many return
statements within this function. Open
return chain.data();
Avoid too many return
statements within this function. Open
if ((part[0] > whole[0]) && (part[1] === whole[1])) { return [[whole[0], part[0] - 1]]; }
Avoid too many return
statements within this method. Open
return [[whole.first, part.first - 1]] if (part.first > whole.first) && (part.last == whole.last)