rubocop-minitest 0.15.0 → 0.17.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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- data/.github/workflows/spell_checking.yml +33 -0
- data/.rubocop.yml +6 -6
- data/.rubocop_todo.yml +2 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +30 -0
- data/CONTRIBUTING.md +3 -2
- data/Gemfile +1 -1
- data/Rakefile +4 -11
- data/codespell.txt +0 -0
- data/config/default.yml +13 -2
- data/docs/antora.yml +1 -1
- data/docs/modules/ROOT/pages/cops_minitest.adoc +133 -38
- data/lib/rubocop/cop/minitest/assert_empty.rb +12 -0
- data/lib/rubocop/cop/minitest/assert_empty_literal.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_with_expected_argument.rb +3 -2
- data/lib/rubocop/cop/minitest/global_expectations.rb +109 -38
- data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +4 -5
- data/lib/rubocop/cop/minitest/refute_empty.rb +12 -0
- data/lib/rubocop/minitest/assert_offense.rb +183 -0
- data/lib/rubocop/minitest/support.rb +10 -0
- data/lib/rubocop/minitest/version.rb +1 -1
- data/relnotes/v0.15.1.md +5 -0
- data/relnotes/v0.15.2.md +5 -0
- data/relnotes/v0.16.0.md +11 -0
- data/relnotes/v0.17.0.md +5 -0
- data/rubocop-minitest.gemspec +2 -1
- data/tasks/changelog.rake +34 -0
- data/tasks/changelog.rb +166 -0
- data/tasks/cops_documentation.rake +4 -14
- data/tasks/cut_release.rake +18 -3
- metadata +16 -4
@@ -19,6 +19,18 @@ module RuboCop
|
|
19
19
|
extend MinitestCopRule
|
20
20
|
|
21
21
|
define_rule :refute, target_method: :empty?
|
22
|
+
|
23
|
+
remove_method :on_send
|
24
|
+
def on_send(node)
|
25
|
+
return unless node.method?(:refute)
|
26
|
+
return unless (arguments = peel_redundant_parentheses_from(node.arguments))
|
27
|
+
return unless arguments.first.respond_to?(:method?) && arguments.first.method?(:empty?)
|
28
|
+
return unless arguments.first.arguments.empty?
|
29
|
+
|
30
|
+
add_offense(node, message: offense_message(arguments)) do |corrector|
|
31
|
+
autocorrect(corrector, node, arguments)
|
32
|
+
end
|
33
|
+
end
|
22
34
|
end
|
23
35
|
end
|
24
36
|
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Laziness copied from rubocop source code
|
4
|
+
require 'rubocop/rspec/expect_offense'
|
5
|
+
require 'rubocop/cop/legacy/corrector'
|
6
|
+
|
7
|
+
module RuboCop
|
8
|
+
module Minitest
|
9
|
+
# Mixin for `assert_offense` and `assert_no_offenses`
|
10
|
+
#
|
11
|
+
# This mixin makes it easier to specify strict offense assertions
|
12
|
+
# in a declarative and visual fashion. Just type out the code that
|
13
|
+
# should generate a offense, annotate code by writing '^'s
|
14
|
+
# underneath each character that should be highlighted, and follow
|
15
|
+
# the carets with a string (separated by a space) that is the
|
16
|
+
# message of the offense. You can include multiple offenses in
|
17
|
+
# one code snippet.
|
18
|
+
#
|
19
|
+
# @example Usage
|
20
|
+
#
|
21
|
+
# assert_offense(<<~RUBY)
|
22
|
+
# class FooTest < Minitest::Test
|
23
|
+
# def test_do_something
|
24
|
+
# assert_equal(nil, somestuff)
|
25
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)` over `assert_equal(nil, somestuff)`.
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# RUBY
|
29
|
+
#
|
30
|
+
# Auto-correction can be tested using `assert_correction` after
|
31
|
+
# `assert_offense`.
|
32
|
+
#
|
33
|
+
# @example `assert_offense` and `assert_correction`
|
34
|
+
#
|
35
|
+
# assert_offense(<<~RUBY)
|
36
|
+
# class FooTest < Minitest::Test
|
37
|
+
# def test_do_something
|
38
|
+
# assert_equal(nil, somestuff)
|
39
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)` over `assert_equal(nil, somestuff)`.
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# RUBY
|
43
|
+
#
|
44
|
+
# assert_correction(<<~RUBY)
|
45
|
+
# class FooTest < Minitest::Test
|
46
|
+
# def test_do_something
|
47
|
+
# assert_nil(somestuff)
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# RUBY
|
51
|
+
#
|
52
|
+
# If you do not want to specify an offense then use the
|
53
|
+
# companion method `assert_no_offenses`. This method is a much
|
54
|
+
# simpler assertion since it just inspects the source and checks
|
55
|
+
# that there were no offenses. The `assert_offense` method has
|
56
|
+
# to do more work by parsing out lines that contain carets.
|
57
|
+
#
|
58
|
+
# If the code produces an offense that could not be auto-corrected, you can
|
59
|
+
# use `assert_no_corrections` after `assert_offense`.
|
60
|
+
#
|
61
|
+
# @example `assert_offense` and `assert_no_corrections`
|
62
|
+
#
|
63
|
+
# assert_offense(<<~RUBY)
|
64
|
+
# class FooTest < Minitest::Test
|
65
|
+
# def test_do_something
|
66
|
+
# assert_equal(nil, somestuff)
|
67
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)` over `assert_equal(nil, somestuff)`.
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
# RUBY
|
71
|
+
#
|
72
|
+
# assert_no_corrections
|
73
|
+
module AssertOffense
|
74
|
+
private
|
75
|
+
|
76
|
+
def setup
|
77
|
+
cop_name = self.class.to_s.delete_suffix('Test')
|
78
|
+
|
79
|
+
@cop = RuboCop::Cop::Minitest.const_get(cop_name).new
|
80
|
+
end
|
81
|
+
|
82
|
+
def assert_no_offenses(source, file = nil)
|
83
|
+
setup_assertion
|
84
|
+
|
85
|
+
offenses = inspect_source(source, @cop, file)
|
86
|
+
|
87
|
+
expected_annotations = RuboCop::RSpec::ExpectOffense::AnnotatedSource.parse(source)
|
88
|
+
actual_annotations = expected_annotations.with_offense_annotations(offenses)
|
89
|
+
|
90
|
+
assert_equal(source, actual_annotations.to_s)
|
91
|
+
end
|
92
|
+
|
93
|
+
def assert_offense(source, file = nil)
|
94
|
+
setup_assertion
|
95
|
+
|
96
|
+
@cop.instance_variable_get(:@options)[:auto_correct] = true
|
97
|
+
|
98
|
+
expected_annotations = RuboCop::RSpec::ExpectOffense::AnnotatedSource.parse(source)
|
99
|
+
if expected_annotations.plain_source == source
|
100
|
+
raise 'Use `assert_no_offenses` to assert that no offenses are found'
|
101
|
+
end
|
102
|
+
|
103
|
+
@processed_source = parse_source!(expected_annotations.plain_source, file)
|
104
|
+
|
105
|
+
offenses = _investigate(@cop, @processed_source)
|
106
|
+
|
107
|
+
actual_annotations = expected_annotations.with_offense_annotations(offenses)
|
108
|
+
|
109
|
+
assert_equal(expected_annotations.to_s, actual_annotations.to_s)
|
110
|
+
end
|
111
|
+
|
112
|
+
def _investigate(cop, processed_source)
|
113
|
+
team = RuboCop::Cop::Team.new([cop], nil, raise_error: true)
|
114
|
+
report = team.investigate(processed_source)
|
115
|
+
@last_corrector = report.correctors.first || RuboCop::Cop::Corrector.new(processed_source)
|
116
|
+
report.offenses
|
117
|
+
end
|
118
|
+
|
119
|
+
def assert_correction(correction, loop: true)
|
120
|
+
raise '`assert_correction` must follow `assert_offense`' unless @processed_source
|
121
|
+
|
122
|
+
iteration = 0
|
123
|
+
new_source = loop do
|
124
|
+
iteration += 1
|
125
|
+
|
126
|
+
corrected_source = @last_corrector.rewrite
|
127
|
+
|
128
|
+
break corrected_source unless loop
|
129
|
+
break corrected_source if @last_corrector.empty? || corrected_source == @processed_source.buffer.source
|
130
|
+
|
131
|
+
if iteration > RuboCop::Runner::MAX_ITERATIONS
|
132
|
+
raise RuboCop::Runner::InfiniteCorrectionLoop.new(@processed_source.path, [])
|
133
|
+
end
|
134
|
+
|
135
|
+
# Prepare for next loop
|
136
|
+
@processed_source = parse_source!(corrected_source, @processed_source.path)
|
137
|
+
|
138
|
+
_investigate(@cop, @processed_source)
|
139
|
+
end
|
140
|
+
|
141
|
+
assert_equal(correction, new_source)
|
142
|
+
end
|
143
|
+
|
144
|
+
def setup_assertion
|
145
|
+
RuboCop::Formatter::DisabledConfigFormatter.config_to_allow_offenses = {}
|
146
|
+
RuboCop::Formatter::DisabledConfigFormatter.detected_styles = {}
|
147
|
+
end
|
148
|
+
|
149
|
+
def inspect_source(source, cop, file = nil)
|
150
|
+
processed_source = parse_source!(source, file)
|
151
|
+
raise 'Error parsing example code' unless processed_source.valid_syntax?
|
152
|
+
|
153
|
+
_investigate(cop, processed_source)
|
154
|
+
end
|
155
|
+
|
156
|
+
def investigate(cop, processed_source)
|
157
|
+
needed = Hash.new { |h, k| h[k] = [] }
|
158
|
+
Array(cop.class.joining_forces).each { |force| needed[force] << cop }
|
159
|
+
forces = needed.map do |force_class, joining_cops|
|
160
|
+
force_class.new(joining_cops)
|
161
|
+
end
|
162
|
+
|
163
|
+
commissioner = RuboCop::Cop::Commissioner.new([cop], forces, raise_error: true)
|
164
|
+
commissioner.investigate(processed_source)
|
165
|
+
commissioner
|
166
|
+
end
|
167
|
+
|
168
|
+
def parse_source!(source, file = nil)
|
169
|
+
if file.respond_to?(:write)
|
170
|
+
file.write(source)
|
171
|
+
file.rewind
|
172
|
+
file = file.path
|
173
|
+
end
|
174
|
+
|
175
|
+
RuboCop::ProcessedSource.new(source, ruby_version, file)
|
176
|
+
end
|
177
|
+
|
178
|
+
def ruby_version
|
179
|
+
2.5
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Require this file to load code that supports testing using Minitest.
|
4
|
+
|
5
|
+
require 'rubocop'
|
6
|
+
require 'minitest/autorun'
|
7
|
+
require 'minitest/pride'
|
8
|
+
require_relative 'assert_offense'
|
9
|
+
|
10
|
+
Minitest::Test.include RuboCop::Minitest::AssertOffense
|
data/relnotes/v0.15.1.md
ADDED
data/relnotes/v0.15.2.md
ADDED
data/relnotes/v0.16.0.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
### New features
|
2
|
+
|
3
|
+
* [#147](https://github.com/rubocop/rubocop-minitest/issues/147): Add `EnforcedStyle` config parameter for `Minitest/GlobalExpectations`. ([@gi][])
|
4
|
+
|
5
|
+
### Bug fixes
|
6
|
+
|
7
|
+
* [#142](https://github.com/rubocop/rubocop-minitest/issues/142): Fix `Minitest/GlobalExpectations` autocorrect when receiver is lambda. ([@gi][])
|
8
|
+
* [#150](https://github.com/rubocop/rubocop-minitest/issues/150): Fix a false positive for `Minitest/AssertEmpty` and `RefuteEmpty` cops when using `empty` method with any arguments. ([@koic][])
|
9
|
+
|
10
|
+
[@gi]: https://github.com/gi
|
11
|
+
[@koic]: https://github.com/koic
|
data/relnotes/v0.17.0.md
ADDED
data/rubocop-minitest.gemspec
CHANGED
@@ -22,7 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
'changelog_uri' => 'https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md',
|
23
23
|
'source_code_uri' => 'https://github.com/rubocop/rubocop-minitest',
|
24
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'
|
25
|
+
'bug_tracker_uri' => 'https://github.com/rubocop/rubocop-minitest/issues',
|
26
|
+
'rubygems_mfa_required' => 'true'
|
26
27
|
}
|
27
28
|
|
28
29
|
# Specify which files should be added to the gem when it is released.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
autoload :Changelog, "#{__dir__}/changelog"
|
4
|
+
|
5
|
+
namespace :changelog do
|
6
|
+
%i[new fix change].each do |type|
|
7
|
+
desc "Create a Changelog entry (#{type})"
|
8
|
+
task type, [:id] do |_task, args|
|
9
|
+
ref_type = :pull if args[:id]
|
10
|
+
path = Changelog::Entry.new(type: type, ref_id: args[:id], ref_type: ref_type).write
|
11
|
+
cmd = "git add #{path}"
|
12
|
+
system cmd
|
13
|
+
puts "Entry '#{path}' created and added to git index"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Merge entries and delete them'
|
18
|
+
task :merge do
|
19
|
+
raise 'No entries!' unless Changelog.pending?
|
20
|
+
|
21
|
+
Changelog.new.merge!.and_delete!
|
22
|
+
cmd = "git commit -a -m 'Update Changelog'"
|
23
|
+
puts cmd
|
24
|
+
system cmd
|
25
|
+
end
|
26
|
+
|
27
|
+
task :check_clean do
|
28
|
+
next unless Changelog.pending?
|
29
|
+
|
30
|
+
puts '*** Pending changelog entries!'
|
31
|
+
puts 'Do `bundle exec rake changelog:merge`'
|
32
|
+
exit(1)
|
33
|
+
end
|
34
|
+
end
|
data/tasks/changelog.rb
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if RUBY_VERSION < '2.6'
|
4
|
+
puts 'Changelog utilities available only for Ruby 2.6+'
|
5
|
+
exit(1)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Changelog utility
|
9
|
+
class Changelog
|
10
|
+
ENTRIES_PATH = 'changelog/'
|
11
|
+
FIRST_HEADER = /#{Regexp.escape("## master (unreleased)\n")}/m.freeze
|
12
|
+
ENTRIES_PATH_TEMPLATE = "#{ENTRIES_PATH}%<type>s_%<name>s.md"
|
13
|
+
TYPE_REGEXP = /#{Regexp.escape(ENTRIES_PATH)}([a-z]+)_/.freeze
|
14
|
+
TYPE_TO_HEADER = { new: 'New features', fix: 'Bug fixes', change: 'Changes' }.freeze
|
15
|
+
HEADER = /### (.*)/.freeze
|
16
|
+
PATH = 'CHANGELOG.md'
|
17
|
+
REF_URL = 'https://github.com/rubocop/rubocop-minitest'
|
18
|
+
MAX_LENGTH = 40
|
19
|
+
CONTRIBUTOR = '[@%<user>s]: https://github.com/%<user>s'
|
20
|
+
SIGNATURE = Regexp.new(format(Regexp.escape('[@%<user>s][]'), user: '([\w-]+)'))
|
21
|
+
EOF = "\n"
|
22
|
+
|
23
|
+
# New entry
|
24
|
+
Entry = Struct.new(:type, :body, :ref_type, :ref_id, :user, keyword_init: true) do
|
25
|
+
def initialize(type:, body: last_commit_title, ref_type: nil, ref_id: nil, user: github_user)
|
26
|
+
id, body = extract_id(body)
|
27
|
+
ref_id ||= id || 'x'
|
28
|
+
ref_type ||= id ? :issues : :pull
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def write
|
33
|
+
Dir.mkdir(ENTRIES_PATH) unless Dir.exist?(ENTRIES_PATH)
|
34
|
+
File.write(path, content)
|
35
|
+
path
|
36
|
+
end
|
37
|
+
|
38
|
+
def path
|
39
|
+
format(ENTRIES_PATH_TEMPLATE, type: type, name: str_to_filename(body))
|
40
|
+
end
|
41
|
+
|
42
|
+
def content
|
43
|
+
period = '.' unless body.end_with? '.'
|
44
|
+
"* #{ref}: #{body}#{period} ([@#{user}][])\n"
|
45
|
+
end
|
46
|
+
|
47
|
+
def ref
|
48
|
+
"[##{ref_id}](#{REF_URL}/#{ref_type}/#{ref_id})"
|
49
|
+
end
|
50
|
+
|
51
|
+
def last_commit_title
|
52
|
+
`git log -1 --pretty=%B`.lines.first.chomp
|
53
|
+
end
|
54
|
+
|
55
|
+
def extract_id(body)
|
56
|
+
/^\[Fix(?:es)? #(\d+)\] (.*)/.match(body)&.captures || [nil, body]
|
57
|
+
end
|
58
|
+
|
59
|
+
def str_to_filename(str)
|
60
|
+
str
|
61
|
+
.downcase
|
62
|
+
.split
|
63
|
+
.each { |s| s.gsub!(/\W/, '') }
|
64
|
+
.reject(&:empty?)
|
65
|
+
.inject do |result, word|
|
66
|
+
s = "#{result}_#{word}"
|
67
|
+
return result if s.length > MAX_LENGTH
|
68
|
+
|
69
|
+
s
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def github_user
|
74
|
+
user = `git config --global credential.username`.chomp
|
75
|
+
warn 'Set your username with `git config --global credential.username "myusernamehere"`' if user.empty?
|
76
|
+
|
77
|
+
user
|
78
|
+
end
|
79
|
+
end
|
80
|
+
attr_reader :header, :rest
|
81
|
+
|
82
|
+
def initialize(content: File.read(PATH), entries: Changelog.read_entries)
|
83
|
+
require 'strscan'
|
84
|
+
|
85
|
+
parse(content)
|
86
|
+
@entries = entries
|
87
|
+
end
|
88
|
+
|
89
|
+
def and_delete!
|
90
|
+
@entries.each_key { |path| File.delete(path) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def merge!
|
94
|
+
File.write(PATH, merge_content)
|
95
|
+
self
|
96
|
+
end
|
97
|
+
|
98
|
+
def unreleased_content
|
99
|
+
entry_map = parse_entries(@entries)
|
100
|
+
merged_map = merge_entries(entry_map)
|
101
|
+
merged_map.flat_map { |header, things| ["### #{header}\n", *things, ''] }.join("\n")
|
102
|
+
end
|
103
|
+
|
104
|
+
def merge_content
|
105
|
+
merged_content = [@header, unreleased_content, @rest.chomp, *new_contributor_lines].join("\n")
|
106
|
+
|
107
|
+
merged_content << EOF
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.pending?
|
111
|
+
entry_paths.any?
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.entry_paths
|
115
|
+
Dir["#{ENTRIES_PATH}*"]
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.read_entries
|
119
|
+
entry_paths.to_h { |path| [path, File.read(path)] }
|
120
|
+
end
|
121
|
+
|
122
|
+
def new_contributor_lines
|
123
|
+
contributors
|
124
|
+
.map { |user| format(CONTRIBUTOR, user: user) }
|
125
|
+
.reject { |line| @rest.include?(line) }
|
126
|
+
end
|
127
|
+
|
128
|
+
def contributors
|
129
|
+
contributors = @entries.values.flat_map do |entry|
|
130
|
+
entry.match(/\. \((?<contributors>.+)\)\n/)[:contributors].split(',')
|
131
|
+
end
|
132
|
+
|
133
|
+
contributors.join.scan(SIGNATURE).flatten
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
def merge_entries(entry_map)
|
139
|
+
all = @unreleased.merge(entry_map) { |_k, v1, v2| v1.concat(v2) }
|
140
|
+
canonical = TYPE_TO_HEADER.values.to_h { |v| [v, nil] }
|
141
|
+
canonical.merge(all).compact
|
142
|
+
end
|
143
|
+
|
144
|
+
def parse(content)
|
145
|
+
ss = StringScanner.new(content)
|
146
|
+
@header = ss.scan_until(FIRST_HEADER)
|
147
|
+
@unreleased = parse_release(ss.scan_until(/\n(?=## )/m))
|
148
|
+
@rest = ss.rest
|
149
|
+
end
|
150
|
+
|
151
|
+
# @return [Hash<type, Array<String>]]
|
152
|
+
def parse_release(unreleased)
|
153
|
+
unreleased.lines.map(&:chomp).reject(&:empty?).slice_before(HEADER).to_h do |header, *entries|
|
154
|
+
[HEADER.match(header)[1], entries]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def parse_entries(path_content_map)
|
159
|
+
changes = Hash.new { |h, k| h[k] = [] }
|
160
|
+
path_content_map.each do |path, content|
|
161
|
+
header = TYPE_TO_HEADER.fetch(TYPE_REGEXP.match(path)[1].to_sym)
|
162
|
+
changes[header].concat(content.lines.map(&:chomp))
|
163
|
+
end
|
164
|
+
changes
|
165
|
+
end
|
166
|
+
end
|
@@ -10,24 +10,14 @@ YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
|
|
10
10
|
task.options = ['--no-output']
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
task generate_cops_documentation: :yard_for_generate_documentation do
|
13
|
+
task update_cops_documentation: :yard_for_generate_documentation do
|
15
14
|
deps = ['Minitest']
|
16
15
|
CopsDocumentationGenerator.new(departments: deps).call
|
17
16
|
end
|
18
17
|
|
19
|
-
desc '
|
20
|
-
task
|
21
|
-
|
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!'
|
31
21
|
end
|
32
22
|
|
33
23
|
desc 'Syntax check for the documentation comments'
|
data/tasks/cut_release.rake
CHANGED
@@ -4,9 +4,8 @@ require 'bump'
|
|
4
4
|
|
5
5
|
namespace :cut_release do
|
6
6
|
%w[major minor patch pre].each do |release_type|
|
7
|
-
desc "Cut a new #{release_type} release, create release notes "
|
8
|
-
|
9
|
-
task release_type do
|
7
|
+
desc "Cut a new #{release_type} release, create release notes and update documents."
|
8
|
+
task release_type => 'changelog:check_clean' do
|
10
9
|
run(release_type)
|
11
10
|
end
|
12
11
|
end
|
@@ -50,12 +49,25 @@ namespace :cut_release do
|
|
50
49
|
version.split('.').take(2).join('.')
|
51
50
|
end
|
52
51
|
|
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
|
+
|
53
60
|
def new_version_changes
|
54
61
|
changelog = File.read('CHANGELOG.md')
|
55
62
|
_, _, new_changes, _older_changes = changelog.split(/^## .*$/, 4)
|
56
63
|
new_changes
|
57
64
|
end
|
58
65
|
|
66
|
+
def update_file(path)
|
67
|
+
content = File.read(path)
|
68
|
+
File.write(path, yield(content))
|
69
|
+
end
|
70
|
+
|
59
71
|
def user_links(text)
|
60
72
|
names = text.scan(/\[@(\S+)\]\[\]/).map(&:first).uniq
|
61
73
|
names.map { |name| "[@#{name}]: https://github.com/#{name}" }
|
@@ -67,6 +79,9 @@ namespace :cut_release do
|
|
67
79
|
Bump::Bump.run(release_type, commit: false, bundle: false, tag: false)
|
68
80
|
new_version = Bump::Bump.current
|
69
81
|
|
82
|
+
update_cop_versions(old_version, new_version)
|
83
|
+
Rake::Task['update_cops_documentation'].invoke
|
84
|
+
|
70
85
|
add_header_to_changelog(new_version)
|
71
86
|
create_release_notes(new_version)
|
72
87
|
update_antora_yml(new_version)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-11-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -60,9 +60,11 @@ files:
|
|
60
60
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
61
61
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
62
62
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
63
|
+
- ".github/workflows/spell_checking.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".rubocop.yml"
|
65
66
|
- ".rubocop_todo.yml"
|
67
|
+
- ".yardopts"
|
66
68
|
- CHANGELOG.md
|
67
69
|
- CONTRIBUTING.md
|
68
70
|
- Gemfile
|
@@ -71,6 +73,7 @@ files:
|
|
71
73
|
- Rakefile
|
72
74
|
- bin/console
|
73
75
|
- bin/setup
|
76
|
+
- codespell.txt
|
74
77
|
- config/default.yml
|
75
78
|
- docs/antora.yml
|
76
79
|
- docs/modules/ROOT/nav.adoc
|
@@ -127,7 +130,9 @@ files:
|
|
127
130
|
- lib/rubocop/cop/mixin/minitest_exploration_helpers.rb
|
128
131
|
- lib/rubocop/cop/mixin/nil_assertion_handleable.rb
|
129
132
|
- lib/rubocop/minitest.rb
|
133
|
+
- lib/rubocop/minitest/assert_offense.rb
|
130
134
|
- lib/rubocop/minitest/inject.rb
|
135
|
+
- lib/rubocop/minitest/support.rb
|
131
136
|
- lib/rubocop/minitest/version.rb
|
132
137
|
- mkdocs.yml
|
133
138
|
- readthedocs.yml
|
@@ -143,6 +148,10 @@ files:
|
|
143
148
|
- relnotes/v0.13.0.md
|
144
149
|
- relnotes/v0.14.0.md
|
145
150
|
- relnotes/v0.15.0.md
|
151
|
+
- relnotes/v0.15.1.md
|
152
|
+
- relnotes/v0.15.2.md
|
153
|
+
- relnotes/v0.16.0.md
|
154
|
+
- relnotes/v0.17.0.md
|
146
155
|
- relnotes/v0.2.0.md
|
147
156
|
- relnotes/v0.2.1.md
|
148
157
|
- relnotes/v0.3.0.md
|
@@ -158,6 +167,8 @@ files:
|
|
158
167
|
- relnotes/v0.8.1.md
|
159
168
|
- relnotes/v0.9.0.md
|
160
169
|
- rubocop-minitest.gemspec
|
170
|
+
- tasks/changelog.rake
|
171
|
+
- tasks/changelog.rb
|
161
172
|
- tasks/cops_documentation.rake
|
162
173
|
- tasks/cut_release.rake
|
163
174
|
homepage:
|
@@ -167,8 +178,9 @@ metadata:
|
|
167
178
|
homepage_uri: https://docs.rubocop.org/rubocop-minitest/
|
168
179
|
changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
|
169
180
|
source_code_uri: https://github.com/rubocop/rubocop-minitest
|
170
|
-
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.
|
181
|
+
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.17
|
171
182
|
bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
|
183
|
+
rubygems_mfa_required: 'true'
|
172
184
|
post_install_message:
|
173
185
|
rdoc_options: []
|
174
186
|
require_paths:
|
@@ -184,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
196
|
- !ruby/object:Gem::Version
|
185
197
|
version: '0'
|
186
198
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
199
|
+
rubygems_version: 3.3.0.dev
|
188
200
|
signing_key:
|
189
201
|
specification_version: 4
|
190
202
|
summary: Automatic Minitest code style checking tool.
|