Skip to content

Commit c69400e

Browse files
committed
update rubocop
1 parent 2f763d2 commit c69400e

File tree

5 files changed

+50
-52
lines changed

5 files changed

+50
-52
lines changed

.rubocop.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require:
22
- standard
33
- rubocop-minitest
4-
- rubocop-rails
54
- rubocop-performance
65
- rubocop-sorbet
6+
# - rubocop-rails
77

88
inherit_gem:
99
standard: config/base.yml
@@ -18,7 +18,7 @@ AllCops:
1818
- sorbet/rbi/dsl/**/*
1919
- sorbet/rbi/gems/**/*
2020
- sorbet/rbi/annotations/**/*
21-
- rails_test_app/logstruct_test_app/bin/**/*
21+
- rails_test_app/logstruct_test_app/**/*
2222

2323
Layout/MultilineHashKeyLineBreaks:
2424
Enabled: true
@@ -29,20 +29,20 @@ Bundler/DuplicatedGem:
2929
Enabled: false # ignore duplicated gem errors because we have duplicated gems for testing
3030

3131
# We use UTC for all timestamps, no timezones required for logs
32-
Rails/TimeZone:
33-
Enabled: false
34-
# We don't use ApplicationMailer in this gem
35-
Rails/ApplicationMailer:
36-
Enabled: false
37-
# Not a Rails app
38-
Rails/RakeEnvironment:
39-
Enabled: false
40-
Rails/Output:
41-
Enabled: false
42-
Rails/NegateInclude:
43-
Enabled: false
44-
Rails/RefuteMethods:
45-
Enabled: false
32+
# Rails/TimeZone:
33+
# Enabled: false
34+
# # We don't use ApplicationMailer in this gem
35+
# Rails/ApplicationMailer:
36+
# Enabled: false
37+
# # Not a Rails app
38+
# Rails/RakeEnvironment:
39+
# Enabled: false
40+
# Rails/Output:
41+
# Enabled: false
42+
# Rails/NegateInclude:
43+
# Enabled: false
44+
# Rails/RefuteMethods:
45+
# Enabled: false
4646

4747
Performance/OpenStruct:
4848
Exclude:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ group :development do
6060
gem "amazing_print"
6161
gem "listen", require: false
6262
gem "rubocop-performance", require: false
63-
gem "rubocop-rails", require: false
63+
# gem "rubocop-rails", require: false
6464
gem "rubocop-minitest", require: false
6565
gem "rubocop-sorbet", require: false
6666
gem "rubocop", require: false

Gemfile.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,6 @@ GEM
290290
rubocop-performance (1.23.1)
291291
rubocop (>= 1.48.1, < 2.0)
292292
rubocop-ast (>= 1.31.1, < 2.0)
293-
rubocop-rails (2.29.1)
294-
activesupport (>= 4.2.0)
295-
rack (>= 1.1)
296-
rubocop (>= 1.52.0, < 2.0)
297-
rubocop-ast (>= 1.31.1, < 2.0)
298293
rubocop-sorbet (0.8.9)
299294
rubocop (>= 1)
300295
ruby-progressbar (1.13.0)
@@ -434,7 +429,6 @@ DEPENDENCIES
434429
rubocop
435430
rubocop-minitest
436431
rubocop-performance
437-
rubocop-rails
438432
rubocop-sorbet
439433
sentry-ruby (~> 5.15)
440434
shrine (~> 3.5)

rails_test_app/create_app.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ def copy_template(file, target_path = nil)
119119
puts "=> Running command: #{rails_new_command}"
120120
system(clean_env, rails_new_command) || abort("Failed to create Rails application")
121121

122+
# Remove the default .rubocop.yml file since it messes up our own RuboCop
123+
puts "=> Deleting default .rubocop.yml"
124+
FileUtils.rm_f(File.join(RAILS_APP_DIR, ".rubocop.yml"))
125+
122126
# Update Gemfile to include the local logstruct gem and test gems
123127
gemfile_path = File.join(RAILS_APP_DIR, "Gemfile")
124128
gemfile_content = File.read(gemfile_path)
@@ -133,22 +137,20 @@ def copy_template(file, target_path = nil)
133137
end
134138

135139
# Common gems for all Rails versions
136-
common_gems = <<~GEMS
137-
# Common gems for all Rails versions
138-
gem "bigdecimal"
139-
gem "mutex_m"
140-
gem "drb"
141-
gem "benchmark"
142-
GEMS
140+
# Common gems for all Rails versions
141+
gem "bigdecimal"
142+
gem "mutex_m"
143+
gem "drb"
144+
gem "benchmark"
143145

144146
# Add version-specific gems
145147
case rails_version
146148
when "7.0"
147-
latest_version = "7.0.8.7" # Updated by update_rails_versions.rb script
149+
"7.0.8.7" # Updated by update_rails_versions.rb script
148150
when "7.1"
149-
latest_version = "7.1.5.1" # Updated by update_rails_versions.rb script
151+
"7.1.5.1" # Updated by update_rails_versions.rb script
150152
when "8.0"
151-
latest_version = "8.0.1" # Updated by update_rails_versions.rb script
153+
"8.0.1" # Updated by update_rails_versions.rb script
152154
else
153155
puts "Warning: Using unrecognized Rails version #{rails_version}"
154156
end

