Skip to content

Commit 4a566f3

Browse files
committed
Lint/IdentityComparison
Use Object#equals? to check if 2 objects have the same identity. It returns false if two objects with different ids have the same values.
1 parent 8b4eeca commit 4a566f3

File tree

4 files changed

+3
-10
lines changed

4 files changed

+3
-10
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,13 +617,6 @@ Lint/HashCompareByIdentity:
617617
- 'lib/puppet/pops/serialization/serializer.rb'
618618
- 'lib/puppet/pops/types/recursion_guard.rb'
619619

620-
# This cop supports safe auto-correction (--auto-correct).
621-
Lint/IdentityComparison:
622-
Exclude:
623-
- 'lib/puppet/parser/resource.rb'
624-
- 'lib/puppet/ssl/verifier.rb'
625-
- 'lib/puppet/type.rb'
626-
627620
# This cop supports safe auto-correction (--auto-correct).
628621
# Configuration parameters: EnforcedStyle.
629622
# SupportedStyles: standard_error, runtime_error

lib/puppet/parser/resource.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def isomorphic?
156156
def merge(resource)
157157
# Test the resource scope, to make sure the resource is even allowed
158158
# to override.
159-
unless self.source.object_id == resource.source.object_id || resource.source.child_of?(self.source)
159+
unless self.source.equal?(resource.source) || resource.source.child_of?(self.source)
160160
raise Puppet::ParseError.new(_("Only subclasses can override parameters"), resource.file, resource.line)
161161
end
162162

lib/puppet/ssl/verifier.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def initialize(hostname, ssl_context)
3030
# @api private
3131
def reusable?(verifier)
3232
verifier.instance_of?(self.class) &&
33-
verifier.ssl_context.object_id == @ssl_context.object_id
33+
verifier.ssl_context.equal?(@ssl_context) # same object?
3434
end
3535

3636
# Configure the `http` connection based on the current `ssl_context`.

lib/puppet/type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ def properties_to_audit(list)
14171417
aliases.each do |other|
14181418
obj = @resource.catalog.resource(@resource.class.name, other)
14191419
if obj
1420-
unless obj.object_id == @resource.object_id
1420+
unless obj.equal?(@resource) # same object?
14211421
self.fail("#{@resource.title} can not create alias #{other}: object already exists")
14221422
end
14231423
next

0 commit comments

Comments
 (0)