Skip to content

Commit a158c7b

Browse files
committed
Upgrade Rubocop Ruby target version to 3.0
1 parent ec0e436 commit a158c7b

10 files changed

Lines changed: 27 additions & 32 deletions

File tree

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.4
2+
TargetRubyVersion: 3.0
33
NewCops: enable
44
Exclude:
55
- 'bin/*'

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
44

55
gemspec
66

7+
gem 'jwt', '~> 2.2'
8+
gem 'rake', '~> 13.0'
9+
gem 'rspec', '~> 3.0'
10+
gem 'webmock', '~> 3.18'
11+
712
gem 'guard-rspec', '~> 4.7'
813
gem 'guard-rubocop', '~> 1.3'
914
gem 'rubocop', '~> 1.45'

lib/userlist/config.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ def respond_to_missing?(name, include_private = false)
7575
key?(name.to_sym) || super
7676
end
7777

78-
def method_missing(name, *args, &block)
78+
def method_missing(name, ...)
7979
if respond_to_missing?(name)
8080
name = name.to_s
8181
method = name =~ /=$/ ? :[]= : :[]
8282
name = name.sub(/=$/, '').to_sym
83-
send(method, name, *args, &block)
83+
send(method, name, ...)
8484
else
8585
super
8686
end

lib/userlist/push/strategies/active_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def call(*args)
2727
def options
2828
@options ||= begin
2929
options = config.push_strategy_options || {}
30-
options.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
30+
options.transform_keys(&:to_sym)
3131
end
3232
end
3333

lib/userlist/push/strategies/sidekiq.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def call(*args)
2525
def options
2626
@options ||= begin
2727
options = config.push_strategy_options || {}
28-
options.each_with_object({}) { |(k, v), h| h[k.to_s] = v }
28+
options.transform_keys(&:to_s)
2929
end
3030
end
3131

lib/userlist/push/strategies/threaded/worker.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ def run
1818
logger.info 'Starting worker thread...'
1919

2020
loop do
21-
begin
22-
method, *args = *queue.pop
23-
break if method == :stop
24-
25-
retryable.attempt { client.public_send(method, *args) }
26-
rescue StandardError => e
27-
logger.error "Failed to deliver payload: [#{e.class.name}] #{e.message}"
28-
end
21+
method, *args = *queue.pop
22+
break if method == :stop
23+
24+
retryable.attempt { client.public_send(method, *args) }
25+
rescue StandardError => e
26+
logger.error "Failed to deliver payload: [#{e.class.name}] #{e.message}"
2927
end
3028

3129
logger.info "Worker thread exited with #{queue.size} tasks still in the queue..."

lib/userlist/retryable.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,15 @@ def retry?(value)
3333

3434
def attempt
3535
(0..@retries).each do |attempt|
36-
begin
37-
if attempt.positive?
38-
milliseconds = delay(attempt)
39-
logger.debug "Retrying in #{milliseconds}ms, #{@retries - attempt} retries left"
40-
sleep(milliseconds / 1000.0)
41-
end
42-
43-
return yield
44-
rescue Userlist::Error => e
45-
raise e unless retry?(e)
36+
if attempt.positive?
37+
milliseconds = delay(attempt)
38+
logger.debug "Retrying in #{milliseconds}ms, #{@retries - attempt} retries left"
39+
sleep(milliseconds / 1000.0)
4640
end
41+
42+
return yield
43+
rescue Userlist::Error => e
44+
raise e unless retry?(e)
4745
end
4846

4947
logger.debug 'Retries exhausted, giving up'

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'bundler/setup'
22
require 'userlist'
33

4-
Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each { |f| require f }
4+
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
55

66
RSpec.configure do |config|
77
# Enable flags like --only-failures and --next-failure

spec/userlist/push/event_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113

114114
context 'when there is a legacy occured_at property' do
115115
let(:payload) do
116-
super().merge(occured_at: timestamp )
116+
super().merge(occured_at: timestamp)
117117
end
118118

119119
let(:timestamp) { Time.parse('2018-01-01T00:00:00Z') }

userlist.gemspec

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ Gem::Specification.new do |spec|
1919
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2020
spec.require_paths = ['lib']
2121

22-
spec.required_ruby_version = '>= 2.4'
23-
24-
spec.add_development_dependency 'bundler', '>= 1.15'
25-
spec.add_development_dependency 'jwt', '~> 2.2'
26-
spec.add_development_dependency 'rake', '~> 13.0'
27-
spec.add_development_dependency 'rspec', '~> 3.0'
28-
spec.add_development_dependency 'webmock', '~> 3.18'
22+
spec.required_ruby_version = '>= 3.0'
2923

3024
spec.metadata = { 'rubygems_mfa_required' => 'true' }
3125
end

0 commit comments

Comments
 (0)