Skip to content

Commit 3edcc98

Browse files
committed
Remove .ruby-version file
This PR removes the `.ruby-version` file The goal is to prevent forcing a specific Ruby version on contributors. Developers should be able to work on this repository regardless of their local Ruby version. * Previously, the Ruby version was pinned solely to address inconsistencies in hash syntax during documentation generation, not due to internal logic issues. * I believe pinning the version for this reason is not ideal. * With this change, documentation generation now produce consistent results without relying on a fixed Ruby version. * Contributors no longer need to worry about or strictly adhere to a specific Ruby version.
1 parent 6a5bf09 commit 3edcc98

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- uses: actions/checkout@v6
1919
- uses: ruby/setup-ruby@v1
2020
with:
21+
ruby-version: ruby
2122
bundler-cache: true
2223
- run: bundle exec rake confirm_config documentation_syntax_check confirm_documentation
2324

@@ -53,6 +54,7 @@ jobs:
5354
- uses: actions/checkout@v6
5455
- uses: ruby/setup-ruby@v1
5556
with:
57+
ruby-version: ruby
5658
bundler-cache: true
5759
- run: bundle exec rake spec
5860

@@ -72,6 +74,7 @@ jobs:
7274
cat Gemfile.local
7375
- uses: ruby/setup-ruby@v1
7476
with:
77+
ruby-version: ruby
7578
bundler-cache: true
7679
- name: Show RuboCop version
7780
run: grep '^ rubocop' Gemfile.lock | sort
@@ -93,6 +96,7 @@ jobs:
9396
cat Gemfile.local
9497
- uses: ruby/setup-ruby@v1
9598
with:
99+
ruby-version: ruby
96100
bundler-cache: true
97101
- name: Show RuboCop version
98102
run: grep '^ rubocop' Gemfile.lock | sort
@@ -115,6 +119,7 @@ jobs:
115119
EOF
116120
- uses: ruby/setup-ruby@v1
117121
with:
122+
ruby-version: ruby
118123
bundler-cache: true
119124
- run: NO_COVERAGE=true bundle exec rake spec
120125

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pkg
1616
/vendor
1717

1818
.ruby-gemset
19+
.ruby-version
1920

2021
# simplecov generated
2122
coverage

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

tasks/cops_documentation.rake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,48 @@ require 'rubocop-rspec'
55
require 'rubocop/cops_documentation_generator'
66
require 'yard'
77

8+
# Monkey patch to normalize Hash formatting regardless of Ruby version
9+
class CopsDocumentationGenerator
10+
private
11+
12+
# Override to normalize Hash values to Ruby 3.4+ format
13+
def format_table_value(val)
14+
value =
15+
case val
16+
when Array
17+
if val.empty?
18+
'`[]`'
19+
else
20+
val.map { |config| format_table_value(config) }.join(', ')
21+
end
22+
when Hash
23+
# Normalize Hash to Ruby 3.4+ format with spaces around =>
24+
normalize_hash(val)
25+
else
26+
wrap_backtick(val.nil? ? '<none>' : val)
27+
end
28+
value.gsub("#{@base_dir}/", '').rstrip
29+
end
30+
31+
def normalize_hash(hash)
32+
return '`{}`' if hash.empty?
33+
34+
pairs = hash.map do |key, value|
35+
formatted_key = key.inspect
36+
formatted_value = value.is_a?(String) ? value.inspect : value.to_s
37+
38+
# Use symbol colon syntax for symbol keys, hash rocket for others
39+
if key.is_a?(Symbol)
40+
"#{key}: #{formatted_value}"
41+
else
42+
"#{formatted_key} => #{formatted_value}"
43+
end
44+
end
45+
46+
"`{#{pairs.join(', ')}}`"
47+
end
48+
end
49+
850
YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
951
task.files = ['lib/rubocop/cop/**/*.rb']
1052
task.options = ['--no-output']

0 commit comments

Comments
 (0)