Fix Style/ClassEqualityComparison cop (#30058)

This commit is contained in:
Matt Jankowski 2024-06-21 11:33:55 -04:00 committed by GitHub
parent 72484a194f
commit 348ccf206e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 2 additions and 10 deletions

View file

@ -31,14 +31,6 @@ Rails/OutputSafety:
Exclude: Exclude:
- 'config/initializers/simple_form.rb' - '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). # This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars. # Configuration parameters: AllowedVars.
Style/FetchEnvVar: Style/FetchEnvVar:

View file

@ -141,7 +141,7 @@ module JsonLdHelper
def safe_for_forwarding?(original, compacted) def safe_for_forwarding?(original, compacted)
original.without('@context', 'signature').all? do |key, value| original.without('@context', 'signature').all? do |key, value|
compacted_value = compacted[key] 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) if value.is_a?(Hash)
safe_for_forwarding?(value, compacted_value) safe_for_forwarding?(value, compacted_value)

View file

@ -2,7 +2,7 @@
class ActivityPub::OutboxSerializer < ActivityPub::CollectionSerializer class ActivityPub::OutboxSerializer < ActivityPub::CollectionSerializer
def self.serializer_for(model, options) def self.serializer_for(model, options)
if model.class.name == 'ActivityPub::ActivityPresenter' if model.instance_of?(::ActivityPub::ActivityPresenter)
ActivityPub::ActivitySerializer ActivityPub::ActivitySerializer
else else
super super