Add rubocop spacing rules

We were following these rules in most places; we just didn't define them
anywhere.
This commit is contained in:
Javi Martín
2019-06-22 18:11:23 +02:00
parent c7f64f8493
commit f9ed186909
264 changed files with 652 additions and 577 deletions

View File

@@ -19,14 +19,14 @@ class Poll
officer_assignments.voting_days.includes(booth_assignment: :poll).
map(&:booth_assignment).
map(&:poll).uniq.compact.
sort {|x, y| y.ends_at <=> x.ends_at}
sort { |x, y| y.ends_at <=> x.ends_at }
end
def final_days_assigned_polls
officer_assignments.final.includes(booth_assignment: :poll).
map(&:booth_assignment).
map(&:poll).uniq.compact.
sort {|x, y| y.ends_at <=> x.ends_at}
sort { |x, y| y.ends_at <=> x.ends_at }
end
def todays_booths

View File

@@ -18,10 +18,10 @@ class Poll
scope :by_officer_and_poll, ->(officer_id, poll_id) do
where("officer_id = ? AND poll_booth_assignments.poll_id = ?", officer_id, poll_id)
end
scope :by_officer, ->(officer){ where(officer_id: officer.id) }
scope :by_poll, ->(poll){ joins(:booth_assignment).where("poll_booth_assignments.poll_id" => poll.id) }
scope :by_booth, ->(booth){ joins(:booth_assignment).where("poll_booth_assignments.booth_id" => booth.id) }
scope :by_date, ->(date){ where(date: date) }
scope :by_officer, ->(officer) { where(officer_id: officer.id) }
scope :by_poll, ->(poll) { joins(:booth_assignment).where("poll_booth_assignments.poll_id" => poll.id) }
scope :by_booth, ->(booth) { joins(:booth_assignment).where("poll_booth_assignments.booth_id" => booth.id) }
scope :by_date, ->(date) { where(date: date) }
before_create :log_user_data

View File

@@ -33,7 +33,7 @@ class Poll::Question < ApplicationRecord
scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) }
scope :sort_for_list, -> { order("poll_questions.proposal_id IS NULL", :created_at)}
scope :sort_for_list, -> { order("poll_questions.proposal_id IS NULL", :created_at) }
scope :for_render, -> { includes(:author, :proposal) }
def self.search(params)

View File

@@ -76,12 +76,12 @@ class Poll::Question::Answer < ApplicationRecord
when "positive_negative_open"
answers = question.question_answers.visibles
.map { |a| count_positive_negative(a, true) - count_positive_negative(a, false) }
is_most_voted = answers.none? {|a| a > total_votes_positive_negative}
is_most_voted = answers.none? { |a| a > total_votes_positive_negative }
update(most_voted: is_most_voted)
when "prioritized"
answers = question.question_answers.visibles
.map { |a| Poll::Answer.where(question_id: a.question, answer: a.title).sum(:value) }
is_most_voted = answers.none? {|a| a > total_votes_prioritized}
is_most_voted = answers.none? { |a| a > total_votes_prioritized }
update(most_voted: is_most_voted)
else
for_only_votes
@@ -97,8 +97,8 @@ class Poll::Question::Answer < ApplicationRecord
def for_only_votes
answers = question.question_answers.visibles
.map {|a| Poll::Answer.where(question_id: a.question, answer: a.title).count}
is_most_voted = answers.none? {|a| a > total_votes}
.map { |a| Poll::Answer.where(question_id: a.question, answer: a.title).count }
is_most_voted = answers.none? { |a| a > total_votes }
update(most_voted: is_most_voted)
end

View File

@@ -7,7 +7,7 @@ class Poll::Recount < ApplicationRecord
belongs_to :officer_assignment
validates :author, presence: true
validates :origin, inclusion: {in: VALID_ORIGINS}
validates :origin, inclusion: { in: VALID_ORIGINS }
scope :web, -> { where(origin: "web") }
scope :booth, -> { where(origin: "booth") }