Skip to content

Commit d264927

Browse files
authored
Merge pull request #687 from Shopify/the-great-reset
The great reset
2 parents 4583b29 + 8cd73ff commit d264927

File tree

7 files changed

+1445
-492
lines changed

7 files changed

+1445
-492
lines changed

.github/workflows/ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
gemfile: [Gemfile, gemfiles/minimum_rubocop.gemfile]
12-
ruby: ["3.0", "3.1", "3.2", "3.3"]
12+
ruby: ["3.1", "3.2", "3.3"]
1313

1414
env:
1515
BUNDLE_GEMFILE: ${{ matrix.gemfile }}

Gemfile.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PATH
22
remote: .
33
specs:
44
rubocop-shopify (2.15.1)
5-
rubocop (~> 1.51)
5+
rubocop (~> 1.62)
66

77
GEM
88
remote: https://rubygems.org/
@@ -12,12 +12,12 @@ GEM
1212
byebug (11.1.3)
1313
coderay (1.1.3)
1414
diffy (3.4.3)
15-
json (2.7.2)
16-
language_server-protocol (3.17.0.3)
15+
json (2.10.1)
16+
language_server-protocol (3.17.0.4)
1717
method_source (1.0.0)
1818
minitest (5.25.4)
19-
parallel (1.24.0)
20-
parser (3.3.1.0)
19+
parallel (1.26.3)
20+
parser (3.3.7.1)
2121
ast (~> 2.4.1)
2222
racc
2323
pry (0.14.2)
@@ -26,26 +26,26 @@ GEM
2626
pry-byebug (3.10.1)
2727
byebug (~> 11.0)
2828
pry (>= 0.13, < 0.15)
29-
racc (1.7.3)
29+
racc (1.8.1)
3030
rainbow (3.1.1)
3131
rake (13.2.1)
32-
regexp_parser (2.9.0)
33-
rexml (3.2.6)
34-
rubocop (1.63.4)
32+
regexp_parser (2.10.0)
33+
rubocop (1.71.2)
3534
json (~> 2.3)
3635
language_server-protocol (>= 3.17.0)
3736
parallel (~> 1.10)
3837
parser (>= 3.3.0.2)
3938
rainbow (>= 2.2.2, < 4.0)
40-
regexp_parser (>= 1.8, < 3.0)
41-
rexml (>= 3.2.5, < 4.0)
42-
rubocop-ast (>= 1.31.1, < 2.0)
39+
regexp_parser (>= 2.9.3, < 3.0)
40+
rubocop-ast (>= 1.38.0, < 2.0)
4341
ruby-progressbar (~> 1.7)
44-
unicode-display_width (>= 2.4.0, < 3.0)
45-
rubocop-ast (1.31.3)
42+
unicode-display_width (>= 2.4.0, < 4.0)
43+
rubocop-ast (1.38.0)
4644
parser (>= 3.3.1.0)
4745
ruby-progressbar (1.13.0)
48-
unicode-display_width (2.5.0)
46+
unicode-display_width (3.1.4)
47+
unicode-emoji (~> 4.0, >= 4.0.4)
48+
unicode-emoji (4.0.4)
4949

5050
PLATFORMS
5151
ruby

bin/sort-cops

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'yaml'
5+
6+
def extract_cop_entries(content)
7+
# Extract all cop configurations (entries that start with a department name)
8+
cop_pattern = /^[A-Z][A-Za-z]+\/[A-Za-z]+:/
9+
cops = {}
10+
11+
current_cop = nil
12+
current_config = []
13+
14+
content.each_line do |line|
15+
if line.match?(cop_pattern)
16+
# Save previous cop if exists
17+
if current_cop
18+
cops[current_cop] = current_config.join
19+
end
20+
21+
# Start new cop
22+
current_cop = line.split(':').first
23+
current_config = [line]
24+
elsif current_cop
25+
current_config << line
26+
end
27+
end
28+
29+
# Save last cop
30+
if current_cop
31+
cops[current_cop] = current_config.join
32+
end
33+
34+
cops
35+
end
36+
37+
def sort_cops(file_path)
38+
content = File.read(file_path)
39+
40+
# Extract header (content before first cop)
41+
first_cop_pattern = /^[A-Z][A-Za-z]+\/[A-Za-z]+:/
42+
header_end = content.index(content.lines.find { |line| line.match?(first_cop_pattern) })
43+
header = content[0...header_end]
44+
45+
# Extract and sort cops
46+
cops = extract_cop_entries(content)
47+
sorted_cops = cops.sort_by { |name, _| name }
48+
49+
# Generate new content
50+
new_content = header
51+
52+
sorted_cops.each do |_, config|
53+
new_content << config
54+
end
55+
56+
# Write sorted content back to file
57+
File.write(file_path, new_content)
58+
end
59+
60+
if ARGV.empty?
61+
puts "Usage: ruby sort_cops.rb path/to/rubocop.yml"
62+
exit 1
63+
end
64+
65+
sort_cops(ARGV[0])
66+
puts "Successfully sorted cops in #{ARGV[0]}"

rubocop-cli.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

rubocop-shopify.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
2121
"allowed_push_host" => "https://rubygems.org",
2222
}
2323

24-
s.required_ruby_version = ">= 3.0.0"
24+
s.required_ruby_version = ">= 3.1.0"
2525

26-
s.add_dependency("rubocop", "~> 1.51")
26+
s.add_dependency("rubocop", "~> 1.62")
2727
end

0 commit comments

Comments
 (0)