Showing 259 of 471 total issues
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 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
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 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(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 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
Avoid too many return
statements within this function. Open
return 'discussion_edited';
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 method. Open
return parse(ranges) if ranges.is_a? String
Avoid too many return
statements within this function. Open
return 'group_form.subgroup_privacy_is_closed_description';
Avoid too many return
statements within this function. Open
return this.findByKeys(q);
Avoid too many return
statements within this function. Open
return this.findByIds(q);
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)
Avoid too many return
statements within this function. Open
return chain.data();
Avoid too many return
statements within this method. Open
return
Method poll_option_names=
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def poll_option_names=(names)
names = Array(names)
existing = Array(poll_options.pluck(:name))
names = names.sort if poll_type == 'meeting'
names.each_with_index do |name, priority|
- 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 pieSlices
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
pieSlices() {
let slices = [];
if ((this.pollType === 'count') && this.results.find(r => r.icon === 'agree')) {
const agree = this.results.find(r => r.icon === 'agree');
if (agree.score < this.agreeTarget) {
- 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 bestNamedId
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
bestNamedId() {
return ((this.id && this) || (this.pollId && this.poll()) || (this.groupId && this.group()) || {namedId() {}}).namedId();
}
- 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 to_ranges
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.to_ranges(ranges)
# ranges is supposed to be an array of ranges.
# but it's useful to support
# range set
return [] if ranges.nil?
- 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"