Skip to content

Commit 187cd63

Browse files
Merge branch 'master' into 3798
2 parents f9c35a6 + 9b51d53 commit 187cd63

35 files changed

+183
-293
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,12 @@
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 7
10-
# This cop supports safe autocorrection (--autocorrect).
11-
Layout/MultilineBlockLayout:
12-
Exclude:
13-
- 'lib/mongo/crypt/handle.rb'
14-
15-
# Offense count: 2
16-
# This cop supports safe autocorrection (--autocorrect).
17-
Layout/RescueEnsureAlignment:
18-
Exclude:
19-
- 'spec/mongo/collection/view/change_stream_spec.rb'
20-
- 'spec/mongo/collection/view/readable_spec.rb'
21-
22-
# Offense count: 8
23-
# This cop supports unsafe autocorrection (--autocorrect-all).
24-
# Configuration parameters: RequireParenthesesForMethodChains.
25-
Lint/AmbiguousRange:
26-
Exclude:
27-
- 'spec/integration/sdam_events_spec.rb'
28-
- 'spec/mongo/server/description/features_spec.rb'
29-
- 'spec/runners/unified.rb'
30-
319
# Offense count: 190
3210
# This cop supports unsafe autocorrection (--autocorrect-all).
3311
# Configuration parameters: AllowSafeAssignment.
3412
Lint/AssignmentInCondition:
3513
Enabled: false
3614

37-
# Offense count: 10
38-
# Configuration parameters: AllowedMethods.
39-
# AllowedMethods: enums
40-
Lint/ConstantDefinitionInBlock:
41-
Exclude:
42-
- 'spec/integration/heartbeat_events_spec.rb'
43-
- 'spec/mongo/id_spec.rb'
44-
- 'spec/mongo/operation/result_spec.rb'
45-
- 'spec/mongo/server/connection_spec.rb'
46-
- 'spec/spec_tests/sdam_spec.rb'
47-
4815
# Offense count: 16
4916
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
5017
Lint/DuplicateBranch:
@@ -63,56 +30,13 @@ Lint/DuplicateBranch:
6330
- 'spec/runners/sdam.rb'
6431
- 'spec/support/client_registry.rb'
6532

66-
# Offense count: 3
67-
Lint/DuplicateMethods:
68-
Exclude:
69-
- 'spec/runners/auth.rb'
70-
- 'spec/runners/cmap.rb'
71-
- 'spec/support/spec_config.rb'
72-
73-
# Offense count: 8
74-
# Configuration parameters: AllowComments, AllowEmptyLambdas.
75-
Lint/EmptyBlock:
76-
Exclude:
77-
- 'spec/integration/cursor_memory_leak_spec.rb'
78-
- 'spec/mongo/auth/user_spec.rb'
79-
- 'spec/mongo/cursor_spec.rb'
80-
- 'spec/mongo/server/description_spec.rb'
81-
- 'spec/mongo/server/round_trip_time_calculator_spec.rb'
82-
- 'spec/mongo/uri/srv_protocol_spec.rb'
83-
84-
# Offense count: 3
85-
# This cop supports safe autocorrection (--autocorrect).
86-
# Configuration parameters: AllowComments.
87-
Lint/EmptyConditionalBody:
88-
Exclude:
89-
- 'spec/runners/transactions.rb'
90-
- 'spec/spec_tests/uri_options_spec.rb'
91-
9233
# Offense count: 4
9334
# This cop supports unsafe autocorrection (--autocorrect-all).
9435
Lint/IncompatibleIoSelectWithFiberScheduler:
9536
Exclude:
9637
- 'lib/mongo/socket/ssl.rb'
9738
- 'lib/mongo/socket/tcp.rb'
9839

99-
# Offense count: 7
100-
Lint/IneffectiveAccessModifier:
101-
Exclude:
102-
- 'lib/mongo/operation/shared/polymorphic_result.rb'
103-
- 'lib/mongo/protocol/message.rb'
104-
- 'lib/mongo/uri/options_mapper.rb'
105-
106-
# Offense count: 4
107-
# This cop supports unsafe autocorrection (--autocorrect-all).
108-
# Configuration parameters: EnforcedStyle.
109-
# SupportedStyles: standard_error, runtime_error
110-
Lint/InheritException:
111-
Exclude:
112-
- 'lib/mongo/error/raise_original_error.rb'
113-
- 'spec/mongo/server/connection_spec.rb'
114-
- 'spec/mongo/socket_spec.rb'
115-
11640
# Offense count: 31
11741
# Configuration parameters: AllowedParentClasses.
11842
Lint/MissingSuper:
@@ -128,12 +52,6 @@ Lint/NextWithoutAccumulator:
12852
Exclude:
12953
- 'lib/mongo/operation/shared/result/aggregatable.rb'
13054

131-
# Offense count: 2
132-
Lint/NoReturnInBeginEndBlocks:
133-
Exclude:
134-
- 'lib/mongo/socket/ocsp_verifier.rb'
135-
- 'spec/runners/change_streams/test.rb'
136-
13755
# Offense count: 1
13856
Lint/NonLocalExitFromIterator:
13957
Exclude:

lib/mongo/cluster/reapers/cursor_reaper.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ def kill_cursors
177177
end
178178

179179
unless server
180-
# TODO: We currently don't have a server for the address that the
181-
# cursor is associated with. We should leave the cursor in the
182-
# queue to be killed at a later time (when the server comes back).
180+
# The server for this cursor has gone away --- maybe temporarily,
181+
# maybe permanently, but we can't know. To prevent connections from
182+
# leaking in the case of a permanent failure, we'll just silently
183+
# drop this killspec and move on.
183184
next
184185
end
185186

