Showing 267 of 502 total issues
Method update_model
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.update_model(model, tasks_data)
uids = tasks_data.map {|t| t[:uid] }
existing_uids = model.tasks.pluck(:uid)
new_uids = uids - existing_uids
removed_uids = existing_uids - uids
- 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 index
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def index
instantiate_collection do |collection|
if !@poll.anonymous && name = params[:name].presence
collection = collection.
joins('LEFT OUTER JOIN users on stances.participant_id = users.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 create
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create
@email_can_be_verified = email_can_be_verified?
self.resource = UserService.create(params: sign_up_params)
if !resource.errors.any?
save_detected_locale(resource)
- 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 bug_tunnel
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def bug_tunnel
raise "no sentry dsn" unless ENV['SENTRY_PUBLIC_DSN']
uri = URI(ENV['SENTRY_PUBLIC_DSN'])
known_host = uri.host
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def create
email = params[:user_email].strip
user = User.verified.find_by(email: email)
if !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 commit!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def commit!
@changed.each do |attribute|
case attribute
when 'is_visible_to_public'
if group.is_hidden_from_public?
- 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_stances
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.create_stances(poll:, actor:, user_ids: [], emails: [], audience: nil, include_actor: false)
existing_voter_ids = Stance.latest.where(poll_id: poll.id).pluck(:participant_id)
users = UserInviter.where_or_create!(
actor: actor,
- 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 deeply nested control flow statements. Open
if discussion = DiscussionService.create(discussion: Discussion.new(discussion_params(email)), actor: actor)
email.update(released: true) if discussion.persisted?
end
Method parse_tasks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_tasks(rich_text, author)
Nokogiri::HTML::fragment(rich_text).search('li[data-type="taskItem"]').map do |el|
identifiers = Nokogiri::HTML::fragment(el).
search("span[data-mention-id]").map do |el|
el['data-mention-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 redirect_to
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def redirect_to(url, opts = {})
return super unless url.is_a? String # GK: for now this override only covers cases where a string has been passed in, so it does not cover cases of a Hash or a Record being passed in
host = URI(url).host
if ENV['USE_VUE'] && Rails.env.development? && host == "localhost"
path = URI(url).path
- 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
Consider simplifying this complex logical expression. Open
if (model.poll && model.poll().id && model.poll().decidedVotersCount && model.poll().undecidedVotersCount) {
model.adminsInclude(user()) ||
(model.group().membersCanAnnounce && model.membersInclude(user()));
audiences.push('decided_voters');
}
Consider simplifying this complex logical expression. Open
if (model.poll && model.poll().id && model.poll().decidedVotersCount && model.poll().undecidedVotersCount) {
model.adminsInclude(user()) ||
(model.group().membersCanAnnounce && model.membersInclude(user()));
audiences.push('undecided_voters');
}
Method perform
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def perform(method, path, params, headers, options)
Method perform
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def perform(method, url, params, headers, options)
Method audience_users
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.audience_users(model, kind, actor, exclude_members = false, include_actor = false)
Method contact_message
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def contact_message(name, email, subject, body, details = {})
Function actions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
actions(discussion, vm) {
return {
make_a_copy: {
icon: 'mdi-content-copy',
name: 'templates.make_a_copy',
- 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 canAnnouncePoll
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
canAnnouncePoll(poll) {
user = Session.user();
if (poll.discardedAt) { return false; }
if (poll.groupId) {
return poll.group().adminsInclude(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
Function suggestedTitle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
suggestedTitle() {
const model = this.model();
if (!model) { return ''; }
if (model.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 avatar_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def avatar_url(size = 512)
if avatar_kind == 'uploaded' && (!uploaded_avatar.attached? or uploaded_avatar.attachment.nil?)
update_columns(avatar_kind: set_default_avatar_kind)
end
- 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"