File tree Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -590,11 +590,6 @@ Lint/EnsureReturn:
590
590
Exclude :
591
591
- ' lib/puppet/configurer.rb'
592
592
593
- Lint/HashCompareByIdentity :
594
- Exclude :
595
- - ' lib/puppet/pops/serialization/serializer.rb'
596
- - ' lib/puppet/pops/types/recursion_guard.rb'
597
-
598
593
# This cop supports safe auto-correction (--auto-correct).
599
594
# Configuration parameters: EnforcedStyle.
600
595
# SupportedStyles: standard_error, runtime_error
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class Serializer
16
16
# @option options [Boolean] :type_by_reference `true` if Object types are serialized by name only.
17
17
# @api public
18
18
def initialize ( writer , options = EMPTY_HASH )
19
+ # Hash#compare_by_identity is intentionally not used since we only need to map
20
+ # object ids to their size and we don't want to store entire objects in memory
19
21
@written = { }
20
22
@writer = writer
21
23
@options = options
@@ -37,7 +39,7 @@ def write(value)
37
39
when :default
38
40
@writer . write ( Extension ::Default ::INSTANCE )
39
41
else
40
- index = @written [ value . object_id ]
42
+ index = @written [ value . object_id ] # rubocop:disable Lint/HashCompareByIdentity
41
43
if index . nil?
42
44
write_tabulated_first_time ( value )
43
45
else
@@ -76,7 +78,7 @@ def start_object(attr_count)
76
78
end
77
79
78
80
def push_written ( value )
79
- @written [ value . object_id ] = @written . size
81
+ @written [ value . object_id ] = @written . size # rubocop:disable Lint/HashCompareByIdentity
80
82
end
81
83
82
84
# Write the start of a sensitive object
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ module Types
8
8
#
9
9
# All comparisons are made using the `object_id` of the instance rather than the instance itself.
10
10
#
11
+ # Hash#compare_by_identity is intentionally not used since we only need to keep
12
+ # track of object ids we've seen before, based on object_id, so we don't store
13
+ # entire objects in memory.
14
+ #
11
15
# @api private
12
16
class RecursionGuard
13
17
attr_reader :state
@@ -25,14 +29,14 @@ def initialize
25
29
# @param instance [Object] the instance to check
26
30
# @return [Integer] the resulting state
27
31
def recursive_this? ( instance )
28
- instance_variable_defined? ( :@recursive_this_map ) && @recursive_this_map . has_key? ( instance . object_id )
32
+ instance_variable_defined? ( :@recursive_this_map ) && @recursive_this_map . has_key? ( instance . object_id ) # rubocop:disable Lint/HashCompareByIdentity
29
33
end
30
34
31
35
# Checks if recursion was detected for the given argument in the 'that' context
32
36
# @param instance [Object] the instance to check
33
37
# @return [Integer] the resulting state
34
38
def recursive_that? ( instance )
35
- instance_variable_defined? ( :@recursive_that_map ) && @recursive_that_map . has_key? ( instance . object_id )
39
+ instance_variable_defined? ( :@recursive_that_map ) && @recursive_that_map . has_key? ( instance . object_id ) # rubocop:disable Lint/HashCompareByIdentity
36
40
end
37
41
38
42
# Add the given argument as 'this' invoke the given block with the resulting state
You can’t perform that action at this time.
0 commit comments