rubocop-minitest 0.13.0 → 0.14.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/.rubocop.yml +13 -0
- data/CHANGELOG.md +6 -0
- data/config/default.yml +5 -0
- data/docs/antora.yml +1 -1
- data/docs/modules/ROOT/pages/cops.adoc +1 -0
- data/docs/modules/ROOT/pages/cops_minitest.adoc +32 -0
- data/lib/rubocop/cop/minitest/refute_false.rb +2 -4
- data/lib/rubocop/cop/minitest/unreachable_assertion.rb +42 -0
- data/lib/rubocop/cop/minitest_cops.rb +1 -0
- data/lib/rubocop/minitest/version.rb +1 -1
- data/relnotes/v0.14.0.md +5 -0
- data/tasks/cops_documentation.rake +1 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcdc752936f6002cc925a5ca82039770b2977685a53f182250b0cc75fffbb412
|
4
|
+
data.tar.gz: a634c0d0fa393ef7f00b07ebb8c17063df18c8e4d92643eb361699c1fa327097
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1879892d3bb7d99c4e2e1c483f1c9f93b990f55fecc71f5ae37b0193bfde0ae7167588d21fbf3a62abdfa26f4e88efc2655d0ddc4e0f078f23fe5f05843e95ca
|
7
|
+
data.tar.gz: c411392994e053920757c682c793defae132d9fd4e556c131f6c4a74fef3d93dca05fab0f3bd91a3081e038a943dd41a00b88626966b0c74928e97afa0cec65f
|
data/.rubocop.yml
CHANGED
@@ -23,6 +23,19 @@ Naming/PredicateName:
|
|
23
23
|
- def_node_matcher
|
24
24
|
- def_node_search
|
25
25
|
|
26
|
+
Naming/InclusiveLanguage:
|
27
|
+
FlaggedTerms:
|
28
|
+
whitelist:
|
29
|
+
Suggestions:
|
30
|
+
- allowlist
|
31
|
+
blacklist:
|
32
|
+
Suggestions:
|
33
|
+
- denylist
|
34
|
+
master:
|
35
|
+
AllowedRegex:
|
36
|
+
- 'blob/master/'
|
37
|
+
- 'master \(unreleased\)'
|
38
|
+
|
26
39
|
Style/FormatStringToken:
|
27
40
|
# Because we parse a lot of source codes from strings. Percent arrays
|
28
41
|
# look like unannotated format string tokens to this cop.
|
data/CHANGELOG.md
CHANGED
data/config/default.yml
CHANGED
@@ -194,6 +194,11 @@ Minitest/TestMethodName:
|
|
194
194
|
Enabled: 'pending'
|
195
195
|
VersionAdded: '0.10'
|
196
196
|
|
197
|
+
Minitest/UnreachableAssertion:
|
198
|
+
Description: 'This cop checks for an `assert_raises` block containing any unreachable assertions.'
|
199
|
+
Enabled: pending
|
200
|
+
VersionAdded: '0.14'
|
201
|
+
|
197
202
|
Minitest/UnspecifiedException:
|
198
203
|
Description: 'This cop checks for a specified error in `assert_raises`.'
|
199
204
|
StyleGuide: 'https://minitest.rubystyle.guide#unspecified-exception'
|
data/docs/antora.yml
CHANGED
@@ -45,6 +45,7 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide].
|
|
45
45
|
* xref:cops_minitest.adoc#minitestrefutepathexists[Minitest/RefutePathExists]
|
46
46
|
* xref:cops_minitest.adoc#minitestrefuterespondto[Minitest/RefuteRespondTo]
|
47
47
|
* xref:cops_minitest.adoc#minitesttestmethodname[Minitest/TestMethodName]
|
48
|
+
* xref:cops_minitest.adoc#minitestunreachableassertion[Minitest/UnreachableAssertion]
|
48
49
|
* xref:cops_minitest.adoc#minitestunspecifiedexception[Minitest/UnspecifiedException]
|
49
50
|
|
50
51
|
// END_COP_LIST
|
@@ -1053,6 +1053,38 @@ class FooTest < Minitest::Test
|
|
1053
1053
|
end
|
1054
1054
|
----
|
1055
1055
|
|
1056
|
+
== Minitest/UnreachableAssertion
|
1057
|
+
|
1058
|
+
|===
|
1059
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
1060
|
+
|
1061
|
+
| Pending
|
1062
|
+
| Yes
|
1063
|
+
| No
|
1064
|
+
| 0.14
|
1065
|
+
| -
|
1066
|
+
|===
|
1067
|
+
|
1068
|
+
This cop checks for `assert_raises` has an assertion method at
|
1069
|
+
the bottom of block because the assertion will be never reached.
|
1070
|
+
|
1071
|
+
=== Examples
|
1072
|
+
|
1073
|
+
[source,ruby]
|
1074
|
+
----
|
1075
|
+
# bad
|
1076
|
+
assert_raises FooError do
|
1077
|
+
obj.occur_error
|
1078
|
+
assert_equal('foo', obj.bar) # Never asserted.
|
1079
|
+
end
|
1080
|
+
|
1081
|
+
# good
|
1082
|
+
assert_raises FooError do
|
1083
|
+
obj.occur_error
|
1084
|
+
end
|
1085
|
+
assert_equal('foo', obj.bar)
|
1086
|
+
----
|
1087
|
+
|
1056
1088
|
== Minitest/UnspecifiedException
|
1057
1089
|
|
1058
1090
|
|===
|
@@ -22,10 +22,8 @@ module RuboCop
|
|
22
22
|
include ArgumentRangeHelper
|
23
23
|
extend AutoCorrector
|
24
24
|
|
25
|
-
MSG_FOR_ASSERT_EQUAL = 'Prefer using `refute(%<arguments>s)` over '
|
26
|
-
|
27
|
-
MSG_FOR_ASSERT = 'Prefer using `refute(%<arguments>s)` over ' \
|
28
|
-
'`assert(!%<arguments>s)`.'
|
25
|
+
MSG_FOR_ASSERT_EQUAL = 'Prefer using `refute(%<arguments>s)` over `assert_equal(false, %<arguments>s)`.'
|
26
|
+
MSG_FOR_ASSERT = 'Prefer using `refute(%<arguments>s)` over `assert(!%<arguments>s)`.'
|
29
27
|
RESTRICT_ON_SEND = %i[assert_equal assert].freeze
|
30
28
|
|
31
29
|
def_node_matcher :assert_equal_with_false, <<~PATTERN
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Minitest
|
6
|
+
# This cop checks for `assert_raises` has an assertion method at
|
7
|
+
# the bottom of block because the assertion will be never reached.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
#
|
11
|
+
# # bad
|
12
|
+
# assert_raises FooError do
|
13
|
+
# obj.occur_error
|
14
|
+
# assert_equal('foo', obj.bar) # Never asserted.
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# assert_raises FooError do
|
19
|
+
# obj.occur_error
|
20
|
+
# end
|
21
|
+
# assert_equal('foo', obj.bar)
|
22
|
+
#
|
23
|
+
class UnreachableAssertion < Base
|
24
|
+
include MinitestExplorationHelpers
|
25
|
+
|
26
|
+
MSG = 'Unreachable `%<assertion_method>s` detected.'
|
27
|
+
|
28
|
+
def on_block(node)
|
29
|
+
return unless node.method?(:assert_raises) && (body = node.body)
|
30
|
+
|
31
|
+
last_node = body.begin_type? ? body.children.last : body
|
32
|
+
return unless last_node.send_type?
|
33
|
+
|
34
|
+
method_name = last_node.method_name
|
35
|
+
return unless assertion_method?(method_name)
|
36
|
+
|
37
|
+
add_offense(last_node, message: format(MSG, assertion_method: method_name))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -36,4 +36,5 @@ require_relative 'minitest/refute_instance_of'
|
|
36
36
|
require_relative 'minitest/refute_path_exists'
|
37
37
|
require_relative 'minitest/refute_respond_to'
|
38
38
|
require_relative 'minitest/test_method_name'
|
39
|
+
require_relative 'minitest/unreachable_assertion'
|
39
40
|
require_relative 'minitest/unspecified_exception'
|
data/relnotes/v0.14.0.md
ADDED
@@ -25,8 +25,7 @@ task verify_cops_documentation: :generate_cops_documentation do
|
|
25
25
|
# Output diff before raising error
|
26
26
|
sh('GIT_PAGER=cat git diff docs')
|
27
27
|
|
28
|
-
warn 'The docs directory is out of sync. '
|
29
|
-
'Run `rake generate_cops_documentation` and commit the results.'
|
28
|
+
warn 'The docs directory is out of sync. Run `rake generate_cops_documentation` and commit the results.'
|
30
29
|
exit!
|
31
30
|
end
|
32
31
|
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.14.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-07-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/rubocop/cop/minitest/refute_path_exists.rb
|
119
119
|
- lib/rubocop/cop/minitest/refute_respond_to.rb
|
120
120
|
- lib/rubocop/cop/minitest/test_method_name.rb
|
121
|
+
- lib/rubocop/cop/minitest/unreachable_assertion.rb
|
121
122
|
- lib/rubocop/cop/minitest/unspecified_exception.rb
|
122
123
|
- lib/rubocop/cop/minitest_cops.rb
|
123
124
|
- lib/rubocop/cop/mixin/argument_range_helper.rb
|
@@ -139,6 +140,7 @@ files:
|
|
139
140
|
- relnotes/v0.12.0.md
|
140
141
|
- relnotes/v0.12.1.md
|
141
142
|
- relnotes/v0.13.0.md
|
143
|
+
- relnotes/v0.14.0.md
|
142
144
|
- relnotes/v0.2.0.md
|
143
145
|
- relnotes/v0.2.1.md
|
144
146
|
- relnotes/v0.3.0.md
|
@@ -163,7 +165,7 @@ metadata:
|
|
163
165
|
homepage_uri: https://docs.rubocop.org/rubocop-minitest/
|
164
166
|
changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
|
165
167
|
source_code_uri: https://github.com/rubocop/rubocop-minitest
|
166
|
-
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.
|
168
|
+
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.14
|
167
169
|
bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
|
168
170
|
post_install_message:
|
169
171
|
rdoc_options: []
|