From 348ccf206ee245309d8e44855667f92c4fc06b7d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 21 Jun 2024 11:33:55 -0400 Subject: [PATCH] Fix `Style/ClassEqualityComparison` cop (#30058) --- .rubocop_todo.yml | 8 -------- app/helpers/jsonld_helper.rb | 2 +- app/serializers/activitypub/outbox_serializer.rb | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fb3a928d3..b05d1bc6b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -31,14 +31,6 @@ Rails/OutputSafety: Exclude: - 'config/initializers/simple_form.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedMethods, AllowedPatterns. -# AllowedMethods: ==, equal?, eql? -Style/ClassEqualityComparison: - Exclude: - - 'app/helpers/jsonld_helper.rb' - - 'app/serializers/activitypub/outbox_serializer.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedVars. Style/FetchEnvVar: diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb index b0f2077db..932a3420d 100644 --- a/app/helpers/jsonld_helper.rb +++ b/app/helpers/jsonld_helper.rb @@ -141,7 +141,7 @@ module JsonLdHelper def safe_for_forwarding?(original, compacted) original.without('@context', 'signature').all? do |key, value| compacted_value = compacted[key] - return false unless value.class == compacted_value.class + return false unless value.instance_of?(compacted_value.class) if value.is_a?(Hash) safe_for_forwarding?(value, compacted_value) diff --git a/app/serializers/activitypub/outbox_serializer.rb b/app/serializers/activitypub/outbox_serializer.rb index 4f4f950a5..4d3d9706d 100644 --- a/app/serializers/activitypub/outbox_serializer.rb +++ b/app/serializers/activitypub/outbox_serializer.rb @@ -2,7 +2,7 @@ class ActivityPub::OutboxSerializer < ActivityPub::CollectionSerializer def self.serializer_for(model, options) - if model.class.name == 'ActivityPub::ActivityPresenter' + if model.instance_of?(::ActivityPub::ActivityPresenter) ActivityPub::ActivitySerializer else super