Showing 257 of 469 total issues
Method send_single_mail
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def send_single_mail(locale: , to:, subject_key:, subject_params: {}, subject_prefix: '', subject_is_title: false, **options)
return if NoSpam::SPAM_REGEX.match?(to)
return if User::BOT_EMAILS.values.include?(to)
return if (to.end_with?("@example.com")) && (Rails.env.production?)
- 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 defaultValues
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
defaultValues() {
return {
parentId: null,
name: '',
description: '',
Method redeem
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.redeem(membership:, actor:, notify: true)
raise Membership::InvitationAlreadyUsed.new(membership) if membership.accepted_at
# so we want to accept all the pending invitations this person has been sent within this org
# and we dont want any surprises if they already have some memberships.
Method find
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.find(group_ids, query, limit, offset)
ids = []
ids.concat ActiveStorage::Attachment.joins(:blob).
joins("LEFT OUTER JOIN groups ON active_storage_attachments.record_type = 'Group' AND active_storage_attachments.record_id = groups.id").
where('groups.id IN (:group_ids)', group_ids: group_ids).
Method invite
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.invite(poll:, actor:, params:)
UserInviter.authorize!(
user_ids: params[:recipient_user_ids],
emails: params[:recipient_emails],
audience: params[:recipient_audience],
Function default
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function(options) {
let chain = Records.discussions.collection.chain();
chain = chain.find({discardedAt: null});
if (options.group) { chain = chain.find({groupId: { $in: options.group.organisationIds() }}); }
if (options.from) { chain = chain.find({lastActivityAt: { $gt: options.from }}); }
Method export
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.export(groups, group_name)
filename = export_filename_for(group_name)
ids = Hash.new { |hash, key| hash[key] = [] }
File.open(filename, 'w') do |file|
groups.each do |group|
Method initialize
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
super(user)
can [:create], ::Comment do |comment|
comment.discussion &&
Method fake_poll
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fake_poll(args = {})
names = option_names(args.delete(:option_count) || (2..7).to_a.sample)
closing_at = args[:wip] ? nil : 3.days.from_now
options = {
Function downcode
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
var downcode= function( slug )
{
Downcoder.Initialize() ;
var downcoded =""
var pieces = slug.match(Downcoder.regex);
- 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 actions
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
actions(poll, vm, event) {
if (!poll || !poll.config()) { return {}; }
return {
translate_poll: {
icon: 'mdi-translate',
- 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 add_events_complete
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_events_complete(collection)
ids = {discussion: [], comment: [], group: [], poll: []}.with_indifferent_access
Event.includes(:eventable).where(id: collection.map(&:id)).each do |e|
- 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 constructor
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
const defaults = {
parentId: null,
name: I18n.t('discussion.direct_thread'),
description: '',
Method update
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.update(poll:, params:, actor:)
actor.ability.authorize! :update, poll
UserInviter.authorize!(
user_ids: params[:recipient_user_ids],
Method payload
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def payload
@payload ||= {
version: Loomio::Version.current,
release: AppConfig.release,
systemNotice: ENV['LOOMIO_SYSTEM_NOTICE'],
Method default_templates
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.default_templates
AppConfig.poll_templates.map do |key, raw_attrs|
raw_attrs[:key] = key
attrs = {}
Method perform
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform
Discussion.where(template: true).each do |discussion|
template = DiscussionTemplate.new(discussion.slice(
:group_id,
:author_id,
Function constructor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
const defaults = {
id: null,
title: 'No thread',
description: '',
Function baseConstructor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
baseConstructor(recordStore) {
this.views = [];
this.missingIds = [];
this.fetchedIds = [];
Function defaultValues
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
defaultValues() {
return {
id: null,
key: null,
private: true,