Merge pull request #1398 from BelieveC/EnableRedundantSelf
Enable Style/RedundantSelf Rubocop cop
This commit is contained in:
commit
8a19c52698
11 changed files with 48 additions and 60 deletions
|
|
@ -76,6 +76,10 @@ Style/HashSyntax:
|
||||||
Style/NilComparison:
|
Style/NilComparison:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
# Checks for redundant uses of self.
|
||||||
|
Style/RedundantSelf:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
# Use single quotes unless there's string interpolation
|
# Use single quotes unless there's string interpolation
|
||||||
Style/StringLiterals:
|
Style/StringLiterals:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
|
||||||
|
|
@ -527,22 +527,6 @@ Style/RedundantReturn:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'app/helpers/application_helper.rb'
|
- 'app/helpers/application_helper.rb'
|
||||||
|
|
||||||
# Offense count: 61
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/RedundantSelf:
|
|
||||||
Exclude:
|
|
||||||
- 'app/models/ahoy/program.rb'
|
|
||||||
- 'app/models/call_for_paper.rb'
|
|
||||||
- 'app/models/cfp.rb'
|
|
||||||
- 'app/models/comment.rb'
|
|
||||||
- 'app/models/conference.rb'
|
|
||||||
- 'app/models/event.rb'
|
|
||||||
- 'app/models/program.rb'
|
|
||||||
- 'app/models/question.rb'
|
|
||||||
- 'app/models/ticket.rb'
|
|
||||||
- 'app/models/user.rb'
|
|
||||||
- 'app/models/venue.rb'
|
|
||||||
|
|
||||||
# Offense count: 2
|
# Offense count: 2
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@ class Cfp < ActiveRecord::Base
|
||||||
# * +True+ -> If cfp dates is updated and all other parameters are set
|
# * +True+ -> If cfp dates is updated and all other parameters are set
|
||||||
# * +False+ -> Either cfp date is not updated or one or more parameter is not set
|
# * +False+ -> Either cfp date is not updated or one or more parameter is not set
|
||||||
def notify_on_cfp_date_update?
|
def notify_on_cfp_date_update?
|
||||||
!self.end_date.blank? && !self.start_date.blank?\
|
!end_date.blank? && !start_date.blank?\
|
||||||
&& (self.start_date_changed? || self.end_date_changed?)\
|
&& (start_date_changed? || end_date_changed?)\
|
||||||
&& self.program.conference.email_settings.send_on_cfp_dates_updated\
|
&& program.conference.email_settings.send_on_cfp_dates_updated\
|
||||||
&& !self.program.conference.email_settings.cfp_dates_updated_subject.blank?\
|
&& !program.conference.email_settings.cfp_dates_updated_subject.blank?\
|
||||||
&& !self.program.conference.email_settings.cfp_dates_updated_body.blank?
|
&& !program.conference.email_settings.cfp_dates_updated_body.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -51,7 +51,7 @@ class Cfp < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def remaining_days(date = Date.today)
|
def remaining_days(date = Date.today)
|
||||||
result = (self.end_date - date).to_i
|
result = (end_date - date).to_i
|
||||||
result > 0 ? result : 0
|
result > 0 ? result : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class Comment < ActiveRecord::Base
|
||||||
|
|
||||||
#helper method to check if a comment has children
|
#helper method to check if a comment has children
|
||||||
def has_children?
|
def has_children?
|
||||||
self.children.any?
|
children.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Helper class method to lookup all comments assigned
|
# Helper class method to lookup all comments assigned
|
||||||
|
|
|
||||||
|
|
@ -555,9 +555,9 @@ class Conference < ActiveRecord::Base
|
||||||
# * +True+ -> If conference is updated and all other parameters are set
|
# * +True+ -> If conference is updated and all other parameters are set
|
||||||
# * +False+ -> Either conference is not updated or one or more parameter is not set
|
# * +False+ -> Either conference is not updated or one or more parameter is not set
|
||||||
def notify_on_dates_changed?
|
def notify_on_dates_changed?
|
||||||
return false unless self.email_settings.send_on_conference_dates_updated
|
return false unless email_settings.send_on_conference_dates_updated
|
||||||
# do not notify unless one of the dates changed
|
# do not notify unless one of the dates changed
|
||||||
return false unless self.start_date_changed? || self.end_date_changed?
|
return false unless start_date_changed? || end_date_changed?
|
||||||
# do not notify unless the mail content is set up
|
# do not notify unless the mail content is set up
|
||||||
(!email_settings.conference_dates_updated_subject.blank? && !email_settings.conference_dates_updated_body.blank?)
|
(!email_settings.conference_dates_updated_subject.blank? && !email_settings.conference_dates_updated_body.blank?)
|
||||||
end
|
end
|
||||||
|
|
@ -569,9 +569,9 @@ class Conference < ActiveRecord::Base
|
||||||
# * +True+ -> If registration dates is updated and all other parameters are set
|
# * +True+ -> If registration dates is updated and all other parameters are set
|
||||||
# * +False+ -> Either registration date is not updated or one or more parameter is not set
|
# * +False+ -> Either registration date is not updated or one or more parameter is not set
|
||||||
def notify_on_registration_dates_changed?
|
def notify_on_registration_dates_changed?
|
||||||
return false unless self.email_settings.send_on_conference_registration_dates_updated
|
return false unless email_settings.send_on_conference_registration_dates_updated
|
||||||
# do not notify unless we allow a registration
|
# do not notify unless we allow a registration
|
||||||
return false unless self.registration_period
|
return false unless registration_period
|
||||||
# do not notify unless one of the dates changed
|
# do not notify unless one of the dates changed
|
||||||
return false unless registration_period.start_date_changed? || registration_period.end_date_changed?
|
return false unless registration_period.start_date_changed? || registration_period.end_date_changed?
|
||||||
# do not notify unless the mail content is set up
|
# do not notify unless the mail content is set up
|
||||||
|
|
@ -628,8 +628,8 @@ class Conference < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
after_create do
|
after_create do
|
||||||
self.create_contact
|
create_contact
|
||||||
self.create_program
|
create_program
|
||||||
create_roles
|
create_roles
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,12 +185,12 @@ class Event < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
begin
|
begin
|
||||||
if mail
|
if mail
|
||||||
self.send(transition,
|
send(transition,
|
||||||
send_mail: send_mail_param)
|
send_mail: send_mail_param)
|
||||||
else
|
else
|
||||||
self.send(transition)
|
send(transition)
|
||||||
end
|
end
|
||||||
self.save
|
save
|
||||||
rescue Transitions::InvalidTransition => e
|
rescue Transitions::InvalidTransition => e
|
||||||
alert = "Update state failed. #{e.message}"
|
alert = "Update state failed. #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
@ -210,12 +210,12 @@ class Event < ActiveRecord::Base
|
||||||
# Returns +Hash+
|
# Returns +Hash+
|
||||||
def progress_status
|
def progress_status
|
||||||
{
|
{
|
||||||
registered: self.program.conference.user_registered?(self.submitter),
|
registered: program.conference.user_registered?(submitter),
|
||||||
commercials: self.commercials.any?,
|
commercials: commercials.any?,
|
||||||
biography: !self.submitter.biography.blank?,
|
biography: !submitter.biography.blank?,
|
||||||
subtitle: !self.subtitle.blank?,
|
subtitle: !subtitle.blank?,
|
||||||
track: (!self.track.blank? unless self.program.tracks.empty?),
|
track: (!track.blank? unless program.tracks.empty?),
|
||||||
difficulty_level: !self.difficulty_level.blank?,
|
difficulty_level: !difficulty_level.blank?,
|
||||||
title: true,
|
title: true,
|
||||||
abstract: true
|
abstract: true
|
||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
|
|
@ -227,7 +227,7 @@ class Event < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +String+ -> Progress in Percent
|
# * +String+ -> Progress in Percent
|
||||||
def calculate_progress
|
def calculate_progress
|
||||||
result = self.progress_status
|
result = progress_status
|
||||||
(100 * result.values.count(true) / result.values.compact.count).to_s
|
(100 * result.values.count(true) / result.values.compact.count).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -280,8 +280,8 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
def set_week
|
def set_week
|
||||||
self.week = created_at.strftime('%W')
|
self.week = created_at.strftime('%W')
|
||||||
self.without_versioning do
|
without_versioning do
|
||||||
self.save!
|
save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ class Program < ActiveRecord::Base
|
||||||
# * +false+ -> If rating is not enabled
|
# * +false+ -> If rating is not enabled
|
||||||
# * +true+ -> If rating is enabled
|
# * +true+ -> If rating is enabled
|
||||||
def rating_enabled?
|
def rating_enabled?
|
||||||
self.rating && self.rating > 0
|
rating && rating > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -139,7 +139,7 @@ class Program < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def languages_list
|
def languages_list
|
||||||
self.languages.split(',').map {|l| ISO_639.find(l).english_name} if self.languages.present?
|
languages.split(',').map {|l| ISO_639.find(l).english_name} if languages.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -161,10 +161,10 @@ class Program < ActiveRecord::Base
|
||||||
def create_event_types
|
def create_event_types
|
||||||
EventType.create(title: 'Talk', length: 30, color: '#FF0000', description: 'Presentation in lecture format',
|
EventType.create(title: 'Talk', length: 30, color: '#FF0000', description: 'Presentation in lecture format',
|
||||||
minimum_abstract_length: 0,
|
minimum_abstract_length: 0,
|
||||||
maximum_abstract_length: 500, program_id: self.id)
|
maximum_abstract_length: 500, program_id: id)
|
||||||
EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice',
|
EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice',
|
||||||
minimum_abstract_length: 0,
|
minimum_abstract_length: 0,
|
||||||
maximum_abstract_length: 500, program_id: self.id)
|
maximum_abstract_length: 500, program_id: id)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -174,13 +174,13 @@ class Program < ActiveRecord::Base
|
||||||
def create_difficulty_levels
|
def create_difficulty_levels
|
||||||
DifficultyLevel.create(title: 'Easy',
|
DifficultyLevel.create(title: 'Easy',
|
||||||
description: 'Events are understandable for everyone without knowledge of the topic.',
|
description: 'Events are understandable for everyone without knowledge of the topic.',
|
||||||
color: '#70EF69', program_id: self.id)
|
color: '#70EF69', program_id: id)
|
||||||
DifficultyLevel.create(title: 'Medium',
|
DifficultyLevel.create(title: 'Medium',
|
||||||
description: 'Events require a basic understanding of the topic.',
|
description: 'Events require a basic understanding of the topic.',
|
||||||
color: '#EEEF69', program_id: self.id)
|
color: '#EEEF69', program_id: id)
|
||||||
DifficultyLevel.create(title: 'Hard',
|
DifficultyLevel.create(title: 'Hard',
|
||||||
description: 'Events require expert knowledge of the topic.',
|
description: 'Events require expert knowledge of the topic.',
|
||||||
color: '#EF6E69', program_id: self.id)
|
color: '#EF6E69', program_id: id)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -188,12 +188,12 @@ class Program < ActiveRecord::Base
|
||||||
# Check if languages string has the right format. Used as validation.
|
# Check if languages string has the right format. Used as validation.
|
||||||
#
|
#
|
||||||
def check_languages_format
|
def check_languages_format
|
||||||
return unless self.languages.present?
|
return unless languages.present?
|
||||||
# All white spaces are removed to allow languages to be separated by ',' and ', '. The languages string without spaces is saved
|
# All white spaces are removed to allow languages to be separated by ',' and ', '. The languages string without spaces is saved
|
||||||
self.languages = self.languages.delete(' ').downcase
|
self.languages = languages.delete(' ').downcase
|
||||||
errors.add(:languages, 'must be two letters separated by commas') && return unless
|
errors.add(:languages, 'must be two letters separated by commas') && return unless
|
||||||
self.languages.match(/^$|(\A[a-z][a-z](,[a-z][a-z])*\z)/).present?
|
languages.match(/^$|(\A[a-z][a-z](,[a-z][a-z])*\z)/).present?
|
||||||
languages_array = self.languages.split(',')
|
languages_array = languages.split(',')
|
||||||
# We check that languages are not repeated
|
# We check that languages are not repeated
|
||||||
errors.add(:languages, "can't be repeated") && return unless languages_array.uniq!.nil?
|
errors.add(:languages, "can't be repeated") && return unless languages_array.uniq!.nil?
|
||||||
# We check if every language is a valid ISO 639-1 language
|
# We check if every language is a valid ISO 639-1 language
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,6 @@ class Question < ActiveRecord::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def existing_answers
|
def existing_answers
|
||||||
errors.add(:base, 'Must have answers') if self.answers.blank?
|
errors.add(:base, 'Must have answers') if answers.blank?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class Ticket < ActiveRecord::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def tickets_of_conference_have_same_currency
|
def tickets_of_conference_have_same_currency
|
||||||
unless Ticket.where(conference_id: conference_id).all?{|t| t.price_currency == self.price_currency }
|
unless Ticket.where(conference_id: conference_id).all?{|t| t.price_currency == price_currency }
|
||||||
errors.add(:price_currency, 'is different from the existing tickets of this conference.')
|
errors.add(:price_currency, 'is different from the existing tickets of this conference.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class User < ActiveRecord::Base
|
||||||
# * +true+ if the user attended the event
|
# * +true+ if the user attended the event
|
||||||
# * +false+ if the user did not attend the event
|
# * +false+ if the user did not attend the event
|
||||||
def attended_event? event
|
def attended_event? event
|
||||||
event_registration = event.events_registrations.find_by(registration: self.registrations)
|
event_registration = event.events_registrations.find_by(registration: registrations)
|
||||||
|
|
||||||
return false unless event_registration.present?
|
return false unless event_registration.present?
|
||||||
event_registration.attended
|
event_registration.attended
|
||||||
|
|
@ -91,7 +91,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscribed? conference
|
def subscribed? conference
|
||||||
self.subscriptions.find_by(conference_id: conference.id).present?
|
subscriptions.find_by(conference_id: conference.id).present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def supports? conference
|
def supports? conference
|
||||||
|
|
@ -206,8 +206,8 @@ class User < ActiveRecord::Base
|
||||||
# Check if biography has an allowed number of words. Used as validation.
|
# Check if biography has an allowed number of words. Used as validation.
|
||||||
#
|
#
|
||||||
def biography_limit
|
def biography_limit
|
||||||
if self.biography.present?
|
if biography.present?
|
||||||
errors.add(:biography, 'is limited to 150 words.') if self.biography.split.length > 150
|
errors.add(:biography, 'is limited to 150 words.') if biography.split.length > 150
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class Venue < ActiveRecord::Base
|
||||||
def notify_on_venue_changed?
|
def notify_on_venue_changed?
|
||||||
return false unless conference.try(:email_settings).try(:send_on_venue_updated)
|
return false unless conference.try(:email_settings).try(:send_on_venue_updated)
|
||||||
# do not notify unless the address changed
|
# do not notify unless the address changed
|
||||||
return false unless self.name_changed? || self.street_changed? || self.city_changed? || self.country_changed?
|
return false unless name_changed? || street_changed? || city_changed? || country_changed?
|
||||||
# do not notify unless the mail content is set up
|
# do not notify unless the mail content is set up
|
||||||
(!conference.email_settings.venue_updated_subject.blank? && !conference.email_settings.venue_updated_body.blank?)
|
(!conference.email_settings.venue_updated_subject.blank? && !conference.email_settings.venue_updated_body.blank?)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue