Showing 267 of 502 total issues
Method is_rich_text
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def is_rich_text(on: [])
define_singleton_method :rich_text_fields, -> { Array on }
rich_text_fields.each do |field|
define_method "sanitize_#{field}!" do
# return if self.send("#{field}_format") == 'md'
- 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 reactions_per_country
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def reactions_per_country
queries = []
data = {}
queries.push <<~SQL
- 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 migrate_paperclip
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.migrate_paperclip
models = [Group, User, Discussion, Comment, Poll, Stance, Outcome, Document]
models.each do |model|
attachments = model.column_names.map do |c|
- 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 reactions_per_user
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def reactions_per_user
queries = []
data = {}
queries.push <<~SQL
- 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_csv
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_csv(opts={})
CSV.generate do |csv|
csv << ['poll']
csv << meta_table.keys
csv << meta_table.values
Function clonePoll
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
clonePoll() {
const clone = this.clone();
clone.id = null;
clone.key = null;
clone.sourceTemplateId = this.id;
Function constructor
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(recordsInterface, attributes) {
this.inCollection = this.inCollection.bind(this);
this.remove = this.remove.bind(this);
this.destroy = this.destroy.bind(this);
this.beforeDestroy = this.beforeDestroy.bind(this);
Method create
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
current_emails = User.active.where(id: group.memberships.pluck(:user_id)).pluck(:email)
params_emails = params.fetch(:emails, [])
add_emails = params_emails - current_emails
Method translate_group_content!
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.translate_group_content!(group, locale, cache_only = false)
return if locale == 'en'
translate_group_record(group, group, locale, cache_only)
Method browse
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def browse
if DiscussionTemplate.where(public: true).count == 0
DiscussionTemplateService.create_public_templates
end
Method accessible_records
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def accessible_records
load_and_authorize(:discussion)
records = Event.where(discussion_id: @discussion.id)
if %w[position_key sequence_id].include?(params[:order_by])
Function exact
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export var exact = function(date, zone, dateTimePref) {
if (zone == null) { zone = AppConfig.timeZone; }
if (dateTimePref == null) { ({
dateTimePref
} = Session.user()); }
Function groupPrivacy
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export var groupPrivacy = function(group, privacy) {
privacy = privacy || group.groupPrivacy;
if (group.isParent()) {
switch (privacy) {
Function addMetaData
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
addMetaData(collection) {
const positions = collection.map(e => e.event.position);
const ranges = RangeSet.arrayToRanges(positions);
const parentExists = collection[0] && collection[0].event && collection[0].event.parent();
const lastPosition = (parentExists && (collection[0].event.parent().childCount)) || 0;
Method poll_created_scenario
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def poll_created_scenario(params)
group = create_group_with_members
discussion = fake_discussion(group: group, title: "Some discussion")
DiscussionService.create(discussion: discussion, actor: group.members.first)
Method history
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def history
notifications = {}
events = Event.where(kind: notification_kinds, id: target_event_ids).order('id desc').limit(1000)
Function MentionPluginConfig
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export var MentionPluginConfig = function() {
// is called when a suggestion starts
return {
HTMLAttributes: {
class: 'mention'
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
def group_privacy=(term)
case term
when 'open'
self.is_visible_to_public = true
self.discussion_privacy_options = 'public_only'
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
actions(stance, vm, event) {
return {
react: {
dock: 1,
canPerform() {
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
actions(group) {
const membership = group.membershipFor(Session.user());
return {
email_group: {
- 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"