Add and apply Rails/WhereNot rubocop rule
We simplify the code a little bit, and make it more consistent since we were already using `where.not` in most places.
This commit is contained in:
@@ -325,6 +325,9 @@ Rails/UnknownEnv:
|
||||
Rails/Validation:
|
||||
Enabled: true
|
||||
|
||||
Rails/WhereNot:
|
||||
Enabled: true
|
||||
|
||||
RSpec/AroundBlock:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class Debate < ApplicationRecord
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :sort_by_recommendations, -> { order(cached_votes_total: :desc) }
|
||||
scope :last_week, -> { where("created_at >= ?", 7.days.ago) }
|
||||
scope :featured, -> { where("featured_at is not null") }
|
||||
scope :featured, -> { where.not(featured_at: nil) }
|
||||
scope :public_for_api, -> { all }
|
||||
|
||||
# Ahoy setup
|
||||
@@ -58,8 +58,7 @@ class Debate < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.recommendations(user)
|
||||
tagged_with(user.interests, any: true)
|
||||
.where("author_id != ?", user.id)
|
||||
tagged_with(user.interests, any: true).where.not(author_id: user.id)
|
||||
end
|
||||
|
||||
def searchable_translations_definitions
|
||||
|
||||
@@ -15,7 +15,7 @@ class Milestone < ApplicationRecord
|
||||
|
||||
scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) }
|
||||
scope :published, -> { where("publication_date <= ?", Date.current.end_of_day) }
|
||||
scope :with_status, -> { where("status_id IS NOT NULL") }
|
||||
scope :with_status, -> { where.not(status_id: nil) }
|
||||
|
||||
def self.title_max_length
|
||||
80
|
||||
|
||||
@@ -122,7 +122,7 @@ class Poll < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.not_voted_by(user)
|
||||
where("polls.id not in (?)", poll_ids_voted_by(user))
|
||||
where.not(id: poll_ids_voted_by(user))
|
||||
end
|
||||
|
||||
def self.poll_ids_voted_by(user)
|
||||
|
||||
@@ -106,7 +106,7 @@ class Proposal < ApplicationRecord
|
||||
|
||||
def self.recommendations(user)
|
||||
tagged_with(user.interests, any: true)
|
||||
.where("author_id != ?", user.id)
|
||||
.where.not(author_id: user.id)
|
||||
.unsuccessful
|
||||
.not_followed_by_user(user)
|
||||
.not_archived
|
||||
|
||||
@@ -2,7 +2,7 @@ class Verification::Management::ManagedUser
|
||||
include ActiveModel::Model
|
||||
|
||||
def self.find(document_type, document_number)
|
||||
User.where("document_number is not null").
|
||||
User.where.not(document_number: nil).
|
||||
find_or_initialize_by(document_type: document_type,
|
||||
document_number: document_number)
|
||||
end
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
section "Flagging Debates & Comments" do
|
||||
40.times do
|
||||
debate = Debate.all.sample
|
||||
flagger = User.where(["users.id <> ?", debate.author_id]).all.sample
|
||||
flagger = User.where.not(id: debate.author_id).all.sample
|
||||
Flag.flag(flagger, debate)
|
||||
end
|
||||
|
||||
40.times do
|
||||
comment = Comment.all.sample
|
||||
flagger = User.where(["users.id <> ?", comment.user_id]).all.sample
|
||||
flagger = User.where.not(id: comment.user_id).all.sample
|
||||
Flag.flag(flagger, comment)
|
||||
end
|
||||
|
||||
40.times do
|
||||
proposal = Proposal.all.sample
|
||||
flagger = User.where(["users.id <> ?", proposal.author_id]).all.sample
|
||||
flagger = User.where.not(id: proposal.author_id).all.sample
|
||||
Flag.flag(flagger, proposal)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user