Showing 471 of 471 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
canMovePoll(poll) {
return (!poll.discussionId || !poll.discussion().closedAt) &&
!poll.discussionId && poll.adminsInclude(Session.user());
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 64.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function addLoadPositionKeyRule
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
addLoadPositionKeyRule(positionKey) {
this.loading = positionKey;
this.addRule({
name: "positionKey from url",
local: {
Function addProseMirrorPlugins
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
addProseMirrorPlugins() {
const attachFile = this.options.attachFile
const attachImageFile = this.options.attachImageFile
return [
uploadPlaceholderPlugin,
Method redeem
has 36 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.
Function groupPrivacyConfirm
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export var groupPrivacyConfirm = function(group) {
if (group.isNew()) { return ""; }
if (group.attributeIsModified('groupPrivacy')) {
if (group.privacyIsSecret()) {
- 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 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],
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).
Similar blocks of code found in 2 locations. Consider refactoring. Open
tags() {
return this.recordStore.tags.collection.chain().find({groupId: this.id}).simplesort('priority').data();
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 63.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
tagsByName() {
return this.recordStore.tags.collection.chain().find({groupId: this.id}).simplesort('name').data();
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 63.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
make_a_copy: {
icon: 'mdi-content-copy',
name: 'templates.make_a_copy',
menu: true,
canPerform() { return Session.user(); },
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 63.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
make_a_copy: {
icon: 'mdi-content-copy',
name: 'templates.make_a_copy',
menu: true,
canPerform() { return Session.user(); },
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 63.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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: '',