rubocop-minitest 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +18 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +5 -1
  4. data/.rubocop.yml +5 -3
  5. data/.rubocop_todo.yml +8 -7
  6. data/CHANGELOG.md +94 -37
  7. data/CONTRIBUTING.md +3 -3
  8. data/Gemfile +2 -2
  9. data/LICENSE.txt +1 -1
  10. data/README.md +20 -4
  11. data/Rakefile +29 -0
  12. data/bin/console +2 -0
  13. data/config/default.yml +100 -16
  14. data/docs/antora.yml +7 -0
  15. data/docs/modules/ROOT/nav.adoc +6 -0
  16. data/docs/modules/ROOT/pages/cops.adoc +49 -0
  17. data/docs/modules/ROOT/pages/cops_minitest.adoc +1050 -0
  18. data/docs/modules/ROOT/pages/index.adoc +5 -0
  19. data/docs/modules/ROOT/pages/installation.adoc +15 -0
  20. data/docs/modules/ROOT/pages/usage.adoc +32 -0
  21. data/{manual → legacy-docs}/cops.md +0 -0
  22. data/{manual → legacy-docs}/cops_minitest.md +16 -16
  23. data/legacy-docs/index.md +1 -0
  24. data/{manual → legacy-docs}/installation.md +0 -0
  25. data/{manual → legacy-docs}/usage.md +0 -0
  26. data/lib/rubocop/cop/generator.rb +56 -0
  27. data/lib/rubocop/cop/minitest/assert_empty_literal.rb +23 -7
  28. data/lib/rubocop/cop/minitest/assert_in_delta.rb +29 -0
  29. data/lib/rubocop/cop/minitest/assert_kind_of.rb +25 -0
  30. data/lib/rubocop/cop/minitest/assert_nil.rb +1 -0
  31. data/lib/rubocop/cop/minitest/assert_output.rb +49 -0
  32. data/lib/rubocop/cop/minitest/assert_path_exists.rb +59 -0
  33. data/lib/rubocop/cop/minitest/assert_silent.rb +45 -0
  34. data/lib/rubocop/cop/minitest/assert_truthy.rb +1 -0
  35. data/lib/rubocop/cop/minitest/assert_with_expected_argument.rb +38 -0
  36. data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +43 -0
  37. data/lib/rubocop/cop/minitest/global_expectations.rb +4 -4
  38. data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +53 -0
  39. data/lib/rubocop/cop/minitest/multiple_assertions.rb +63 -0
  40. data/lib/rubocop/cop/minitest/refute_equal.rb +2 -1
  41. data/lib/rubocop/cop/minitest/refute_false.rb +1 -0
  42. data/lib/rubocop/cop/minitest/refute_in_delta.rb +29 -0
  43. data/lib/rubocop/cop/minitest/refute_kind_of.rb +25 -0
  44. data/lib/rubocop/cop/minitest/refute_nil.rb +1 -0
  45. data/lib/rubocop/cop/minitest/refute_path_exists.rb +59 -0
  46. data/lib/rubocop/cop/minitest/test_method_name.rb +79 -0
  47. data/lib/rubocop/cop/minitest/unspecified_exception.rb +36 -0
  48. data/lib/rubocop/cop/minitest_cops.rb +16 -0
  49. data/lib/rubocop/cop/mixin/argument_range_helper.rb +10 -0
  50. data/lib/rubocop/cop/mixin/in_delta_mixin.rb +50 -0
  51. data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +2 -1
  52. data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +97 -0
  53. data/lib/rubocop/minitest/version.rb +8 -1
  54. data/mkdocs.yml +4 -4
  55. data/relnotes/v0.1.0.md +1 -1
  56. data/relnotes/v0.10.0.md +21 -0
  57. data/relnotes/v0.10.1.md +5 -0
  58. data/relnotes/v0.10.2.md +5 -0
  59. data/relnotes/v0.10.3.md +5 -0
  60. data/relnotes/v0.11.0.md +16 -0
  61. data/relnotes/v0.2.0.md +4 -4
  62. data/relnotes/v0.2.1.md +1 -1
  63. data/relnotes/v0.3.0.md +6 -6
  64. data/relnotes/v0.4.0.md +5 -5
  65. data/relnotes/v0.4.1.md +1 -1
  66. data/relnotes/v0.5.0.md +1 -1
  67. data/relnotes/v0.5.1.md +1 -1
  68. data/relnotes/v0.6.0.md +1 -1
  69. data/relnotes/v0.6.1.md +2 -2
  70. data/relnotes/v0.6.2.md +1 -1
  71. data/relnotes/v0.7.0.md +5 -5
  72. data/relnotes/v0.8.0.md +4 -4
  73. data/relnotes/v0.8.1.md +1 -1
  74. data/relnotes/v0.9.0.md +3 -3
  75. data/rubocop-minitest.gemspec +7 -7
  76. data/tasks/cops_documentation.rake +15 -264
  77. data/tasks/cut_release.rake +16 -0
  78. metadata +55 -20
  79. data/manual/index.md +0 -1
