Apply Layout/SpaceInLambdaLiteral rubocop rule
I had mixed feelings about this rule, since I like spaces where
possible.
However, I changed my mind when I realized writing `->(thing) { }` was
similar to defining a method, and we don't have a space before the
parenthesis when defining a method.
This commit is contained in:
@@ -115,6 +115,9 @@ Layout/SpaceBeforeFirstArg:
|
|||||||
Layout/SpaceBeforeSemicolon:
|
Layout/SpaceBeforeSemicolon:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
Layout/SpaceInLambdaLiteral:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
Layout/SpaceInsideArrayLiteralBrackets:
|
Layout/SpaceInsideArrayLiteralBrackets:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class LocalCensusRecord < ApplicationRecord
|
|||||||
validates :postal_code, presence: true
|
validates :postal_code, presence: true
|
||||||
validates :document_number, uniqueness: { scope: :document_type }
|
validates :document_number, uniqueness: { scope: :document_type }
|
||||||
|
|
||||||
scope :search, -> (terms) { where("document_number ILIKE ?", "%#{terms}%") }
|
scope :search, ->(terms) { where("document_number ILIKE ?", "%#{terms}%") }
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Poll::PartialResult < ApplicationRecord
|
|||||||
validates :question, presence: true
|
validates :question, presence: true
|
||||||
validates :author, presence: true
|
validates :author, presence: true
|
||||||
validates :answer, presence: true
|
validates :answer, presence: true
|
||||||
validates :answer, inclusion: { in: -> (a) { a.question.possible_answers }},
|
validates :answer, inclusion: { in: ->(a) { a.question.possible_answers }},
|
||||||
unless: ->(a) { a.question.blank? }
|
unless: ->(a) { a.question.blank? }
|
||||||
validates :origin, inclusion: { in: VALID_ORIGINS }
|
validates :origin, inclusion: { in: VALID_ORIGINS }
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Poll::Question::Answer < ApplicationRecord
|
|||||||
validates_translation :title, presence: true
|
validates_translation :title, presence: true
|
||||||
validates :given_order, presence: true, uniqueness: { scope: :question_id }
|
validates :given_order, presence: true, uniqueness: { scope: :question_id }
|
||||||
|
|
||||||
scope :by_author, -> (author) { where(author: author) }
|
scope :by_author, ->(author) { where(author: author) }
|
||||||
|
|
||||||
scope :visibles, -> { where(hidden: false) }
|
scope :visibles, -> { where(hidden: false) }
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class User < ApplicationRecord
|
|||||||
string = "%#{search_string}%"
|
string = "%#{search_string}%"
|
||||||
where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", string, string, string)
|
where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", string, string, string)
|
||||||
end
|
end
|
||||||
scope :between_ages, -> (from, to) do
|
scope :between_ages, ->(from, to) do
|
||||||
where(
|
where(
|
||||||
"date_of_birth > ? AND date_of_birth < ?",
|
"date_of_birth > ? AND date_of_birth < ?",
|
||||||
to.years.ago.beginning_of_year,
|
to.years.ago.beginning_of_year,
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ class VotationSetAnswer < ApplicationRecord
|
|||||||
belongs_to :votation_type
|
belongs_to :votation_type
|
||||||
belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :votation_set_answers
|
belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :votation_set_answers
|
||||||
|
|
||||||
scope :by_author, -> (author) { where(author: author) }
|
scope :by_author, ->(author) { where(author: author) }
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user