From 2177daeae92b77be6797ba8f2ab6ebe1e641e078 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sat, 18 Feb 2023 17:09:40 -0500 Subject: Autofix Rubocop Style/RedundantBegin (#23703) --- app/models/announcement.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'app/models/announcement.rb') diff --git a/app/models/announcement.rb b/app/models/announcement.rb index 4b2cb4c6d..898bf3efa 100644 --- a/app/models/announcement.rb +++ b/app/models/announcement.rb @@ -54,13 +54,11 @@ class Announcement < ApplicationRecord end def statuses - @statuses ||= begin - if status_ids.nil? - [] - else - Status.where(id: status_ids, visibility: [:public, :unlisted]) - end - end + @statuses ||= if status_ids.nil? + [] + else + Status.where(id: status_ids, visibility: [:public, :unlisted]) + end end def tags -- cgit From 9909b4b653d2f1cef662211a4b8e0b02cbb42fc1 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 20 Feb 2023 13:20:56 -0500 Subject: Autofix Rubocop Rails/WhereEquals (#23759) --- .rubocop_todo.yml | 7 ------- app/models/announcement.rb | 2 +- app/models/status.rb | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) (limited to 'app/models/announcement.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bb214a70b..2a272b095 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1916,13 +1916,6 @@ Rails/UnusedIgnoredColumns: - 'app/models/status_edit.rb' - 'app/models/user.rb' -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -Rails/WhereEquals: - Exclude: - - 'app/models/announcement.rb' - - 'app/models/status.rb' - # Offense count: 61 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. diff --git a/app/models/announcement.rb b/app/models/announcement.rb index 898bf3efa..339f5ae70 100644 --- a/app/models/announcement.rb +++ b/app/models/announcement.rb @@ -20,7 +20,7 @@ class Announcement < ApplicationRecord scope :unpublished, -> { where(published: false) } scope :published, -> { where(published: true) } - scope :without_muted, ->(account) { joins("LEFT OUTER JOIN announcement_mutes ON announcement_mutes.announcement_id = announcements.id AND announcement_mutes.account_id = #{account.id}").where('announcement_mutes.id IS NULL') } + scope :without_muted, ->(account) { joins("LEFT OUTER JOIN announcement_mutes ON announcement_mutes.announcement_id = announcements.id AND announcement_mutes.account_id = #{account.id}").where(announcement_mutes: { id: nil }) } scope :chronological, -> { order(Arel.sql('COALESCE(announcements.starts_at, announcements.scheduled_at, announcements.published_at, announcements.created_at) ASC')) } scope :reverse_chronological, -> { order(Arel.sql('COALESCE(announcements.starts_at, announcements.scheduled_at, announcements.published_at, announcements.created_at) DESC')) } diff --git a/app/models/status.rb b/app/models/status.rb index 2eb47d72c..e7ea191a8 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -95,7 +95,7 @@ class Status < ApplicationRecord scope :local, -> { where(local: true).or(where(uri: nil)) } scope :with_accounts, ->(ids) { where(id: ids).includes(:account) } scope :without_replies, -> { where('statuses.reply = FALSE OR statuses.in_reply_to_account_id = statuses.account_id') } - scope :without_reblogs, -> { where('statuses.reblog_of_id IS NULL') } + scope :without_reblogs, -> { where(statuses: { reblog_of_id: nil }) } scope :with_public_visibility, -> { where(visibility: :public) } scope :tagged_with, ->(tag_ids) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag_ids }) } scope :excluding_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced_at: nil }) } -- cgit