rubocop-minitest 0.21.1 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +5 -0
- data/lib/rubocop/cop/minitest/assert_match.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_raises_with_regexp_argument.rb +36 -0
- data/lib/rubocop/cop/minitest_cops.rb +1 -0
- data/lib/rubocop/cop/mixin/argument_range_helper.rb +1 -0
- data/lib/rubocop/cop/mixin/in_delta_mixin.rb +1 -0
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +11 -4
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +1 -0
- data/lib/rubocop/cop/mixin/nil_assertion_handleable.rb +1 -0
- data/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb +1 -0
- data/lib/rubocop/minitest/version.rb +1 -1
- metadata +4 -81
- data/.circleci/config.yml +0 -55
- data/.gitattributes +0 -1
- data/.github/FUNDING.yml +0 -7
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -43
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -17
- data/.github/workflows/linting.yml +0 -15
- data/.github/workflows/spell_checking.yml +0 -33
- data/.gitignore +0 -61
- data/.rubocop.yml +0 -110
- data/.rubocop_todo.yml +0 -19
- data/.yamllint.yml +0 -9
- data/.yardopts +0 -3
- data/CHANGELOG.md +0 -336
- data/CONTRIBUTING.md +0 -69
- data/Gemfile +0 -16
- data/Rakefile +0 -56
- data/bin/console +0 -11
- data/bin/setup +0 -8
- data/codespell.txt +0 -0
- data/docs/antora.yml +0 -7
- data/docs/modules/ROOT/nav.adoc +0 -6
- data/docs/modules/ROOT/pages/cops.adoc +0 -56
- data/docs/modules/ROOT/pages/cops_minitest.adoc +0 -1450
- data/docs/modules/ROOT/pages/index.adoc +0 -5
- data/docs/modules/ROOT/pages/installation.adoc +0 -15
- data/docs/modules/ROOT/pages/usage.adoc +0 -32
- data/legacy-docs/cops.md +0 -23
- data/legacy-docs/cops_minitest.md +0 -448
- data/legacy-docs/index.md +0 -1
- data/legacy-docs/installation.md +0 -11
- data/legacy-docs/usage.md +0 -27
- data/mkdocs.yml +0 -13
- data/readthedocs.yml +0 -5
- data/relnotes/v0.1.0.md +0 -7
- data/relnotes/v0.10.0.md +0 -21
- data/relnotes/v0.10.1.md +0 -5
- data/relnotes/v0.10.2.md +0 -5
- data/relnotes/v0.10.3.md +0 -5
- data/relnotes/v0.11.0.md +0 -16
- data/relnotes/v0.11.1.md +0 -5
- data/relnotes/v0.12.0.md +0 -10
- data/relnotes/v0.12.1.md +0 -5
- data/relnotes/v0.13.0.md +0 -5
- data/relnotes/v0.14.0.md +0 -5
- data/relnotes/v0.15.0.md +0 -5
- data/relnotes/v0.15.1.md +0 -5
- data/relnotes/v0.15.2.md +0 -5
- data/relnotes/v0.16.0.md +0 -11
- data/relnotes/v0.17.0.md +0 -5
- data/relnotes/v0.17.1.md +0 -5
- data/relnotes/v0.17.2.md +0 -5
- data/relnotes/v0.18.0.md +0 -9
- data/relnotes/v0.19.0.md +0 -5
- data/relnotes/v0.19.1.md +0 -5
- data/relnotes/v0.2.0.md +0 -9
- data/relnotes/v0.2.1.md +0 -5
- data/relnotes/v0.20.0.md +0 -13
- data/relnotes/v0.20.1.md +0 -5
- data/relnotes/v0.21.0.md +0 -5
- data/relnotes/v0.21.1.md +0 -5
- data/relnotes/v0.3.0.md +0 -16
- data/relnotes/v0.4.0.md +0 -14
- data/relnotes/v0.4.1.md +0 -5
- data/relnotes/v0.5.0.md +0 -5
- data/relnotes/v0.5.1.md +0 -5
- data/relnotes/v0.6.0.md +0 -5
- data/relnotes/v0.6.1.md +0 -6
- data/relnotes/v0.6.2.md +0 -5
- data/relnotes/v0.7.0.md +0 -13
- data/relnotes/v0.8.0.md +0 -12
- data/relnotes/v0.8.1.md +0 -5
- data/relnotes/v0.9.0.md +0 -10
- data/rubocop-minitest.gemspec +0 -40
- data/tasks/changelog.rake +0 -34
- data/tasks/changelog.rb +0 -166
- data/tasks/cops_documentation.rake +0 -50
- data/tasks/cut_release.rake +0 -86
data/relnotes/v0.14.0.md
DELETED
data/relnotes/v0.15.0.md
DELETED
data/relnotes/v0.15.1.md
DELETED
data/relnotes/v0.15.2.md
DELETED
data/relnotes/v0.16.0.md
DELETED
@@ -1,11 +0,0 @@
|
|
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
DELETED
data/relnotes/v0.17.1.md
DELETED
data/relnotes/v0.17.2.md
DELETED
data/relnotes/v0.18.0.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
### New features
|
2
|
-
|
3
|
-
* [#161](https://github.com/rubocop/rubocop-minitest/pull/161): Add new `Minitest/AssertPredicate` and `Minitest/RefutePredicate` cops. ([@koic][])
|
4
|
-
|
5
|
-
### Changes
|
6
|
-
|
7
|
-
* [#162](https://github.com/rubocop/rubocop-minitest/pull/162): Make `Minitest/AssertNil` (`Minitest/RefuteNil`) aware of `assert_predicate(obj, :nil?)` (`refute_predicate(obj, :nil?)`). ([@koic][])
|
8
|
-
|
9
|
-
[@koic]: https://github.com/koic
|
data/relnotes/v0.19.0.md
DELETED
data/relnotes/v0.19.1.md
DELETED
data/relnotes/v0.2.0.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
### New features
|
2
|
-
|
3
|
-
* [#11](https://github.com/rubocop/rubocop-minitest/pull/11): Add new `Minitest/RefuteNil` cop. ([@tejasbubane ][])
|
4
|
-
* [#8](https://github.com/rubocop/rubocop-minitest/pull/8): Add new `Minitest/AssertTruthy` cop. ([@abhaynikam ][])
|
5
|
-
* [#9](https://github.com/rubocop/rubocop-minitest/pull/9): Add new `Minitest/AssertIncludes` cop. ([@abhaynikam ][])
|
6
|
-
* [#10](https://github.com/rubocop/rubocop-minitest/pull/10): Add new `Minitest/AssertEmpty` cop. ([@abhaynikam ][])
|
7
|
-
|
8
|
-
[@tejasbubane]: https://github.com/tejasbubane
|
9
|
-
[@abhaynikam]: https://github.com/abhaynikam
|
data/relnotes/v0.2.1.md
DELETED
data/relnotes/v0.20.0.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
### New features
|
2
|
-
|
3
|
-
* [#169](https://github.com/rubocop/rubocop-minitest/issues/169): Add new `Minitest/SkipEnsure` cop. ([@koic][])
|
4
|
-
|
5
|
-
### Bug fixes
|
6
|
-
|
7
|
-
* [#172](https://github.com/rubocop/rubocop-minitest/issues/172): Fix a false positive for `Minitest/AssertPredicate` and `Minitest/RefutePredicate` when using numbered parameters. ([@koic][])
|
8
|
-
|
9
|
-
### Changes
|
10
|
-
|
11
|
-
* [#168](https://github.com/rubocop/rubocop-minitest/pull/168): **(Compatibility)** Drop Ruby 2.5 support. ([@koic][])
|
12
|
-
|
13
|
-
[@koic]: https://github.com/koic
|
data/relnotes/v0.20.1.md
DELETED
data/relnotes/v0.21.0.md
DELETED
data/relnotes/v0.21.1.md
DELETED
data/relnotes/v0.3.0.md
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
## 0.3.0 (2019-10-13)
|
2
|
-
|
3
|
-
### New features
|
4
|
-
|
5
|
-
* [#15](https://github.com/rubocop/rubocop-minitest/pull/15): Add new `Minitest/RefuteIncludes` cop. ([@abhaynikam][])
|
6
|
-
* [#18](https://github.com/rubocop/rubocop-minitest/pull/18): Add new `Minitest/RefuteFalse` cop. ([@duduribeiro][])
|
7
|
-
* [#20](https://github.com/rubocop/rubocop-minitest/pull/20): Add new `Minitest/RefuteEmpty` cop. ([@abhaynikam][])
|
8
|
-
* [#21](https://github.com/rubocop/rubocop-minitest/pull/21): Add new `Minitest/RefuteEqual` cop. ([@duduribeiro][])
|
9
|
-
* [#27](https://github.com/rubocop/rubocop-minitest/pull/27): Add new `Minitest/AssertRespondTo` cop. ([@duduribeiro][])
|
10
|
-
|
11
|
-
### Bug fixes
|
12
|
-
|
13
|
-
* [#19](https://github.com/rubocop/rubocop-minitest/pull/19): Fix a false negative for `Minitest/AssertIncludes` when using `include` method in arguments of `assert` method. ([@abhaynikam][])
|
14
|
-
|
15
|
-
[@abhaynikam]: https://github.com/abhaynikam
|
16
|
-
[@duduribeiro]: https://github.com/duduribeiro
|
data/relnotes/v0.4.0.md
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
### New features
|
2
|
-
|
3
|
-
* [#29](https://github.com/rubocop/rubocop-minitest/pull/29): Add new `Minitest/RefuteRespondTo` cop. ([@herwinw][])
|
4
|
-
* [#31](https://github.com/rubocop/rubocop-minitest/pull/31): Add new `Minitest/AssertEqual` cop. ([@herwinw][])
|
5
|
-
* [#34](https://github.com/rubocop/rubocop-minitest/pull/34): Add new `Minitest/AssertInstanceOf` cop. ([@abhaynikam][])
|
6
|
-
* [#35](https://github.com/rubocop/rubocop-minitest/pull/35): Add new `Minitest/RefuteInstanceOf` cop. ([@abhaynikam][])
|
7
|
-
|
8
|
-
### Bug fixes
|
9
|
-
|
10
|
-
* [#25](https://github.com/rubocop/rubocop-minitest/issues/25): Add `Enabled: true` to `Minitest` department config to suppress `Warning: Minitest does not support Enabled parameter`. ([@koic][])
|
11
|
-
|
12
|
-
[@herwinw]: https://github.com/herwinw
|
13
|
-
[@abhaynikam]: https://github.com/abhaynikam
|
14
|
-
[@koic]: https://github.com/koic
|
data/relnotes/v0.4.1.md
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
### Bug fixes
|
2
|
-
|
3
|
-
* [#39](https://github.com/rubocop/rubocop-minitest/issues/39): Fix an incorrect autocorrect for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo` when using assertion method calling `respond_to` with receiver omitted. ([@koic][])
|
4
|
-
|
5
|
-
[@koic]: https://github.com/koic
|
data/relnotes/v0.5.0.md
DELETED
data/relnotes/v0.5.1.md
DELETED
data/relnotes/v0.6.0.md
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
### New features
|
2
|
-
|
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
|
-
|
5
|
-
[@fsateler]: https://github.com/fsateler
|
data/relnotes/v0.6.1.md
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
### Bug fixes
|
2
|
-
|
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
|
-
|
6
|
-
[@koic]: https://github.com/koic
|
data/relnotes/v0.6.2.md
DELETED
data/relnotes/v0.7.0.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
### New features
|
2
|
-
|
3
|
-
* [#60](https://github.com/rubocop/rubocop-minitest/issues/60): Add new cop `Minitest/GlobalExpectations` to check for deprecated global expectations. ([@tejasbubane][])
|
4
|
-
|
5
|
-
### Bug fixes
|
6
|
-
|
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
|
-
|
12
|
-
[@tejasbubane]: https://github.com/tejasbubane
|
13
|
-
[@koic]: https://github.com/koic
|
data/relnotes/v0.8.0.md
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
### New features
|
2
|
-
|
3
|
-
* [#66](https://github.com/rubocop/rubocop-minitest/issues/66): Support all expectations of `Minitest::Expectations` for `Minitest/GlobalExpectations` cop. ([@koic][])
|
4
|
-
|
5
|
-
### Bug fixes
|
6
|
-
|
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
|
-
|
11
|
-
[@koic]: https://github.com/koic
|
12
|
-
[@tejasbubane]: https://github.com/tejasbubane
|
data/relnotes/v0.8.1.md
DELETED
data/relnotes/v0.9.0.md
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
### Bug fixes
|
2
|
-
|
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
|
-
|
5
|
-
### Changes
|
6
|
-
|
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): **(Compatibility)** Drop support for Ruby 2.3. ([@koic][])
|
9
|
-
|
10
|
-
[@koic]: https://github.com/koic
|
data/rubocop-minitest.gemspec
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path('lib', __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'rubocop/minitest/version'
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = 'rubocop-minitest'
|
9
|
-
spec.version = RuboCop::Minitest::Version::STRING
|
10
|
-
spec.authors = ['Bozhidar Batsov', 'Jonas Arvidsson', 'Koichi ITO']
|
11
|
-
|
12
|
-
spec.summary = 'Automatic Minitest code style checking tool.'
|
13
|
-
spec.description = <<~DESCRIPTION
|
14
|
-
Automatic Minitest code style checking tool.
|
15
|
-
A RuboCop extension focused on enforcing Minitest best practices and coding conventions.
|
16
|
-
DESCRIPTION
|
17
|
-
spec.license = 'MIT'
|
18
|
-
|
19
|
-
spec.required_ruby_version = '>= 2.6.0'
|
20
|
-
spec.metadata = {
|
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
|
-
'rubygems_mfa_required' => 'true'
|
27
|
-
}
|
28
|
-
|
29
|
-
# Specify which files should be added to the gem when it is released.
|
30
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
32
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
-
end
|
34
|
-
spec.bindir = 'exe'
|
35
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
-
spec.require_paths = ['lib']
|
37
|
-
|
38
|
-
spec.add_runtime_dependency 'rubocop', '>= 0.90', '< 2.0'
|
39
|
-
spec.add_development_dependency 'minitest', '~> 5.11'
|
40
|
-
end
|
data/tasks/changelog.rake
DELETED
@@ -1,34 +0,0 @@
|
|
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
DELETED
@@ -1,166 +0,0 @@
|
|
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
|
-
FileUtils.mkdir_p(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
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yard'
|
4
|
-
require 'rubocop'
|
5
|
-
require 'rubocop-minitest'
|
6
|
-
require 'rubocop/cops_documentation_generator'
|
7
|
-
|
8
|
-
YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
|
9
|
-
task.files = ['lib/rubocop/cop/**/*.rb']
|
10
|
-
task.options = ['--no-output']
|
11
|
-
end
|
12
|
-
|
13
|
-
task update_cops_documentation: :yard_for_generate_documentation do
|
14
|
-
deps = ['Minitest']
|
15
|
-
|
16
|
-
# NOTE: Update `<<next>>` version for docs/modules/ROOT/pages/cops_minitest.adoc
|
17
|
-
# when running release tasks.
|
18
|
-
RuboCop::Minitest::Inject.defaults!
|
19
|
-
|
20
|
-
CopsDocumentationGenerator.new(departments: deps).call
|
21
|
-
end
|
22
|
-
|
23
|
-
desc 'Syntax check for the documentation comments'
|
24
|
-
task documentation_syntax_check: :yard_for_generate_documentation do
|
25
|
-
require 'parser/ruby31'
|
26
|
-
|
27
|
-
ok = true
|
28
|
-
YARD::Registry.load!
|
29
|
-
cops = RuboCop::Cop::Registry.global
|
30
|
-
cops.each do |cop|
|
31
|
-
examples = YARD::Registry.all(:class).find do |code_object|
|
32
|
-
next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
|
33
|
-
|
34
|
-
break code_object.tags('example')
|
35
|
-
end
|
36
|
-
|
37
|
-
examples.to_a.each do |example|
|
38
|
-
buffer = Parser::Source::Buffer.new('<code>', 1)
|
39
|
-
buffer.source = example.text
|
40
|
-
parser = Parser::Ruby31.new(RuboCop::AST::Builder.new)
|
41
|
-
parser.diagnostics.all_errors_are_fatal = true
|
42
|
-
parser.parse(buffer)
|
43
|
-
rescue Parser::SyntaxError => e
|
44
|
-
path = example.object.file
|
45
|
-
puts "#{path}: Syntax Error in an example. #{e}"
|
46
|
-
ok = false
|
47
|
-
end
|
48
|
-
end
|
49
|
-
abort unless ok
|
50
|
-
end
|
data/tasks/cut_release.rake
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bump'
|
4
|
-
|
5
|
-
namespace :cut_release do
|
6
|
-
%w[major minor patch pre].each do |release_type|
|
7
|
-
desc "Cut a new #{release_type} release, create release notes and update documents."
|
8
|
-
task release_type => 'changelog:check_clean' do
|
9
|
-
run(release_type)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def add_header_to_changelog(version)
|
14
|
-
changelog = File.read('CHANGELOG.md')
|
15
|
-
head, tail = changelog.split("## master (unreleased)\n\n", 2)
|
16
|
-
|
17
|
-
File.open('CHANGELOG.md', 'w') do |f|
|
18
|
-
f << head
|
19
|
-
f << "## master (unreleased)\n\n"
|
20
|
-
f << "## #{version} (#{Time.now.strftime('%F')})\n\n"
|
21
|
-
f << tail
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def create_release_notes(version)
|
26
|
-
release_notes = new_version_changes.strip
|
27
|
-
contributor_links = user_links(release_notes)
|
28
|
-
|
29
|
-
File.open("relnotes/v#{version}.md", 'w') do |file|
|
30
|
-
file << release_notes
|
31
|
-
file << "\n\n"
|
32
|
-
file << contributor_links
|
33
|
-
file << "\n"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def update_antora_yml(new_version)
|
38
|
-
antora_metadata = File.read('docs/antora.yml')
|
39
|
-
|
40
|
-
File.open('docs/antora.yml', 'w') do |f|
|
41
|
-
f << antora_metadata.sub('version: ~', "version: '#{version_sans_patch(new_version)}'")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def version_sans_patch(version)
|
46
|
-
version.split('.').take(2).join('.')
|
47
|
-
end
|
48
|
-
|
49
|
-
# Replace `<<next>>` (and variations) with version being cut.
|
50
|
-
def update_cop_versions(_old_version, new_version)
|
51
|
-
update_file('config/default.yml') do |default|
|
52
|
-
default.gsub(/['"]?<<\s*next\s*>>['"]?/i, "'#{version_sans_patch(new_version)}'")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def new_version_changes
|
57
|
-
changelog = File.read('CHANGELOG.md')
|
58
|
-
_, _, new_changes, _older_changes = changelog.split(/^## .*$/, 4)
|
59
|
-
new_changes
|
60
|
-
end
|
61
|
-
|
62
|
-
def update_file(path)
|
63
|
-
content = File.read(path)
|
64
|
-
File.write(path, yield(content))
|
65
|
-
end
|
66
|
-
|
67
|
-
def user_links(text)
|
68
|
-
names = text.scan(/\[@(\S+)\]\[\]/).map(&:first).uniq
|
69
|
-
names.map { |name| "[@#{name}]: https://github.com/#{name}" }.join("\n")
|
70
|
-
end
|
71
|
-
|
72
|
-
def run(release_type)
|
73
|
-
old_version = Bump::Bump.current
|
74
|
-
Bump::Bump.run(release_type, commit: false, bundle: false, tag: false)
|
75
|
-
new_version = Bump::Bump.current
|
76
|
-
|
77
|
-
update_cop_versions(old_version, new_version)
|
78
|
-
Rake::Task['update_cops_documentation'].invoke
|
79
|
-
|
80
|
-
add_header_to_changelog(new_version)
|
81
|
-
create_release_notes(new_version)
|
82
|
-
update_antora_yml(new_version)
|
83
|
-
|
84
|
-
puts "Changed version from #{old_version} to #{new_version}."
|
85
|
-
end
|
86
|
-
end
|