Showing 25 of 52 total issues
Method execute_grouped_calculation
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def execute_grouped_calculation(operation, column_name, distinct) #:nodoc:
group_attrs = group_values
if group_attrs.first.respond_to?(:to_sym)
association = @klass._reflect_on_association(group_attrs.first)
- 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
Class Conference
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Conference < ApplicationRecord
include AutoCompleteUsername
has_attached_file :logo, styles: { medium: '300x80>', thumb: '75x20>' }
validates_attachment :logo,
Method execute_grouped_calculation
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute_grouped_calculation(operation, column_name, distinct) #:nodoc:
group_attrs = group_values
if group_attrs.first.respond_to?(:to_sym)
association = @klass._reflect_on_association(group_attrs.first)
Method update
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
resource_updated = update_resource(resource, account_update_params)
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def create
return render nothing: true, status: 503 if Rails.env == 'production'
build_resource(sign_up_params)
- 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 update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update
self.resource = resource_class.reset_password_by_token(resource_params)
if resource.errors.empty?
resource.unlock_access! if unlockable?(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 create
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@conference = Conference.new(new_conference_params)
page = @conference.pages.build(path: 'home')
track = @conference.tracks.build
audience_level = @conference.audience_levels.build
Method privileges
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def privileges
can(:manage, ::Reviewer, conference: { visible: true })
can(:read, 'organizer_sessions') do
@conference.visible?
end
Method translated_age_range
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def translated_age_range(a_birth_date)
return '' unless a_birth_date.respond_to?(:beginning_of_day)
date = a_birth_date.beginning_of_day
today = DateTime.current.beginning_of_day
- 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 privileges
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def privileges
can!(:create, Session) do
@conference.in_submission_phase? &&
(@conference.submission_limit.zero? || @user.sessions_for_conference(@conference).active.count < @conference.submission_limit)
end
Method validate_each
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, _value)
case record.outcome
when Outcome.find_by(title: 'outcomes.accept.title')
record.errors.add(attribute, :cant_accept) unless
record.session.try(:pending_confirmation?) ||
- 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_tag_keys
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def to_tag_keys(tag_list)
return nil if tag_list.blank?
tag_names = tag_list.split(/\s*,\s*/)
return nil if tag_names.empty?
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def index
conferences = Conference.all
length = conferences.map { |c| (c.submissions_deadline.to_date - c.submissions_open.to_date).to_i }.max
conf_distribution = conferences.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 create_third_reject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_third_reject(review)
return if in_early_review_phase?
return unless review.weak_reject? || review.strong_reject?
- 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 too many return
statements within this method. Open
return t('age_range.35_to_39') if today.advance(years: -40) < date
Avoid too many return
statements within this method. Open
return t('age_range.40_to_44') if today.advance(years: -45) < date
Avoid too many return
statements within this method. Open
return t('age_range.30_to_34') if today.advance(years: -35) < date
Avoid too many return
statements within this method. Open
return t('age_range.45_to_49') if today.advance(years: -50) < date
Avoid too many return
statements within this method. Open
return t('age_range.55_to_59') if today.advance(years: -60) < date
Avoid too many return
statements within this method. Open
return t('age_range.50_to_54') if today.advance(years: -55) < date