Skip to content

Commit 19369de

Browse files
committed
Have cut_release handle "config/default" and generate cops doc
Follow up to rubocop/rubocop@1905f1b.
1 parent 3ecda94 commit 19369de

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

.circleci/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ jobs:
3030
- run:
3131
name: Check documentation syntax
3232
command: bundle exec rake documentation_syntax_check
33-
- run:
34-
name: Build documentation and verify that doc files are in sync
35-
command: bundle exec rake verify_cops_documentation
3633

3734
workflows:
3835
build:

Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ RuboCop::RakeTask.new(:internal_investigation)
3838

3939
task default: %i[
4040
documentation_syntax_check
41-
generate_cops_documentation
4241
spec
4342
internal_investigation
4443
]

tasks/cops_documentation.rake

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,14 @@ YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
1010
task.options = ['--no-output']
1111
end
1212

13-
desc 'Generate docs of all cops departments'
14-
task generate_cops_documentation: :yard_for_generate_documentation do
13+
task update_cops_documentation: :yard_for_generate_documentation do
1514
deps = ['Rails']
1615
CopsDocumentationGenerator.new(departments: deps).call
1716
end
1817

19-
desc 'Verify that documentation is up to date'
20-
task verify_cops_documentation: :generate_cops_documentation do
21-
# Do not print diff and yield whether exit code was zero
22-
sh('git diff --quiet docs') do |outcome, _|
23-
exit if outcome
24-
25-
# Output diff before raising error
26-
sh('GIT_PAGER=cat git diff docs')
27-
28-
warn 'The docs directory is out of sync. Run `rake generate_cops_documentation` and commit the results.'
29-
exit!
30-
end
18+
desc 'Generate docs of all cops departments (obsolete)'
19+
task :generate_cops_documentation do
20+
puts 'Updating the documentation is now done automatically!'
3121
end
3222

3323
desc 'Syntax check for the documentation comments'

tasks/cut_release.rake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,25 @@ namespace :cut_release do
4949
version.split('.').take(2).join('.')
5050
end
5151

52+
# Replace `<<next>>` (and variations) with version being cut.
53+
def update_cop_versions(_old_version, new_version)
54+
update_file('config/default.yml') do |default|
55+
default.gsub(/['"]?<<\s*next\s*>>['"]?/i,
56+
"'#{version_sans_patch(new_version)}'")
57+
end
58+
end
59+
5260
def new_version_changes
5361
changelog = File.read('CHANGELOG.md')
5462
_, _, new_changes, _older_changes = changelog.split(/^## .*$/, 4)
5563
new_changes
5664
end
5765

66+
def update_file(path)
67+
content = File.read(path)
68+
File.write(path, yield(content))
69+
end
70+
5871
def user_links(text)
5972
names = text.scan(/\[@(\S+)\]\[\]/).map(&:first).uniq
6073
names.map { |name| "[@#{name}]: https://github.com/#{name}" }
@@ -66,6 +79,9 @@ namespace :cut_release do
6679
Bump::Bump.run(release_type, commit: false, bundle: false, tag: false)
6780
new_version = Bump::Bump.current
6881

82+
update_cop_versions(old_version, new_version)
83+
Rake::Task['update_cops_documentation'].invoke
84+
6985
add_header_to_changelog(new_version)
7086
create_release_notes(new_version)
7187
update_antora_yml(new_version)

0 commit comments

Comments
 (0)