diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 302c66a16..77f7e7073 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.59.0. +# using RuboCop version 1.60.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -70,21 +70,6 @@ Rails/UniqueValidationWithoutIndex: - 'app/models/identity.rb' - 'app/models/webauthn_credential.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: exists, where -Rails/WhereExists: - Exclude: - - 'app/controllers/activitypub/inboxes_controller.rb' - - 'app/controllers/admin/email_domain_blocks_controller.rb' - - 'app/policies/status_policy.rb' - - 'app/serializers/rest/announcement_serializer.rb' - - 'app/workers/move_worker.rb' - - 'spec/models/account_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/purge_domain_service_spec.rb' - - 'spec/services/unallow_domain_service_spec.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. # AllowedMethods: ==, equal?, eql? diff --git a/app/controllers/activitypub/inboxes_controller.rb b/app/controllers/activitypub/inboxes_controller.rb index 5ee85474e..ba85e0a72 100644 --- a/app/controllers/activitypub/inboxes_controller.rb +++ b/app/controllers/activitypub/inboxes_controller.rb @@ -24,7 +24,7 @@ class ActivityPub::InboxesController < ActivityPub::BaseController def unknown_affected_account? json = Oj.load(body, mode: :strict) - json.is_a?(Hash) && %w(Delete Update).include?(json['type']) && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.where(uri: json['actor']).exists? + json.is_a?(Hash) && %w(Delete Update).include?(json['type']) && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.exists?(uri: json['actor']) rescue Oj::ParseError false end diff --git a/app/controllers/admin/email_domain_blocks_controller.rb b/app/controllers/admin/email_domain_blocks_controller.rb index ff754bc0b..faa0a061a 100644 --- a/app/controllers/admin/email_domain_blocks_controller.rb +++ b/app/controllers/admin/email_domain_blocks_controller.rb @@ -38,7 +38,7 @@ module Admin log_action :create, @email_domain_block (@email_domain_block.other_domains || []).uniq.each do |domain| - next if EmailDomainBlock.where(domain: domain).exists? + next if EmailDomainBlock.exists?(domain: domain) other_email_domain_block = EmailDomainBlock.create!(domain: domain, allow_with_approval: @email_domain_block.allow_with_approval, parent: @email_domain_block) log_action :create, other_email_domain_block diff --git a/app/policies/status_policy.rb b/app/policies/status_policy.rb index 322d3aec5..540e26642 100644 --- a/app/policies/status_policy.rb +++ b/app/policies/status_policy.rb @@ -57,7 +57,7 @@ class StatusPolicy < ApplicationPolicy if record.mentions.loaded? record.mentions.any? { |mention| mention.account_id == current_account.id } else - record.mentions.where(account: current_account).exists? + record.mentions.exists?(account: current_account) end end diff --git a/app/serializers/rest/announcement_serializer.rb b/app/serializers/rest/announcement_serializer.rb index 23b2fa514..8cee27127 100644 --- a/app/serializers/rest/announcement_serializer.rb +++ b/app/serializers/rest/announcement_serializer.rb @@ -23,7 +23,7 @@ class REST::AnnouncementSerializer < ActiveModel::Serializer end def read - object.announcement_mutes.where(account: current_user.account).exists? + object.announcement_mutes.exists?(account: current_user.account) end def content diff --git a/app/workers/move_worker.rb b/app/workers/move_worker.rb index 73ae268be..a18f38556 100644 --- a/app/workers/move_worker.rb +++ b/app/workers/move_worker.rb @@ -123,7 +123,7 @@ class MoveWorker end def add_account_note_if_needed!(account, id) - unless AccountNote.where(account: account, target_account: @target_account).exists? + unless AccountNote.exists?(account: account, target_account: @target_account) text = I18n.with_locale(account.user&.locale.presence || I18n.default_locale) do I18n.t(id, acct: @source_account.acct) end diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index f4a2b8fec..63502c546 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -265,7 +265,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do anything ) - expect(Status.where(uri: 'https://example.com/users/bob/fake-status').exists?).to be false + expect(Status.exists?(uri: 'https://example.com/users/bob/fake-status')).to be false end end end