Linter fixes (many unrelated)

This commit is contained in:
James Mason 2018-02-23 00:41:19 -08:00
parent d40229a054
commit d040d9c6ab
No known key found for this signature in database
GPG key ID: 1B3951886C449023
20 changed files with 100 additions and 79 deletions

View file

@ -120,7 +120,15 @@ class Event < ApplicationRecord
@total_rating += vote.rating
end
@total = votes.size
@total_rating > 0 ? number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true) : 0
if @total_rating.positive?
number_with_precision(
@total_rating / @total.to_f,
precision: 2,
strip_insignificant_zeros: true
)
else
0
end
end
# get event speakers with the event sumbmitter at the first position
@ -310,7 +318,7 @@ class Event < ApplicationRecord
def before_end_of_conference
errors
.add(:created_at, "can't be after the conference end date!") if program.conference && program.conference.end_date &&
.add(:created_at, "can't be after the conference end date!") if program.conference&.end_date &&
(Date.today > program.conference.end_date)
end
@ -322,7 +330,7 @@ class Event < ApplicationRecord
# Allow only confirmed tracks that belong to the same program as the event
#
def valid_track
return unless track && track.program && program
return unless track&.program && program
errors.add(:track, 'is invalid') unless track.confirmed? && track.program == program
end