rubocop-minitest 0.6.2 → 0.10.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 +5 -5
- data/.circleci/config.yml +0 -3
- data/.gitattributes +1 -0
- data/.rubocop.yml +2 -1
- data/.rubocop_todo.yml +0 -7
- data/CHANGELOG.md +65 -0
- data/Gemfile +1 -1
- data/README.md +5 -1
- data/Rakefile +29 -0
- data/config/default.yml +103 -18
- data/docs/antora.yml +7 -0
- data/docs/modules/ROOT/nav.adoc +6 -0
- data/docs/modules/ROOT/pages/cops.adoc +37 -0
- data/docs/modules/ROOT/pages/cops_minitest.adoc +1014 -0
- data/docs/modules/ROOT/pages/index.adoc +5 -0
- data/docs/modules/ROOT/pages/installation.adoc +15 -0
- data/docs/modules/ROOT/pages/usage.adoc +32 -0
- data/{manual → legacy-docs}/cops.md +1 -0
- data/{manual → legacy-docs}/cops_minitest.md +64 -41
- data/{manual → legacy-docs}/index.md +0 -0
- data/{manual → legacy-docs}/installation.md +0 -0
- data/{manual → legacy-docs}/usage.md +0 -0
- data/lib/rubocop/cop/generator.rb +56 -0
- data/lib/rubocop/cop/minitest/assert_empty.rb +4 -30
- data/lib/rubocop/cop/minitest/assert_empty_literal.rb +15 -0
- data/lib/rubocop/cop/minitest/assert_equal.rb +2 -31
- data/lib/rubocop/cop/minitest/assert_in_delta.rb +27 -0
- data/lib/rubocop/cop/minitest/assert_includes.rb +4 -4
- data/lib/rubocop/cop/minitest/assert_instance_of.rb +4 -38
- data/lib/rubocop/cop/minitest/assert_kind_of.rb +25 -0
- data/lib/rubocop/cop/minitest/assert_match.rb +4 -39
- data/lib/rubocop/cop/minitest/assert_nil.rb +2 -2
- data/lib/rubocop/cop/minitest/assert_output.rb +49 -0
- data/lib/rubocop/cop/minitest/assert_path_exists.rb +58 -0
- data/lib/rubocop/cop/minitest/assert_respond_to.rb +10 -45
- data/lib/rubocop/cop/minitest/assert_silent.rb +45 -0
- data/lib/rubocop/cop/minitest/assert_truthy.rb +2 -2
- data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +43 -0
- data/lib/rubocop/cop/minitest/global_expectations.rb +95 -0
- data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +52 -0
- data/lib/rubocop/cop/minitest/multiple_assertions.rb +63 -0
- data/lib/rubocop/cop/minitest/refute_empty.rb +4 -30
- data/lib/rubocop/cop/minitest/refute_false.rb +3 -3
- data/lib/rubocop/cop/minitest/refute_in_delta.rb +27 -0
- data/lib/rubocop/cop/minitest/refute_includes.rb +4 -4
- data/lib/rubocop/cop/minitest/refute_instance_of.rb +4 -38
- data/lib/rubocop/cop/minitest/refute_kind_of.rb +25 -0
- data/lib/rubocop/cop/minitest/refute_match.rb +4 -39
- data/lib/rubocop/cop/minitest/refute_nil.rb +2 -2
- data/lib/rubocop/cop/minitest/refute_path_exists.rb +58 -0
- data/lib/rubocop/cop/minitest/refute_respond_to.rb +10 -45
- data/lib/rubocop/cop/minitest/test_method_name.rb +70 -0
- data/lib/rubocop/cop/minitest/unspecified_exception.rb +36 -0
- data/lib/rubocop/cop/minitest_cops.rb +17 -1
- data/lib/rubocop/cop/mixin/argument_range_helper.rb +10 -0
- data/lib/rubocop/cop/mixin/in_delta_mixin.rb +50 -0
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +102 -0
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +84 -0
- data/lib/rubocop/minitest/version.rb +1 -1
- data/mkdocs.yml +2 -2
- data/relnotes/v0.10.0.md +21 -0
- data/relnotes/v0.6.2.md +5 -0
- data/relnotes/v0.7.0.md +13 -0
- data/relnotes/v0.8.0.md +12 -0
- data/relnotes/v0.8.1.md +5 -0
- data/relnotes/v0.9.0.md +10 -0
- data/rubocop-minitest.gemspec +4 -4
- data/tasks/cops_documentation.rake +83 -52
- data/tasks/cut_release.rake +16 -0
- metadata +45 -15
- data/lib/rubocop/cop/mixin/includes_cop_rule.rb +0 -78
data/tasks/cut_release.rake
CHANGED
@@ -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
|
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.10.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: 2020-
|
13
|
+
date: 2020-07-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0.
|
21
|
+
version: '0.87'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '0.
|
28
|
+
version: '0.87'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: minitest
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,6 +49,7 @@ extensions: []
|
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
51
|
- ".circleci/config.yml"
|
52
|
+
- ".gitattributes"
|
52
53
|
- ".github/FUNDING.yml"
|
53
54
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
54
55
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
@@ -65,38 +66,63 @@ files:
|
|
65
66
|
- bin/console
|
66
67
|
- bin/setup
|
67
68
|
- config/default.yml
|
69
|
+
- docs/antora.yml
|
70
|
+
- docs/modules/ROOT/nav.adoc
|
71
|
+
- docs/modules/ROOT/pages/cops.adoc
|
72
|
+
- docs/modules/ROOT/pages/cops_minitest.adoc
|
73
|
+
- docs/modules/ROOT/pages/index.adoc
|
74
|
+
- docs/modules/ROOT/pages/installation.adoc
|
75
|
+
- docs/modules/ROOT/pages/usage.adoc
|
76
|
+
- legacy-docs/cops.md
|
77
|
+
- legacy-docs/cops_minitest.md
|
78
|
+
- legacy-docs/index.md
|
79
|
+
- legacy-docs/installation.md
|
80
|
+
- legacy-docs/usage.md
|
68
81
|
- lib/rubocop-minitest.rb
|
82
|
+
- lib/rubocop/cop/generator.rb
|
69
83
|
- lib/rubocop/cop/minitest/assert_empty.rb
|
70
84
|
- lib/rubocop/cop/minitest/assert_empty_literal.rb
|
71
85
|
- lib/rubocop/cop/minitest/assert_equal.rb
|
86
|
+
- lib/rubocop/cop/minitest/assert_in_delta.rb
|
72
87
|
- lib/rubocop/cop/minitest/assert_includes.rb
|
73
88
|
- lib/rubocop/cop/minitest/assert_instance_of.rb
|
89
|
+
- lib/rubocop/cop/minitest/assert_kind_of.rb
|
74
90
|
- lib/rubocop/cop/minitest/assert_match.rb
|
75
91
|
- lib/rubocop/cop/minitest/assert_nil.rb
|
92
|
+
- lib/rubocop/cop/minitest/assert_output.rb
|
93
|
+
- lib/rubocop/cop/minitest/assert_path_exists.rb
|
76
94
|
- lib/rubocop/cop/minitest/assert_respond_to.rb
|
95
|
+
- lib/rubocop/cop/minitest/assert_silent.rb
|
77
96
|
- lib/rubocop/cop/minitest/assert_truthy.rb
|
97
|
+
- lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb
|
98
|
+
- lib/rubocop/cop/minitest/global_expectations.rb
|
99
|
+
- lib/rubocop/cop/minitest/literal_as_actual_argument.rb
|
100
|
+
- lib/rubocop/cop/minitest/multiple_assertions.rb
|
78
101
|
- lib/rubocop/cop/minitest/refute_empty.rb
|
79
102
|
- lib/rubocop/cop/minitest/refute_equal.rb
|
80
103
|
- lib/rubocop/cop/minitest/refute_false.rb
|
104
|
+
- lib/rubocop/cop/minitest/refute_in_delta.rb
|
81
105
|
- lib/rubocop/cop/minitest/refute_includes.rb
|
82
106
|
- lib/rubocop/cop/minitest/refute_instance_of.rb
|
107
|
+
- lib/rubocop/cop/minitest/refute_kind_of.rb
|
83
108
|
- lib/rubocop/cop/minitest/refute_match.rb
|
84
109
|
- lib/rubocop/cop/minitest/refute_nil.rb
|
110
|
+
- lib/rubocop/cop/minitest/refute_path_exists.rb
|
85
111
|
- lib/rubocop/cop/minitest/refute_respond_to.rb
|
112
|
+
- lib/rubocop/cop/minitest/test_method_name.rb
|
113
|
+
- lib/rubocop/cop/minitest/unspecified_exception.rb
|
86
114
|
- lib/rubocop/cop/minitest_cops.rb
|
87
115
|
- lib/rubocop/cop/mixin/argument_range_helper.rb
|
88
|
-
- lib/rubocop/cop/mixin/
|
116
|
+
- lib/rubocop/cop/mixin/in_delta_mixin.rb
|
117
|
+
- lib/rubocop/cop/mixin/minitest_cop_rule.rb
|
118
|
+
- lib/rubocop/cop/mixin/minitest_exploration_helpers.rb
|
89
119
|
- lib/rubocop/minitest.rb
|
90
120
|
- lib/rubocop/minitest/inject.rb
|
91
121
|
- lib/rubocop/minitest/version.rb
|
92
|
-
- manual/cops.md
|
93
|
-
- manual/cops_minitest.md
|
94
|
-
- manual/index.md
|
95
|
-
- manual/installation.md
|
96
|
-
- manual/usage.md
|
97
122
|
- mkdocs.yml
|
98
123
|
- readthedocs.yml
|
99
124
|
- relnotes/v0.1.0.md
|
125
|
+
- relnotes/v0.10.0.md
|
100
126
|
- relnotes/v0.2.0.md
|
101
127
|
- relnotes/v0.2.1.md
|
102
128
|
- relnotes/v0.3.0.md
|
@@ -106,6 +132,11 @@ files:
|
|
106
132
|
- relnotes/v0.5.1.md
|
107
133
|
- relnotes/v0.6.0.md
|
108
134
|
- relnotes/v0.6.1.md
|
135
|
+
- relnotes/v0.6.2.md
|
136
|
+
- relnotes/v0.7.0.md
|
137
|
+
- relnotes/v0.8.0.md
|
138
|
+
- relnotes/v0.8.1.md
|
139
|
+
- relnotes/v0.9.0.md
|
109
140
|
- rubocop-minitest.gemspec
|
110
141
|
- tasks/cops_documentation.rake
|
111
142
|
- tasks/cut_release.rake
|
@@ -113,10 +144,10 @@ homepage:
|
|
113
144
|
licenses:
|
114
145
|
- MIT
|
115
146
|
metadata:
|
116
|
-
homepage_uri: https://docs.rubocop.org/
|
147
|
+
homepage_uri: https://docs.rubocop.org/rubocop-minitest/
|
117
148
|
changelog_uri: https://github.com/rubocop-hq/rubocop-minitest/blob/master/CHANGELOG.md
|
118
149
|
source_code_uri: https://github.com/rubocop-hq/rubocop-minitest
|
119
|
-
documentation_uri: https://docs.rubocop.org/
|
150
|
+
documentation_uri: https://docs.rubocop.org/rubocop-minitest/
|
120
151
|
bug_tracker_uri: https://github.com/rubocop-hq/rubocop-minitest/issues
|
121
152
|
post_install_message:
|
122
153
|
rdoc_options: []
|
@@ -126,15 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
157
|
requirements:
|
127
158
|
- - ">="
|
128
159
|
- !ruby/object:Gem::Version
|
129
|
-
version: 2.
|
160
|
+
version: 2.4.0
|
130
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
162
|
requirements:
|
132
163
|
- - ">="
|
133
164
|
- !ruby/object:Gem::Version
|
134
165
|
version: '0'
|
135
166
|
requirements: []
|
136
|
-
|
137
|
-
rubygems_version: 2.5.2.3
|
167
|
+
rubygems_version: 3.1.2
|
138
168
|
signing_key:
|
139
169
|
specification_version: 4
|
140
170
|
summary: Automatic Minitest code style checking tool.
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
# Define the rule for `Minitest/AssertIncludes` and `Minitest/RefuteIncludes` cops.
|
6
|
-
module IncludesCopRule
|
7
|
-
def rule(target_method:, prefer_method:)
|
8
|
-
class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
9
|
-
include ArgumentRangeHelper
|
10
|
-
|
11
|
-
MSG = 'Prefer using `#{prefer_method}(%<new_arguments>s)` over ' \
|
12
|
-
'`#{target_method}(%<original_arguments>s)`.'
|
13
|
-
|
14
|
-
def on_send(node)
|
15
|
-
return unless node.method?(:#{target_method})
|
16
|
-
return unless (arguments = peel_redundant_parentheses_from(node.arguments))
|
17
|
-
return unless arguments.first.respond_to?(:method?) && arguments.first.method?(:include?)
|
18
|
-
|
19
|
-
add_offense(node, message: offense_message(arguments))
|
20
|
-
end
|
21
|
-
|
22
|
-
def autocorrect(node)
|
23
|
-
lambda do |corrector|
|
24
|
-
corrector.replace(node.loc.selector, '#{prefer_method}')
|
25
|
-
|
26
|
-
arguments = peel_redundant_parentheses_from(node.arguments)
|
27
|
-
|
28
|
-
new_arguments = [
|
29
|
-
arguments.first.receiver.source,
|
30
|
-
arguments.first.arguments.map(&:source)
|
31
|
-
].join(', ')
|
32
|
-
|
33
|
-
if enclosed_in_redundant_parentheses?(node)
|
34
|
-
new_arguments = '(' + new_arguments + ')'
|
35
|
-
end
|
36
|
-
|
37
|
-
corrector.replace(first_argument_range(node), new_arguments)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def peel_redundant_parentheses_from(arguments)
|
44
|
-
return arguments unless arguments.first.begin_type?
|
45
|
-
|
46
|
-
peel_redundant_parentheses_from(arguments.first.children)
|
47
|
-
end
|
48
|
-
|
49
|
-
def offense_message(arguments)
|
50
|
-
new_arguments = new_arguments(arguments)
|
51
|
-
|
52
|
-
original_arguments = arguments.map(&:source).join(', ')
|
53
|
-
|
54
|
-
format(
|
55
|
-
MSG,
|
56
|
-
new_arguments: new_arguments,
|
57
|
-
original_arguments: original_arguments
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
|
-
def new_arguments(arguments)
|
62
|
-
message_argument = arguments.last if arguments.first != arguments.last
|
63
|
-
|
64
|
-
[
|
65
|
-
arguments.first.receiver,
|
66
|
-
arguments.first.arguments.first,
|
67
|
-
message_argument
|
68
|
-
].compact.map(&:source).join(', ')
|
69
|
-
end
|
70
|
-
|
71
|
-
def enclosed_in_redundant_parentheses?(node)
|
72
|
-
node.arguments.first.begin_type?
|
73
|
-
end
|
74
|
-
RUBY
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|