scripts/update_rails_versions.rb

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# typed: strict
3+
24
# This script fetches the latest patch versions for each supported Rails version
35
# and updates them in the codebase.
46

@@ -17,37 +19,37 @@ def fetch_latest_rails_versions
1719
uri = URI("https://rubygems.org/api/v1/versions/rails.json")
1820
response = Net::HTTP.get(uri)
1921
versions = JSON.parse(response)
20-
22+
2123
# Filter out prerelease versions and map by version number
2224
stable_versions = versions.reject { |v| v["prerelease"] }.map { |v| v["number"] }
23-
25+
2426
# Find latest patch version for each supported major.minor
2527
latest_patches = {}
2628
SUPPORTED_MAJOR_MINOR.each do |major_minor|
2729
matching = stable_versions.select { |v| v.start_with?("#{major_minor}.") }
2830
next if matching.empty?
29-
31+
3032
# Sort by version parts to find latest
31-
latest = matching.sort_by { |v| v.split(".").map(&:to_i) }.last
33+
latest = matching.max_by { |v| v.split(".").map(&:to_i) }
3234
latest_patches[major_minor] = latest
3335
end
34-
36+
3537
puts "Latest patch versions:"
3638
latest_patches.each do |mm, version|
3739
puts " - Rails #{mm}: #{version}"
3840
end
39-
41+
4042
latest_patches
4143
end
4244

4345
def update_create_app_script(versions)
4446
puts "\nUpdating rails_test_app/create_app.rb..."
45-
47+
4648
content = File.read(CREATE_APP_SCRIPT)
47-
49+
4850
# Look for the case statement with Rails version mapping
4951
case_pattern = /case\s+rails_version\s*\n(.*?)end/m
50-
52+
5153
if content.match(case_pattern)
5254
# Replace the case statement with updated versions
5355
new_case = "case rails_version\n"
@@ -58,7 +60,7 @@ def update_create_app_script(versions)
5860
new_case += " else\n"
5961
new_case += " puts \"Warning: Using unrecognized Rails version \#{rails_version}\"\n"
6062
new_case += " end"
61-
63+
6264
updated_content = content.gsub(case_pattern, new_case)
6365
File.write(CREATE_APP_SCRIPT, updated_content)
6466
puts " Updated create_app.rb with latest versions"
@@ -70,30 +72,30 @@ def update_create_app_script(versions)
7072

7173
def update_github_workflow(versions)
7274
puts "\nUpdating .github/workflows/test.yml..."
73-
75+
7476
content = File.read(GITHUB_WORKFLOW)
7577
updated_content = content.dup
76-
78+
7779
# Update the pilot test Rails version
78-
if updated_content.match(/RAILS_VERSION:\s*'8\.0[\.\d]*'/)
79-
updated_content.gsub!(/RAILS_VERSION:\s*'8\.0[\.\d]*'/, "RAILS_VERSION: '#{versions['8.0']}'")
80-
puts " Updated pilot test Rails version to #{versions['8.0']}"
80+
if /RAILS_VERSION:\s*'8\.0[\.\d]*'/.match?(updated_content)
81+
updated_content.gsub!(/RAILS_VERSION:\s*'8\.0[\.\d]*'/, "RAILS_VERSION: '#{versions["8.0"]}'")
82+
puts " Updated pilot test Rails version to #{versions["8.0"]}"
8183
else
8284
puts " Warning: Could not find RAILS_VERSION for pilot test in test.yml"
8385
end
84-
86+
8587
# Update the matrix versions
8688
versions.each do |major_minor, version|
8789
# Look for matrix entries with this major.minor version
8890
# Allow for different patch versions (e.g., .8, .8.7)
89-
if updated_content.match(/rails:\s*'#{major_minor}[\.\d]+'/)
91+
if /rails:\s*'#{major_minor}[\.\d]+'/.match?(updated_content)
9092
updated_content.gsub!(/rails:\s*'#{major_minor}[\.\d]+'/, "rails: '#{version}'")
9193
puts " Updated matrix Rails #{major_minor} to version #{version}"
9294
else
9395
puts " Warning: Could not find matrix entry for Rails #{major_minor} in test.yml"
9496
end
9597
end
96-
98+
9799
File.write(GITHUB_WORKFLOW, updated_content)
98100
puts " Updated test.yml with latest versions"
99101
end
@@ -104,4 +106,4 @@ def update_github_workflow(versions)
104106
update_github_workflow(versions)
105107

106108
puts "\nDone! Rails versions have been updated to the latest patches."
107-
puts "Remember to commit these changes if they look good."
109+
puts "Remember to commit these changes if they look good."

0 commit comments

Comments
 (0)