Skip to content

Commit 1fc5b3c

Browse files
committed
Enable rubocop-thread_safety plugin
1 parent e890d8d commit 1fc5b3c

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins:
22
- rubocop-performance
33
- rubocop-rake
44
- rubocop-rspec
5+
- rubocop-thread_safety
56

67
AllCops:
78
TargetRubyVersion: '3.2'

lib/minfraud.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
# for the gem's classes.
3333
module Minfraud
3434
class << self
35+
# rubocop:disable ThreadSafety/ClassAndModuleAttributes
36+
# This is a false positive - these configuration attributes are set during initialization
37+
3538
# The MaxMind account ID that is used for authorization.
3639
#
3740
# @return [Integer, nil]
@@ -57,6 +60,8 @@ class << self
5760
# @return [String, nil]
5861
attr_accessor :license_key
5962

63+
# rubocop:enable ThreadSafety/ClassAndModuleAttributes
64+
6065
# @!visibility private
6166
attr_reader :connection_pool
6267

@@ -67,19 +72,25 @@ def configure
6772
yield self
6873

6974
pool_size = 5
75+
# rubocop:disable ThreadSafety/ClassInstanceVariable
76+
# This is a false positive - this configuration is set during initialization
7077
host = @host.nil? ? 'minfraud.maxmind.com' : @host
7178
@connection_pool = ConnectionPool.new(size: pool_size) do
79+
# rubocop:enable ThreadSafety/ClassInstanceVariable
7280
make_http_client.persistent("https://#{host}")
7381
end
7482
end
7583

7684
private
7785

7886
def make_http_client
87+
# rubocop:disable ThreadSafety/ClassInstanceVariable
88+
# This is a false positive - this configuration is set during initialization
7989
HTTP.basic_auth(
8090
user: @account_id,
8191
pass: @license_key,
8292
).headers(
93+
# rubocop:enable ThreadSafety/ClassInstanceVariable
8394
accept: 'application/json',
8495
user_agent: "minfraud-api-ruby/#{Minfraud::VERSION} ruby/#{RUBY_VERSION} http/#{HTTP::VERSION}",
8596
)

lib/minfraud/enum.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ module ClassMethods
1515
#
1616
# @return [Hash]
1717
def mapping
18+
# rubocop:disable ThreadSafety/ClassInstanceVariable
19+
# This is a false positive - this is set during class definition and then only read
1820
@mapping ||= {}
21+
# rubocop:enable ThreadSafety/ClassInstanceVariable
1922
end
2023

2124
# Create a set of methods for enum-like behavior of the attribute.

minfraud.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
3434
spec.add_development_dependency 'rubocop-performance'
3535
spec.add_development_dependency 'rubocop-rake'
3636
spec.add_development_dependency 'rubocop-rspec'
37+
spec.add_development_dependency 'rubocop-thread_safety'
3738
spec.add_development_dependency 'webmock', '~> 3.14'
3839
spec.metadata = {
3940
'rubygems_mfa_required' => 'true'

0 commit comments

Comments
 (0)