Add and apply EmptyLineAfterGuardClause rule

We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
This commit is contained in:
Javi Martín
2019-10-24 16:19:27 +02:00
parent db97f9d08c
commit d0d681a44b
69 changed files with 102 additions and 1 deletions

View File

@@ -63,6 +63,7 @@ class Poll::Question < ApplicationRecord
def self.answerable_by(user)
return none if user.nil? || user.unverified?
where(poll_id: Poll.answerable_by(user).pluck(:id))
end

View File

@@ -11,6 +11,7 @@ class Poll::Question::Answer::Video < ApplicationRecord
return if url.blank?
return if url.match(VIMEO_REGEX)
return if url.match(YOUTUBE_REGEX)
errors.add(:url, :invalid)
end
end

View File

@@ -21,6 +21,7 @@ class Poll::Recount < ApplicationRecord
[:white, :null, :total].each do |amount|
next unless send("#{amount}_amount_changed?") && send("#{amount}_amount_was").present?
self["#{amount}_amount_log"] += ":#{send("#{amount}_amount_was")}"
amounts_changed = true
end