Showing 469 of 469 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
actorName() {
if (this.actor()) {
return this.actor().nameWithTitle(this.discussion().group());
} else {
return i18n.t('common.anonymous');
- 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 69.
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
participantName() {
if (this.participant()) {
return this.participant().nameWithTitle(this.poll().group());
} else {
return i18n.t('common.anonymous');
- 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 69.
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
Method poll_template_attributes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def poll_template_attributes
[
:key,
:group_id,
:position,
Function addAttributes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
addAttributes() {
return {
uid: {
default: Math.floor(Math.random() * 90000000),
parseHTML: element => ( parseInt(element.getAttribute('data-uid')) || Math.floor(Math.random() * 90000000) ),
Method theme
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.theme
brand_colors = {
gold: "#DCA034",
ink: "#293C4A",
Method invite
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.invite(group:, params:, actor:)
group_ids = if params[:invited_group_ids]
Array(params[:invited_group_ids])
else
Array(group.id)
Similar blocks of code found in 2 locations. Consider refactoring. Open
show_history: {
icon: 'mdi-history',
name: 'action_dock.show_edits',
dock: 1,
canPerform() { return discussion.edited(); },
- 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 68.
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
show_history: {
icon: 'mdi-history',
name: 'action_dock.show_edits',
dock: 1,
canPerform() { return outcome.edited(); },
- 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 68.
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
Method perform
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(user_id, actor_id)
user = User.find(user_id)
deactivated_at = DateTime.now
User.transaction do
Method is_rich_text
has 40 lines of code (exceeds 25 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'
Function defaultValues
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
defaultValues() {
return {
anonymous: false,
groupId: null,
title: '',
Method publish_event!
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.publish_event!(event_id)
event = Event.find(event_id)
event.reload
return if event.eventable.nil?
Method route
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.route(email)
return nil unless email.route_address
return nil if email.released
return nil if email.sender_hostname.downcase == ENV['REPLY_HOSTNAME'].downcase
return nil if email.sender_hostname.downcase == ENV['SMTP_DOMAIN'].downcase
Function audiencesFor
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
audiencesFor(model) {
const audiences = [];
if (model.discussion && model.discussion().id && model.discussion().membersCount) {
model.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
Method locate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def locate
return nil unless defined?(resource_class)
if model.to_sym == :user
resource_class.verified.find_by(username: params[:id] || params[:username]) || resource_class.friendly.find(params[:id] || params[:user_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 filter
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.filter(chain: , params: )
# how to do this....
if group = Group.find_by(key: params[:group_key])
group_ids = (params[:subgroups] == "none") ? [group.id] : group.id_and_subgroup_ids
chain = chain.where(group_id: group_ids)
- 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 history
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def history
notifications = {}
events = Event.where(kind: notification_kinds, id: target_event_ids).order('id desc').limit(1000)
- 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 actor_from_email_and_group
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.actor_from_email_and_group(email, group)
if actor = (email.dkim_valid || email.spf_valid) && User.find_by(email: email.sender_email)
return actor if group.members.exists?(actor.id)
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"
Further reading
Function constructor
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
this.makeAdmin = {
name: 'membership_dropdown.make_coordinator',
canPerform(dr) {
return !dr.discussion().group().adminsInclude(dr.user()) &&
Function render
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
render: () => {
return {
onStart: props => {
this.query = props.query.toLowerCase();
this.suggestionRange = props.range;