Skip to content

Commit f171ec7

Browse files
authored
RUBY-3733 update rubocop (#3002)
* RUBY-3733 update rubocop * upload-api-docs snuck under the radar
1 parent f8b7ed5 commit f171ec7

File tree

8 files changed

+43
-23
lines changed

8 files changed

+43
-23
lines changed

.rubocop.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
require:
1+
plugins:
22
- rubocop-performance
33
- rubocop-rake
44
- rubocop-rspec
55

66
AllCops:
7-
TargetRubyVersion: 2.5
7+
TargetRubyVersion: 2.7
88
NewCops: enable
99
Exclude:
1010
- 'spec/shared/**/*'
@@ -51,6 +51,9 @@ Layout/SpaceInsideArrayLiteralBrackets:
5151
Layout/SpaceInsidePercentLiteralDelimiters:
5252
Enabled: false
5353

54+
Lint/UselessConstantScoping:
55+
Enabled: false
56+
5457
Metrics/ClassLength:
5558
Max: 200
5659

@@ -63,6 +66,9 @@ Metrics/MethodLength:
6366
Naming/MethodParameterName:
6467
AllowedNames: [ id, op ]
6568

69+
Naming/PredicateMethod:
70+
Enabled: false
71+
6672
RSpec/BeforeAfterAll:
6773
Enabled: false
6874

@@ -71,12 +77,24 @@ RSpec/BeforeAfterAll:
7177
RSpec/DescribeClass:
7278
Enabled: false
7379

80+
RSpec/Eq:
81+
Enabled: false
82+
7483
Style/FetchEnvVar:
7584
Enabled: false
7685

7786
RSpec/ImplicitExpect:
7887
EnforcedStyle: is_expected
7988

89+
RSpec/IncludeExamples:
90+
Enabled: false
91+
92+
RSpec/IndexedLet:
93+
Enabled: false
94+
95+
RSpec/ExpectInLet:
96+
Enabled: false
97+
8098
RSpec/MultipleExpectations:
8199
Enabled: false
82100

@@ -86,6 +104,9 @@ RSpec/MultipleMemoizedHelpers:
86104
RSpec/NestedGroups:
87105
Enabled: false
88106

107+
RSpec/ReceiveMessages:
108+
Enabled: false
109+
89110
Style/Documentation:
90111
Exclude:
91112
- 'spec/**/*'

gemfiles/standard.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def standard_dependencies
2929
gem 'yajl-ruby', platforms: :mri, require: false
3030
gem 'celluloid', platforms: :mri, require: false
3131

32-
gem 'rubocop', '~> 1.45.1'
33-
gem 'rubocop-performance', '~> 1.16.0'
34-
gem 'rubocop-rake', '~> 0.6.0'
35-
gem 'rubocop-rspec', '~> 2.18.1'
32+
gem 'rubocop', '~> 1.85.1'
33+
gem 'rubocop-performance', '~> 1.26.1'
34+
gem 'rubocop-rake', '~> 0.7.1'
35+
gem 'rubocop-rspec', '~> 3.9.0'
3636

3737
platform :mri do
3838
# Debugger for VSCode.

spec/integration/retryable_writes/retryable_writes.rb renamed to spec/integration/retryable_writes/retryable_writes_spec.rb

File renamed without changes.

spec/mongo/client_construction_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
# Client is created here.
7171
client
7272
end
73-
puts "client_construction_spec.rb: Cluster is: #{client.cluster.summary}"
7473

7574
# Because the first round of sdam waits for server statuses to change
7675
# rather than for server selection semaphore on the cluster which
@@ -2604,13 +2603,6 @@
26042603

26052604
new_client.cluster.next_primary
26062605

2607-
# Diagnostics
2608-
# rubocop:disable Style/IfUnlessModifier, Lint/Debugger
2609-
unless subscriber.started_events.empty?
2610-
p subscriber.started_events
2611-
end
2612-
# rubocop:enable Style/IfUnlessModifier, Lint/Debugger
2613-
26142606
expect(subscriber.started_events.length).to eq 0
26152607
expect(new_client.cluster.topology.class).not_to be Mongo::Cluster::Topology::Unknown
26162608
end

spec/mongo/server/connection_pool/generation_manager_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
it 'closes all pipes and removes them from the map' do
1818
expect(manager.pipe_fds(service_id: service_id).size).to eq(2)
1919

20-
manager.instance_variable_get(:@pipe_fds)[service_id].each do |_gen, (r, w)|
20+
manager.instance_variable_get(:@pipe_fds)[service_id].each_value do |(r, w)|
2121
expect(r).to receive(:close).and_call_original
2222
expect(w).to receive(:close).and_call_original
2323
end

spec/support/tracing.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module Tracing
4-
Error = Class.new(StandardError)
4+
class Error < StandardError; end
55

66
class Span
77
attr_reader :tracer, :name, :attributes, :with_parent, :kind, :finished, :nested

spec/support/utils.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ module Net
66
autoload :HTTP, 'net/http'
77
end
88

9+
# rubocop:disable Style/OneClassPerFile
910
module Utils
11+
# rubocop:enable Style/OneClassPerFile
12+
1013
extend self
1114

1215
# Used by #yamlify_command_events
@@ -212,7 +215,7 @@ def yamlify_command_events(events)
212215
# rubocop:disable Metrics
213216
def convert_operation_options(options)
214217
if options
215-
options.map do |k, v|
218+
options.filter_map do |k, v|
216219
out_v =
217220
case k
218221
when 'readPreference'
@@ -242,7 +245,7 @@ def convert_operation_options(options)
242245
# they mean is for the driver to use the default write concern,
243246
# which for Ruby means no write concern is specified at all.
244247
#
245-
# This nil return requires the compact call below to get rid of
248+
# This nil return requires the filter_map call above to get rid of
246249
# the nils before outgoing options are constructed.
247250
next nil if v == {}
248251

@@ -255,7 +258,7 @@ def convert_operation_options(options)
255258
raise "Unhandled operation option #{k}"
256259
end
257260
[ out_k, out_v ]
258-
end.compact.to_h
261+
end.to_h
259262
else
260263
{}
261264
end
@@ -429,11 +432,11 @@ def wait_for_instance_profile
429432
begin
430433
ip = ec2_instance_profile
431434
if ip
432-
puts "Instance profile assigned: #{ip}"
435+
warn "Instance profile assigned: #{ip}"
433436
break
434437
end
435438
rescue StandardError => e
436-
puts "Problem retrieving instance profile: #{e.class}: #{e}"
439+
warn "Problem retrieving instance profile: #{e.class}: #{e}"
437440
end
438441

439442
if Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline
@@ -450,11 +453,11 @@ def wait_for_no_instance_profile
450453
begin
451454
ip = ec2_instance_profile
452455
if ip.nil?
453-
puts 'Instance profile cleared'
456+
warn 'Instance profile cleared'
454457
break
455458
end
456459
rescue StandardError => e
457-
puts "Problem retrieving instance profile: #{e.class}: #{e}"
460+
warn "Problem retrieving instance profile: #{e.class}: #{e}"
458461
end
459462

460463
if Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline

upload-api-docs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env ruby
22
# frozen_string_literal: true
33

4+
# rubocop:disable Style/OneClassPerFile
5+
46
require 'bundler/inline'
57

68
gemfile true do
@@ -125,3 +127,5 @@ options = Options.new
125127
generate_docs(options)
126128
FileUploader.new(options).upload_docs
127129
return
130+
131+
# rubocop:enable Style/OneClassPerFile

0 commit comments

Comments
 (0)