Skip to content

Commit 175c309

Browse files
authoredMar 21, 2025··
Merge pull request #703 from Shopify/thread-safety-rubocop
Include thread-safety rubocop and refactor minimum rubocop.gemfile
2 parents 39d8dd7 + a8dd1f0 commit 175c309

File tree

6 files changed

+75
-87
lines changed

6 files changed

+75
-87
lines changed
 

‎Gemfile.lock

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ PATH
22
remote: .
33
specs:
44
rubocop-shopify (2.15.1)
5-
rubocop (~> 1.62)
5+
rubocop (~> 1.72, >= 1.72.1)
6+
rubocop-thread_safety (>= 0.7.1)
67

78
GEM
89
remote: https://rubygems.org/
@@ -31,7 +32,7 @@ GEM
3132
rainbow (3.1.1)
3233
rake (13.2.1)
3334
regexp_parser (2.10.0)
34-
rubocop (1.73.1)
35+
rubocop (1.72.2)
3536
json (~> 2.3)
3637
language_server-protocol (~> 3.17.0.2)
3738
lint_roller (~> 1.1.0)
@@ -44,6 +45,9 @@ GEM
4445
unicode-display_width (>= 2.4.0, < 4.0)
4546
rubocop-ast (1.38.1)
4647
parser (>= 3.3.1.0)
48+
rubocop-thread_safety (0.7.1)
49+
lint_roller (~> 1.1)
50+
rubocop (~> 1.72, >= 1.72.1)
4751
ruby-progressbar (1.13.0)
4852
unicode-display_width (3.1.4)
4953
unicode-emoji (~> 4.0, >= 4.0.4)

‎bin/sort-cops

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def sort_cops(file_path)
5858
end
5959

6060
if ARGV.empty?
61-
puts "Usage: ruby sort_cops.rb path/to/rubocop.yml"
61+
puts "Usage: ruby sort-cops path/to/rubocop.yml"
6262
exit 1
6363
end
6464

‎gemfiles/minimum_rubocop.gemfile

+16-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@
22

33
eval_gemfile "../Gemfile"
44

5-
# This naively extracts the minimum rubocop version from our gemspec,
5+
# This extracts the minimum rubocop version from our gemspec,
66
# allowing us to ensure that it remains compatible.
7-
minimum_rubocop_version = File.read("rubocop-shopify.gemspec")[/(?<=add_dependency\("rubocop", "~> ).*(?="\)$)/]
8-
raise "Failed to extract minimum rubocop version from gemspec" if minimum_rubocop_version.nil?
97

10-
gem "rubocop", minimum_rubocop_version
8+
supported_requirement_types = ['>=', '~>']
9+
supported_requirements, unsupported_requirements = Gem::Specification
10+
.load("rubocop-shopify.gemspec")
11+
.dependencies.find { |d| d.name == "rubocop" }
12+
.requirement.requirements
13+
.partition { |type, _version| supported_requirement_types.include?(type) }
14+
15+
raise <<~ERROR_MESSAGE unless unsupported_requirements.empty?
16+
Unsupported requirement types: #{unsupported_requirements.inspect}.
17+
Only #{supported_requirement_types.inspect} are supported.
18+
ERROR_MESSAGE
19+
20+
minimum_version = supported_requirements.map { |_type, version| version }.max
21+
22+
gem "rubocop", minimum_version

‎rubocop-shopify.gemspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ Gem::Specification.new do |s|
2323

2424
s.required_ruby_version = ">= 3.1.0"
2525

26-
s.add_dependency("rubocop", "~> 1.62")
26+
s.add_dependency("rubocop", "~> 1.72", ">= 1.72.1")
27+
s.add_dependency("rubocop-thread_safety", ">= 0.7.1")
2728
end

0 commit comments

Comments
 (0)
Please sign in to comment.