Showing 83 of 151 total issues
Method toggle_user
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def toggle_user
user = User.find_by(email: user_params[:email])
state = user_params[:state]
url = if @track
Method calendar
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def calendar
respond_to do |format|
format.ics do
calendar = Icalendar::Calendar.new
Conference.all.each do |conf|
Method show
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@program = @conference.program || Program.new(conference_id: @conference.id)
# Overview and since last login information
@total_reg = @conference.registrations.count
Method show
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
event_schedules = @program.selected_event_schedules(
includes: [{ event: %i[event_type speakers submitter] }]
)
Method user_change_description
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def user_change_description(version)
if version.event == 'create'
link_to_user(version.item_id) + ' signed up'
elsif version.event == 'update'
if version.changeset.keys.include?('reset_password_sent_at')
- 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 reply
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def reply
unless can? :reply, @survey
redirect_to conference_survey_path(@conference, @survey), alert: 'This survey is currently closed'
return
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
Method signed_in_with_cfp_role
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def signed_in_with_cfp_role(user)
# ids of all the conferences for which the user has the 'cfp' role
conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)
can :show, Conference do |conf|
Method signed_in_with_track_organizer_role
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def signed_in_with_track_organizer_role(user)
# ids of all the conferences for which the user has the 'track organizer' role
conf_ids_for_track_organizer = Track.with_role(:track_organizer, user).joins(:program).pluck(:conference_id)
# ids of all the tracks for which the user has the 'track_organizer' role
track_ids_for_track_organizer = Track.with_role(:track_organizer, user).pluck(:id)
Function add
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
add: function (previous_parent, new_parent, event) {
event.appendTo(new_parent);
var event_schedule_id = event.attr("event_schedule_id");
var my_url = url;
var type = 'POST';
Method create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
@url = conference_program_proposals_path(@conference.short_title)
# We allow proposal submission and sign up on same page.
# If user is not signed in then first create new user and then sign them in
- 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 11 (exceeds 5 allowed). Consider refactoring. Open
def create
@registration = @conference.registrations.new(registration_params)
@user = if current_user.nil?
# @user needs to be set for devise/registrations/new_embedded
- 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 not_signed_in
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def not_signed_in
can [:index], Conference
can [:show], Conference do |conference|
conference.splashpage&.public == true
end
Method draw_second_square
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def draw_second_square
move_up 150
if @conference.picture?
conference_image = case @conference.picture.ticket.url[0, 4]
when 'http', 'ftp:' # CDNs
Method revert_attribute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def revert_attribute
if params[:attribute] && @version.changeset.reject{ |_, values| values[0].blank? && values[1].blank? }.keys.include?(params[:attribute])
if @version.item[params[:attribute]] == @version.changeset[params[:attribute]][0]
flash[:error] = 'The item is already in the state that you are trying to revert it back to'
- 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 total_price
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.total_price(conference, user, paid: false)
tickets = Ticket.where(conference_id: conference.id)
result = nil
begin
tickets.each do |ticket|
- 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 link_to_user
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def link_to_user(user_id)
return 'Someone (probably via the console)' unless user_id
user = User.find_by(id: user_id)
if 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 create
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@url = conference_program_proposals_path(@conference.short_title)
# We allow proposal submission and sign up on same page.
# If user is not signed in then first create new user and then sign them in
Method registration_change_description
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def registration_change_description(version)
if version.item_type == 'Registration'
user_id = current_or_last_object_state(version.item_type, version.item_id).user_id
elsif version.item_type == 'EventsRegistration'
registration_id = current_or_last_object_state(version.item_type, version.item_id).registration_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 check_languages_format
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check_languages_format
return unless languages.present?
# All white spaces are removed to allow languages to be separated by ',' and ', '. The languages string without spaces is saved
self.languages = languages.delete(' ').downcase
- 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 concurrent_events
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def concurrent_events(event)
return nil unless event.scheduled? && event.program.selected_event_schedules
event_schedule = event.program.selected_event_schedules.find { |es| es.event == event }
other_event_schedules = event.program.selected_event_schedules.reject { |other_event_schedule| other_event_schedule == event_schedule }
- 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"