data/relnotes/v0.5.1.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ### Bug fixes
2
2
 
3
- * [#42](https://github.com/rubocop-hq/rubocop-minitest/issues/42): Fix an incorrect autocorrect for some cops of `Minitest` department when using heredoc message. ([@koic][])
3
+ * [#42](https://github.com/rubocop/rubocop-minitest/issues/42): Fix an incorrect autocorrect for some cops of `Minitest` department when using heredoc message. ([@koic][])
4
4
 
5
5
  [@koic]: https://github.com/koic
data/relnotes/v0.6.0.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ### New features
2
2
 
3
- * [#49](https://github.com/rubocop-hq/rubocop-minitest/pull/49): New cops `AssertMatch` and `RefuteMatch` check for use of `assert_match`/`refute_match` instead of `assert(foo.match(bar))`/`refute(foo.match(bar))`. ([@fsateler][])
3
+ * [#49](https://github.com/rubocop/rubocop-minitest/pull/49): New cops `AssertMatch` and `RefuteMatch` check for use of `assert_match`/`refute_match` instead of `assert(foo.match(bar))`/`refute(foo.match(bar))`. ([@fsateler][])
4
4
 
5
5
  [@fsateler]: https://github.com/fsateler
data/relnotes/v0.6.1.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ### Bug fixes
2
2
 
3
- * [#52](https://github.com/rubocop-hq/rubocop-minitest/issues/52): Make `Minitest/RefuteFalse` cop aware of `assert(!test)`. ([@koic][])
4
- * [#52](https://github.com/rubocop-hq/rubocop-minitest/issues/52): Fix a false negative for `Minitest/AssertIncludes` and `Minitest/RefuteIncludes` when an argument is enclosed in redundant parentheses. ([@koic][])
3
+ * [#52](https://github.com/rubocop/rubocop-minitest/issues/52): Make `Minitest/RefuteFalse` cop aware of `assert(!test)`. ([@koic][])
4
+ * [#52](https://github.com/rubocop/rubocop-minitest/issues/52): Fix a false negative for `Minitest/AssertIncludes` and `Minitest/RefuteIncludes` when an argument is enclosed in redundant parentheses. ([@koic][])
5
5
 
6
6
  [@koic]: https://github.com/koic
data/relnotes/v0.6.2.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ### Bug fixes
2
2
 
3
- * [#55](https://github.com/rubocop-hq/rubocop-minitest/issues/55): Fix an error for `Minitest/AssertIncludes` when using local variable argument. ([@koic][])
3
+ * [#55](https://github.com/rubocop/rubocop-minitest/issues/55): Fix an error for `Minitest/AssertIncludes` when using local variable argument. ([@koic][])
4
4
 
5
5
  [@koic]: https://github.com/koic
data/relnotes/v0.7.0.md CHANGED
@@ -1,13 +1,13 @@
1
1
  ### New features
2
2
 
3
- * [#60](https://github.com/rubocop-hq/rubocop-minitest/issues/60): Add new cop `Minitest/GlobalExpectations` to check for deprecated global expectations. ([@tejasbubane][])
3
+ * [#60](https://github.com/rubocop/rubocop-minitest/issues/60): Add new cop `Minitest/GlobalExpectations` to check for deprecated global expectations. ([@tejasbubane][])
4
4
 
5
5
  ### Bug fixes
6
6
 
7
- * [#58](https://github.com/rubocop-hq/rubocop-minitest/pull/58): Fix a false negative for `Minitest/AssertMatch` and `Minitest/RefuteMatch` when an argument is enclosed in redundant parentheses. ([@koic][])
8
- * [#59](https://github.com/rubocop-hq/rubocop-minitest/pull/59): Fix a false negative for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo` when an argument is enclosed in redundant parentheses. ([@koic][])
9
- * [#61](https://github.com/rubocop-hq/rubocop-minitest/pull/61): Fix a false negative for `Minitest/AssertInstanceOf` and `Minitest/RefuteInstanceOf` when an argument is enclosed in redundant parentheses. ([@koic][])
10
- * [#62](https://github.com/rubocop-hq/rubocop-minitest/pull/62): Fix a false negative for `Minitest/AssertEmpty` and `Minitest/RefuteEmpty` when an argument is enclosed in redundant parentheses. ([@koic][])
7
+ * [#58](https://github.com/rubocop/rubocop-minitest/pull/58): Fix a false negative for `Minitest/AssertMatch` and `Minitest/RefuteMatch` when an argument is enclosed in redundant parentheses. ([@koic][])
8
+ * [#59](https://github.com/rubocop/rubocop-minitest/pull/59): Fix a false negative for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo` when an argument is enclosed in redundant parentheses. ([@koic][])
9
+ * [#61](https://github.com/rubocop/rubocop-minitest/pull/61): Fix a false negative for `Minitest/AssertInstanceOf` and `Minitest/RefuteInstanceOf` when an argument is enclosed in redundant parentheses. ([@koic][])
10
+ * [#62](https://github.com/rubocop/rubocop-minitest/pull/62): Fix a false negative for `Minitest/AssertEmpty` and `Minitest/RefuteEmpty` when an argument is enclosed in redundant parentheses. ([@koic][])
11
11
 
12
12
  [@tejasbubane]: https://github.com/tejasbubane
13
13
  [@koic]: https://github.com/koic
data/relnotes/v0.8.0.md CHANGED
@@ -1,12 +1,12 @@
1
1
  ### New features
2
2
 
3
- * [#66](https://github.com/rubocop-hq/rubocop-minitest/issues/66): Support all expectations of `Minitest::Expectations` for `Minitest/GlobalExpectations` cop. ([@koic][])
3
+ * [#66](https://github.com/rubocop/rubocop-minitest/issues/66): Support all expectations of `Minitest::Expectations` for `Minitest/GlobalExpectations` cop. ([@koic][])
4
4
 
5
5
  ### Bug fixes
6
6
 
7
- * [#60](https://github.com/rubocop-hq/rubocop-minitest/issues/60): Fix `Minitest/GlobalExpectations` autocorrection for chained methods. ([@tejasbubane][])
8
- * [#69](https://github.com/rubocop-hq/rubocop-minitest/pull/69): Fix a false negative for `Minitest/GlobalExpectations` cop when using a variable or a hash index for receiver. ([@koic][])
9
- * [#71](https://github.com/rubocop-hq/rubocop-minitest/pull/71): Fix a false negative for `Minitest/AssertEqual` when an argument is enclosed in redundant parentheses. ([@koic][])
7
+ * [#60](https://github.com/rubocop/rubocop-minitest/issues/60): Fix `Minitest/GlobalExpectations` autocorrection for chained methods. ([@tejasbubane][])
8
+ * [#69](https://github.com/rubocop/rubocop-minitest/pull/69): Fix a false negative for `Minitest/GlobalExpectations` cop when using a variable or a hash index for receiver. ([@koic][])
9
+ * [#71](https://github.com/rubocop/rubocop-minitest/pull/71): Fix a false negative for `Minitest/AssertEqual` when an argument is enclosed in redundant parentheses. ([@koic][])
10
10
 
11
11
  [@koic]: https://github.com/koic
12
12
  [@tejasbubane]: https://github.com/tejasbubane
data/relnotes/v0.8.1.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ### Bug fixes
2
2
 
3
- * [#72](https://github.com/rubocop-hq/rubocop-minitest/pull/72): Fix some false negatives for `Minitest/GlobalExpectations`. ([@andrykonchin][])
3
+ * [#72](https://github.com/rubocop/rubocop-minitest/pull/72): Fix some false negatives for `Minitest/GlobalExpectations`. ([@andrykonchin][])
4
4
 
5
5
  [@andrykonchin]: https://github.com/andrykonchin
data/relnotes/v0.9.0.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ### Bug fixes
2
2
 
3
- * [#75](https://github.com/rubocop-hq/rubocop-minitest/issues/75): Fix a false negative for `Minitest/GlobalExpectations` when using global expectation methods with no arguments. ([@koic][])
3
+ * [#75](https://github.com/rubocop/rubocop-minitest/issues/75): Fix a false negative for `Minitest/GlobalExpectations` when using global expectation methods with no arguments. ([@koic][])
4
4
 
5
5
  ### Changes
6
6
 
7
- * [#73](https://github.com/rubocop-hq/rubocop-minitest/issues/73): The Minitest department works on file names end with `_test.rb` by default. ([@koic][])
8
- * [#77](https://github.com/rubocop-hq/rubocop-minitest/pull/77): **(BREAKING)** Drop support for Ruby 2.3. ([@koic][])
7
+ * [#73](https://github.com/rubocop/rubocop-minitest/issues/73): The Minitest department works on file names end with `_test.rb` by default. ([@koic][])
8
+ * [#77](https://github.com/rubocop/rubocop-minitest/pull/77): **(BREAKING)** Drop support for Ruby 2.3. ([@koic][])
9
9
 
10
10
  [@koic]: https://github.com/koic
@@ -6,7 +6,7 @@ require 'rubocop/minitest/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'rubocop-minitest'
9
- spec.version = RuboCop::Minitest::VERSION
9
+ spec.version = RuboCop::Minitest::Version::STRING
10
10
  spec.authors = ['Bozhidar Batsov', 'Jonas Arvidsson', 'Koichi ITO']
11
11
 
12
12
  spec.summary = 'Automatic Minitest code style checking tool.'
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = '>= 2.4.0'
20
20
  spec.metadata = {
21
- 'homepage_uri' => 'https://docs.rubocop.org/projects/minitest/',
22
- 'changelog_uri' => 'https://github.com/rubocop-hq/rubocop-minitest/blob/master/CHANGELOG.md',
23
- 'source_code_uri' => 'https://github.com/rubocop-hq/rubocop-minitest',
24
- 'documentation_uri' => 'https://docs.rubocop.org/projects/minitest/',
25
- 'bug_tracker_uri' => 'https://github.com/rubocop-hq/rubocop-minitest/issues'
21
+ 'homepage_uri' => 'https://docs.rubocop.org/rubocop-minitest/',
22
+ 'changelog_uri' => 'https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md',
23
+ 'source_code_uri' => 'https://github.com/rubocop/rubocop-minitest',
24
+ 'documentation_uri' => "https://docs.rubocop.org/rubocop-minitest/#{RuboCop::Minitest::Version.document_version}",
25
+ 'bug_tracker_uri' => 'https://github.com/rubocop/rubocop-minitest/issues'
26
26
  }
27
27
 
28
28
  # Specify which files should be added to the gem when it is released.
@@ -34,6 +34,6 @@ Gem::Specification.new do |spec|
34
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ['lib']
36
36
 
37
- spec.add_runtime_dependency 'rubocop', '>= 0.74'
37
+ spec.add_runtime_dependency 'rubocop', '>= 0.90', '< 2.0'
38
38
  spec.add_development_dependency 'minitest', '~> 5.11'
39
39
  end
@@ -3,6 +3,7 @@
3
3
  require 'yard'
4
4
  require 'rubocop'
5
5
  require 'rubocop-minitest'
6
+ require 'rubocop/cops_documentation_generator'
6
7
 
7
8
  YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
8
9
  task.files = ['lib/rubocop/cop/**/*.rb']
@@ -11,273 +12,23 @@ end
11
12
 
12
13
  desc 'Generate docs of all cops departments'
13
14
  task generate_cops_documentation: :yard_for_generate_documentation do
14
- def cops_of_department(cops, department)
15
- cops.with_department(department).sort!
16
- end
17
-
18
- def cops_body(config, cop, description, examples_objects, pars)
19
- content = h2(cop.cop_name)
20
- content << properties(config, cop)
21
- content << "#{description}\n"
22
- content << examples(examples_objects) if examples_objects.count.positive?
23
- content << configurations(pars)
24
- content << references(config, cop)
25
- content
26
- end
27
-
28
- def examples(examples_object)
29
- examples_object.each_with_object(h3('Examples').dup) do |example, content|
30
- content << h4(example.name) unless example.name == ''
31
- content << code_example(example)
32
- end
33
- end
34
-
35
- # rubocop:disable Metrics/MethodLength
36
- def properties(config, cop)
37
- header = [
38
- 'Enabled by default', 'Safe', 'Supports autocorrection', 'VersionAdded',
39
- 'VersionChanged'
40
- ]
41
- config = config.for_cop(cop)
42
- safe_auto_correct = config.fetch('SafeAutoCorrect', true)
43
- autocorrect = if cop.new.support_autocorrect?
44
- "Yes #{'(Unsafe)' unless safe_auto_correct}"
45
- else
46
- 'No'
47
- end
48
- content = [[
49
- config.fetch('Enabled') ? 'Enabled' : 'Disabled',
50
- config.fetch('Safe', true) ? 'Yes' : 'No',
51
- autocorrect,
52
- config.fetch('VersionAdded', '-'),
53
- config.fetch('VersionChanged', '-')
54
- ]]
55
- to_table(header, content) + "\n"
56
- end
57
- # rubocop:enable Metrics/MethodLength
58
-
59
- def h2(title)
60
- content = +"\n"
61
- content << "## #{title}\n"
62
- content << "\n"
63
- content
64
- end
65
-
66
- def h3(title)
67
- content = +"\n"
68
- content << "### #{title}\n"
69
- content << "\n"
70
- content
71
- end
72
-
73
- def h4(title)
74
- content = +"#### #{title}\n"
75
- content << "\n"
76
- content
77
- end
78
-
79
- def code_example(ruby_code)
80
- content = +"```ruby\n"
81
- content << ruby_code.text
82
- .gsub('@good', '# good').gsub('@bad', '# bad').strip
83
- content << "\n```\n"
84
- content
85
- end
86
-
87
- def configurations(pars)
88
- return '' if pars.empty?
89
-
90
- header = ['Name', 'Default value', 'Configurable values']
91
- configs = pars.each_key.reject { |key| key.start_with?('Supported') }
92
- content = configs.map do |name|
93
- configurable = configurable_values(pars, name)
94
- default = format_table_value(pars[name])
95
- [name, default, configurable]
96
- end
97
-
98
- h3('Configurable attributes') + to_table(header, content)
99
- end
100
-
101
- # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
102
- def configurable_values(pars, name)
103
- case name
104
- when /^Enforced/
105
- supported_style_name = RuboCop::Cop::Util.to_supported_styles(name)
106
- format_table_value(pars[supported_style_name])
107
- when 'IndentationWidth'
108
- 'Integer'
109
- when 'Database'
110
- format_table_value(pars['SupportedDatabases'])
111
- else
112
- case pars[name]
113
- when String
114
- 'String'
115
- when Integer
116
- 'Integer'
117
- when Float
118
- 'Float'
119
- when true, false
120
- 'Boolean'
121
- when Array
122
- 'Array'
123
- else
124
- ''
125
- end
126
- end
127
- end
128
- # rubocop:enable Metrics/CyclomaticComplexity,Metrics/MethodLength
129
-
130
- def to_table(header, content)
131
- table = [
132
- header.join(' | '),
133
- Array.new(header.size, '---').join(' | ')
134
- ]
135
- table.concat(content.map { |c| c.join(' | ') })
136
- table.join("\n") + "\n"
137
- end
138
-
139
- def format_table_value(val)
140
- value =
141
- case val
142
- when Array
143
- if val.empty?
144
- '`[]`'
145
- else
146
- val.map { |config| format_table_value(config) }.join(', ')
147
- end
148
- else
149
- "`#{val.nil? ? '<none>' : val}`"
150
- end
151
- value.gsub("#{Dir.pwd}/", '').rstrip
152
- end
153
-
154
- def references(config, cop)
155
- cop_config = config.for_cop(cop)
156
- urls = RuboCop::Cop::MessageAnnotator.new(
157
- config, cop.name, cop_config, {}
158
- ).urls
159
- return '' if urls.empty?
160
-
161
- content = h3('References')
162
- content << urls.map { |url| "* [#{url}](#{url})" }.join("\n")
163
- content << "\n"
164
- content
165
- end
166
-
167
- def print_cops_of_department(cops, department, config)
168
- selected_cops = cops_of_department(cops, department).select do |cop|
169
- cop.to_s.start_with?('RuboCop::Cop::Minitest')
170
- end
171
- return if selected_cops.empty?
172
-
173
- content = +"# #{department}\n"
174
- selected_cops.each do |cop|
175
- content << print_cop_with_doc(cop, config)
176
- end
177
- file_name = "#{Dir.pwd}/manual/cops_#{department.downcase}.md"
178
- File.open(file_name, 'w') do |file|
179
- puts "* generated #{file_name}"
180
- file.write(content.strip + "\n")
181
- end
182
- end
183
-
184
- def print_cop_with_doc(cop, config)
185
- t = config.for_cop(cop)
186
- non_display_keys = %w[
187
- Description Enabled StyleGuide Reference Safe SafeAutoCorrect VersionAdded
188
- VersionChanged
189
- ]
190
- pars = t.reject { |k| non_display_keys.include? k }
191
- description = 'No documentation'
192
- examples_object = []
193
- YARD::Registry.all(:class).detect do |code_object|
194
- next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
195
-
196
- description = code_object.docstring unless code_object.docstring.blank?
197
- examples_object = code_object.tags('example')
198
- end
199
- cops_body(config, cop, description, examples_object, pars)
200
- end
201
-
202
- # rubocop:disable Metrics/AbcSize
203
- def table_of_content_for_department(cops, department)
204
- selected_cops = cops_of_department(cops, department.to_sym).select do |cop|
205
- cop.to_s.start_with?('RuboCop::Cop::Minitest')
206
- end
207
- return if selected_cops.empty?
208
-
209
- type_title = department[0].upcase + department[1..-1]
210
- filename = "cops_#{department.downcase}.md"
211
- content = +"#### Department [#{type_title}](#{filename})\n\n"
212
- selected_cops.each do |cop|
213
- anchor = cop.cop_name.sub('/', '').downcase
214
- content << "* [#{cop.cop_name}](#{filename}##{anchor})\n"
215
- end
216
-
217
- content
218
- end
219
- # rubocop:enable Metrics/AbcSize
220
-
221
- def print_table_of_contents(cops)
222
- path = "#{Dir.pwd}/manual/cops.md"
223
- original = File.read(path)
224
- content = +"<!-- START_COP_LIST -->\n"
225
-
226
- content << table_contents(cops)
227
-
228
- content << "\n<!-- END_COP_LIST -->"
229
-
230
- content = if original.empty?
231
- content
232
- else
233
- original.sub(
234
- /<!-- START_COP_LIST -->.+<!-- END_COP_LIST -->/m, content
235
- )
236
- end
237
- File.write(path, content)
238
- end
239
-
240
- def table_contents(cops)
241
- cops
242
- .departments
243
- .map(&:to_s)
244
- .sort
245
- .map { |department| table_of_content_for_department(cops, department) }
246
- .reject(&:nil?)
247
- .join("\n")
248
- end
249
-
250
- def assert_manual_synchronized
251
- # Do not print diff and yield whether exit code was zero
252
- sh('git diff --quiet manual') do |outcome, _|
253
- return if outcome
254
-
255
- # Output diff before raising error
256
- sh('GIT_PAGER=cat git diff manual')
257
-
258
- warn 'The manual directory is out of sync. ' \
259
- 'Run `rake generate_cops_documentation` and commit the results.'
260
- exit!
261
- end
262
- end
263
-
264
- def main
265
- cops = RuboCop::Cop::Cop.registry
266
- config = RuboCop::ConfigLoader.load_file('config/default.yml')
15
+ deps = ['Minitest']
16
+ CopsDocumentationGenerator.new(departments: deps).call
17
+ end
267
18
 
268
- YARD::Registry.load!
269
- cops.departments.sort!.each do |department|
270
- print_cops_of_department(cops, department, config)
271
- end
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
272
24
 
273
- print_table_of_contents(cops)
25
+ # Output diff before raising error
26
+ sh('GIT_PAGER=cat git diff docs')
274
27
 
275
- assert_manual_synchronized if ENV['CI'] == 'true'
276
- ensure
277
- RuboCop::ConfigLoader.default_configuration = nil
28
+ warn 'The docs directory is out of sync. ' \
29
+ 'Run `rake generate_cops_documentation` and commit the results.'
30
+ exit!
278
31
  end
279
-
280
- main
281
32
  end
282
33
 
283
34
  desc 'Syntax check for the documentation comments'
@@ -286,7 +37,7 @@ task documentation_syntax_check: :yard_for_generate_documentation do
286
37
 
287
38
  ok = true
288
39
  YARD::Registry.load!
289
- cops = RuboCop::Cop::Cop.registry
40
+ cops = RuboCop::Cop::Registry.global
290
41
  cops.each do |cop|
291
42
  examples = YARD::Registry.all(:class).find do |code_object|
292
43
  next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
@@ -35,6 +35,21 @@ namespace :cut_release do
35
35
  end
36
36
  end
37
37
 
38
+ def update_antora_yml(new_version)
39
+ antora_metadata = File.read('docs/antora.yml')
40
+
41
+ File.open('docs/antora.yml', 'w') do |f|
42
+ f << antora_metadata.sub(
43
+ 'version: master',
44
+ "version: '#{version_sans_patch(new_version)}'"
45
+ )
46
+ end
47
+ end
48
+
49
+ def version_sans_patch(version)
50
+ version.split('.').take(2).join('.')
51
+ end
52
+
38
53
  def new_version_changes
39
54
  changelog = File.read('CHANGELOG.md')
40
55
  _, _, new_changes, _older_changes = changelog.split(/^## .*$/, 4)
@@ -54,6 +69,7 @@ namespace :cut_release do
54
69
 
55
70
  add_header_to_changelog(new_version)
56
71
  create_release_notes(new_version)
72
+ update_antora_yml(new_version)
57
73
 
58
74
  puts "Changed version from #{old_version} to #{new_version}."
59
75
  end