lib/mongo/cluster_time.rb

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module Mongo
2626
#
2727
# @api private
2828
class ClusterTime < BSON::Document
29+
include Comparable
30+
2931
def initialize(elements = nil)
3032
super
3133

@@ -62,25 +64,6 @@ def <=>(other)
6264
end
6365
end
6466

65-
# Older Rubies do not implement other logical operators through <=>.
66-
# TODO revise whether these methods are needed when
67-
# https://jira.mongodb.org/browse/RUBY-1622 is implemented.
68-
def >=(other)
69-
(self <=> other) != -1
70-
end
71-
72-
def >(other)
73-
(self <=> other) == 1
74-
end
75-
76-
def <=(other)
77-
(self <=> other) != 1
78-
end
79-
80-
def <(other)
81-
(self <=> other) == -1
82-
end
83-
8467
# Compares two ClusterTime instances by comparing their timestamps.
8568
def ==(other)
8669
if self['clusterTime'] && other['clusterTime'] &&

lib/mongo/crypt/handle.rb

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ def do_rsaes_pkcs_signature(key_binary_p, input_binary_p,
288288
# Every crypto binding ignores its first argument, which is an option
289289
# mongocrypt_ctx_t object and is not required to use crypto hooks.
290290
def set_crypto_hooks
291-
@aes_encrypt = proc do |_, key_binary_p, iv_binary_p, input_binary_p,
292-
output_binary_p, response_length_p, status_p|
291+
@aes_encrypt = proc do |_, key_binary_p, iv_binary_p, input_binary_p, output_binary_p, response_length_p, status_p|
293292
do_aes(
294293
key_binary_p,
295294
iv_binary_p,
@@ -300,8 +299,7 @@ def set_crypto_hooks
300299
)
301300
end
302301

303-
@aes_decrypt = proc do |_, key_binary_p, iv_binary_p, input_binary_p,
304-
output_binary_p, response_length_p, status_p|
302+
@aes_decrypt = proc do |_, key_binary_p, iv_binary_p, input_binary_p, output_binary_p, response_length_p, status_p|
305303
do_aes(
306304
key_binary_p,
307305
iv_binary_p,
@@ -319,13 +317,11 @@ def set_crypto_hooks
319317
end
320318
end
321319

322-
@hmac_sha_512 = proc do |_, key_binary_p, input_binary_p,
323-
output_binary_p, status_p|
320+
@hmac_sha_512 = proc do |_, key_binary_p, input_binary_p, output_binary_p, status_p|
324321
do_hmac_sha('SHA512', key_binary_p, input_binary_p, output_binary_p, status_p)
325322
end
326323

327-
@hmac_sha_256 = proc do |_, key_binary_p, input_binary_p,
328-
output_binary_p, status_p|
324+
@hmac_sha_256 = proc do |_, key_binary_p, input_binary_p, output_binary_p, status_p|
329325
do_hmac_sha('SHA256', key_binary_p, input_binary_p, output_binary_p, status_p)
330326
end
331327

@@ -347,8 +343,7 @@ def set_crypto_hooks
347343
@hmac_hash
348344
)
349345

350-
@aes_ctr_encrypt = proc do |_, key_binary_p, iv_binary_p, input_binary_p,
351-
output_binary_p, response_length_p, status_p|
346+
@aes_ctr_encrypt = proc do |_, key_binary_p, iv_binary_p, input_binary_p, output_binary_p, response_length_p, status_p|
352347
do_aes(
353348
key_binary_p,
354349
iv_binary_p,
@@ -360,8 +355,7 @@ def set_crypto_hooks
360355
)
361356
end
362357

363-
@aes_ctr_decrypt = proc do |_, key_binary_p, iv_binary_p, input_binary_p,
364-
output_binary_p, response_length_p, status_p|
358+
@aes_ctr_decrypt = proc do |_, key_binary_p, iv_binary_p, input_binary_p, output_binary_p, response_length_p, status_p|
365359
do_aes(
366360
key_binary_p,
367361
iv_binary_p,
@@ -380,8 +374,7 @@ def set_crypto_hooks
380374
@aes_ctr_decrypt
381375
)
382376

383-
@rsaes_pkcs_signature_cb = proc do |_, key_binary_p, input_binary_p,
384-
output_binary_p, status_p|
377+
@rsaes_pkcs_signature_cb = proc do |_, key_binary_p, input_binary_p, output_binary_p, status_p|
385378
do_rsaes_pkcs_signature(key_binary_p, input_binary_p, output_binary_p, status_p)
386379
end
387380

lib/mongo/error/raise_original_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Error
2424
# @note This class must not derive from Error.
2525
#
2626
# @api private
27-
class RaiseOriginalError < Exception
27+
class RaiseOriginalError < Exception # rubocop:disable Lint/InheritException
2828
end
2929
end
3030
end

lib/mongo/operation/result.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ class Result
104104
def initialize(replies, connection_description = nil, connection_global_id = nil, context: nil, connection: nil)
105105
@context = context
106106

107-
# TODO: older versions of MongoDB (2.4 and below?) could sometimes end
108-
# up with nil here, which indicated an unackowledged write. Is that
109-
# still the case? Can we simplify this?
110107
return unless replies
111108

112109
if replies.is_a?(Array)

lib/mongo/operation/shared/polymorphic_result.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ module Operation
2626
module PolymorphicResult
2727
include PolymorphicLookup
2828

29-
private
30-
3129
def self.included(base)
3230
base.extend ClassMethods
3331
end
3432

33+
private
34+
3535
module ClassMethods
3636
attr_accessor :result_class
3737
end

0 commit comments

Comments
 (0)