rubocop-minitest 0.40.0 → 0.41.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/lib/rubocop/cop/minitest/assert_equal.rb +1 -2
- data/lib/rubocop/cop/minitest/assert_match.rb +1 -2
- data/lib/rubocop/cop/minitest/assert_same.rb +1 -2
- data/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb +1 -2
- data/lib/rubocop/cop/minitest/global_expectations.rb +24 -7
- data/lib/rubocop/cop/minitest/lifecycle_hooks_order.rb +1 -2
- data/lib/rubocop/cop/minitest/multiple_assertions.rb +8 -3
- data/lib/rubocop/cop/minitest/refute_equal.rb +1 -2
- data/lib/rubocop/cop/minitest/refute_match.rb +1 -2
- data/lib/rubocop/cop/minitest/refute_same.rb +1 -2
- data/lib/rubocop/cop/minitest/useless_assertion.rb +1 -2
- data/lib/rubocop/cop/minitest.rb +77 -0
- data/lib/rubocop/cop/minitest_cops.rb +4 -62
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +10 -3
- data/lib/rubocop/minitest/assert_offense.rb +5 -3
- data/lib/rubocop/minitest/version.rb +1 -1
- data/lib/rubocop-minitest.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecf18d07d25d4f364c0b5ea4292bbb07f3f06edb4b72f87771db2377ff86ef15
|
|
4
|
+
data.tar.gz: b5ae1ab24935cddcc5e42d1e69b0a2d67b711d23dca1fc4fd7694c7a8dd857a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd0ae54e3f23f3263904b4911312e73baefb19544dd8ece51949d933b5d97dc39774d82987c990ae9accbbfb98815938b38f85fa01790aefa8fa7478d7ef5ab9
|
|
7
|
+
data.tar.gz: b4896422846188b55f119070d4a618640f19e36caa3f8382c3cc809d09597c913f33ddb622f361e3c9cc0f728ce7435e7ab8d88ddb670528984ea702c1e31c07
|
|
@@ -28,7 +28,7 @@ module RuboCop
|
|
|
28
28
|
}
|
|
29
29
|
PATTERN
|
|
30
30
|
|
|
31
|
-
# rubocop:disable Metrics/AbcSize
|
|
31
|
+
# rubocop:disable-next Metrics/AbcSize
|
|
32
32
|
def on_send(node)
|
|
33
33
|
assert_equal(node) do |expected, actual, rest_args|
|
|
34
34
|
basic_arguments = "#{expected.source}, #{actual.source}"
|
|
@@ -48,7 +48,6 @@ module RuboCop
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
# rubocop:enable Metrics/AbcSize
|
|
52
51
|
end
|
|
53
52
|
end
|
|
54
53
|
end
|
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
|
32
32
|
}
|
|
33
33
|
PATTERN
|
|
34
34
|
|
|
35
|
-
# rubocop:disable Metrics/AbcSize
|
|
35
|
+
# rubocop:disable-next Metrics/AbcSize
|
|
36
36
|
def on_send(node)
|
|
37
37
|
assert_match(node) do |expected, actual, rest_args|
|
|
38
38
|
basic_arguments = order_expected_and_actual(expected, actual)
|
|
@@ -52,7 +52,6 @@ module RuboCop
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
|
-
# rubocop:enable Metrics/AbcSize
|
|
56
55
|
|
|
57
56
|
private
|
|
58
57
|
|
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
|
36
36
|
$_?)
|
|
37
37
|
PATTERN
|
|
38
38
|
|
|
39
|
-
# rubocop:disable Metrics/AbcSize
|
|
39
|
+
# rubocop:disable-next Metrics/AbcSize
|
|
40
40
|
def on_send(node)
|
|
41
41
|
if (equal_node, expected_node, actual_node, message_node = assert_with_equal?(node))
|
|
42
42
|
add_offense(node, message: message(expected_node, actual_node, message_node.first)) do |corrector|
|
|
@@ -51,7 +51,6 @@ module RuboCop
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
-
# rubocop:enable Metrics/AbcSize
|
|
55
54
|
|
|
56
55
|
private
|
|
57
56
|
|
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
|
23
23
|
|
|
24
24
|
MSG = 'Add empty line before assertion.'
|
|
25
25
|
|
|
26
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
|
26
|
+
# rubocop:disable-next Metrics/CyclomaticComplexity
|
|
27
27
|
def on_send(node)
|
|
28
28
|
return unless (assertion_method = assertion_method(node))
|
|
29
29
|
return unless (previous_line_node = assertion_method.left_sibling)
|
|
@@ -36,7 +36,6 @@ module RuboCop
|
|
|
36
36
|
|
|
37
37
|
register_offense(assertion_method, previous_line_node)
|
|
38
38
|
end
|
|
39
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
40
39
|
|
|
41
40
|
private
|
|
42
41
|
|
|
@@ -136,19 +136,36 @@ module RuboCop
|
|
|
136
136
|
|
|
137
137
|
def register_offense(node, method)
|
|
138
138
|
receiver = node.receiver
|
|
139
|
+
preferred = method ? preferred_method : preferred_receiver(node)
|
|
140
|
+
message = format(MSG, preferred: preferred)
|
|
141
|
+
|
|
142
|
+
add_offense(receiver, message: message) do |corrector|
|
|
143
|
+
autocorrect(corrector, node, receiver, method)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
139
146
|
|
|
147
|
+
# Replacing the whole receiver would overlap the correction of a matcher call nested
|
|
148
|
+
# in that receiver (`a.must_equal(b).must_equal(c)`), so only the DSL method selector
|
|
149
|
+
# is replaced and new DSL calls are wrapped around the receiver instead.
|
|
150
|
+
def autocorrect(corrector, node, receiver, method)
|
|
140
151
|
if method
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
corrector.replace(dsl_method_selector(receiver), preferred_method.to_s)
|
|
153
|
+
elsif BLOCK_MATCHERS.include?(node.method_name)
|
|
154
|
+
autocorrect_block_matcher(corrector, receiver)
|
|
143
155
|
else
|
|
144
|
-
|
|
145
|
-
replacement = preferred
|
|
156
|
+
corrector.wrap(receiver, "#{preferred_method}(", ')')
|
|
146
157
|
end
|
|
158
|
+
end
|
|
147
159
|
|
|
148
|
-
|
|
160
|
+
def dsl_method_selector(receiver)
|
|
161
|
+
receiver.block_type? ? receiver.send_node.loc.selector : receiver.loc.selector
|
|
162
|
+
end
|
|
149
163
|
|
|
150
|
-
|
|
151
|
-
|
|
164
|
+
def autocorrect_block_matcher(corrector, receiver)
|
|
165
|
+
if receiver.block_type? && receiver.lambda?
|
|
166
|
+
corrector.replace(receiver, "#{preferred_method} { #{receiver.body.source} }")
|
|
167
|
+
else
|
|
168
|
+
corrector.wrap(receiver, "#{preferred_method} { ", ' }')
|
|
152
169
|
end
|
|
153
170
|
end
|
|
154
171
|
end
|
|
@@ -56,7 +56,7 @@ module RuboCop
|
|
|
56
56
|
hash[hook] = LIFECYCLE_HOOK_METHODS_IN_ORDER.index(hook) || REGULAR_METHOD_POSITION
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
# rubocop:disable Metrics/MethodLength
|
|
59
|
+
# rubocop:disable-next Metrics/MethodLength
|
|
60
60
|
def on_class(class_node)
|
|
61
61
|
return unless test_class?(class_node)
|
|
62
62
|
|
|
@@ -77,7 +77,6 @@ module RuboCop
|
|
|
77
77
|
previous_hook_node = node
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
|
-
# rubocop:enable Metrics/MethodLength
|
|
81
80
|
|
|
82
81
|
private
|
|
83
82
|
|
|
@@ -67,10 +67,15 @@ module RuboCop
|
|
|
67
67
|
assertions_count(node.body) + assertions_count_in_branches(node.branches)
|
|
68
68
|
when :block, :numblock, :itblock
|
|
69
69
|
assertions_count(node.body)
|
|
70
|
-
when *RuboCop::AST::Node::ASSIGNMENTS
|
|
71
|
-
assertions_count_in_assignment(node)
|
|
72
70
|
else
|
|
73
|
-
node
|
|
71
|
+
# Splatting the `ASSIGNMENTS` Set into a `when` makes every other node pay a linear scan.
|
|
72
|
+
# Collapse it into the `case` once the gemspec floor is Ruby 3.1+, which supports `Set#===`.
|
|
73
|
+
return assertions_count_in_assignment(node) if RuboCop::AST::Node::ASSIGNMENTS.include?(node.type)
|
|
74
|
+
|
|
75
|
+
# `each_child_node` without a block allocates an Enumerator per node.
|
|
76
|
+
total = 0
|
|
77
|
+
node.each_child_node { |child| total += assertions_count(child) }
|
|
78
|
+
total
|
|
74
79
|
end
|
|
75
80
|
end
|
|
76
81
|
|
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
|
32
32
|
}
|
|
33
33
|
PATTERN
|
|
34
34
|
|
|
35
|
-
# rubocop:disable Metrics/AbcSize
|
|
35
|
+
# rubocop:disable-next Metrics/AbcSize
|
|
36
36
|
def on_send(node)
|
|
37
37
|
refute_equal(node) do |expected, actual, rest_args|
|
|
38
38
|
basic_arguments = "#{expected.source}, #{actual.source}"
|
|
@@ -52,7 +52,6 @@ module RuboCop
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
|
-
# rubocop:enable Metrics/AbcSize
|
|
56
55
|
end
|
|
57
56
|
end
|
|
58
57
|
end
|
|
@@ -34,7 +34,7 @@ module RuboCop
|
|
|
34
34
|
}
|
|
35
35
|
PATTERN
|
|
36
36
|
|
|
37
|
-
# rubocop:disable Metrics/AbcSize
|
|
37
|
+
# rubocop:disable-next Metrics/AbcSize
|
|
38
38
|
def on_send(node)
|
|
39
39
|
refute_match(node) do |expected, actual, rest_args|
|
|
40
40
|
basic_arguments = order_expected_and_actual(expected, actual)
|
|
@@ -54,7 +54,6 @@ module RuboCop
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
|
-
# rubocop:enable Metrics/AbcSize
|
|
58
57
|
|
|
59
58
|
private
|
|
60
59
|
|
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
|
36
36
|
$_?)
|
|
37
37
|
PATTERN
|
|
38
38
|
|
|
39
|
-
# rubocop:disable Metrics/AbcSize
|
|
39
|
+
# rubocop:disable-next Metrics/AbcSize
|
|
40
40
|
def on_send(node)
|
|
41
41
|
if (equal_node, expected_node, actual_node, message_node = refute_with_equal?(node))
|
|
42
42
|
add_offense(node, message: message(expected_node, actual_node, message_node.first)) do |corrector|
|
|
@@ -51,7 +51,6 @@ module RuboCop
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
-
# rubocop:enable Metrics/AbcSize
|
|
55
54
|
|
|
56
55
|
private
|
|
57
56
|
|
|
@@ -40,7 +40,7 @@ module RuboCop
|
|
|
40
40
|
|
|
41
41
|
private
|
|
42
42
|
|
|
43
|
-
# rubocop:disable Metrics
|
|
43
|
+
# rubocop:disable-next Metrics
|
|
44
44
|
def offense?(node)
|
|
45
45
|
expected, actual, = node.arguments
|
|
46
46
|
|
|
@@ -62,7 +62,6 @@ module RuboCop
|
|
|
62
62
|
false
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
|
-
# rubocop:enable Metrics
|
|
66
65
|
|
|
67
66
|
def empty_composite?(node)
|
|
68
67
|
return true if node.str_type? && node.value.empty?
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
# Mixins are autoloaded because they're used only when the relevant cop class is loaded.
|
|
6
|
+
autoload :ArgumentRangeHelper, "#{__dir__}/mixin/argument_range_helper"
|
|
7
|
+
autoload :InDeltaMixin, "#{__dir__}/mixin/in_delta_mixin"
|
|
8
|
+
autoload :MinitestCopRule, "#{__dir__}/mixin/minitest_cop_rule"
|
|
9
|
+
autoload :MinitestExplorationHelpers, "#{__dir__}/mixin/minitest_exploration_helpers"
|
|
10
|
+
|
|
11
|
+
# Cops for the `Minitest` department. The department's cops are registered for lazy loading and their files,
|
|
12
|
+
# along with the mixins they use, are loaded on demand.
|
|
13
|
+
module Minitest
|
|
14
|
+
autoload :InstanceOfAssertionHandleable, "#{__dir__}/mixin/instance_of_assertion_handleable"
|
|
15
|
+
autoload :NilAssertionHandleable, "#{__dir__}/mixin/nil_assertion_handleable"
|
|
16
|
+
autoload :PredicateAssertionHandleable, "#{__dir__}/mixin/predicate_assertion_handleable"
|
|
17
|
+
|
|
18
|
+
extend LazyLoader
|
|
19
|
+
|
|
20
|
+
register_cop :AssertEmpty, "#{__dir__}/minitest/assert_empty"
|
|
21
|
+
register_cop :AssertEmptyLiteral, "#{__dir__}/minitest/assert_empty_literal"
|
|
22
|
+
register_cop :AssertEqual, "#{__dir__}/minitest/assert_equal"
|
|
23
|
+
register_cop :AssertInDelta, "#{__dir__}/minitest/assert_in_delta"
|
|
24
|
+
register_cop :AssertOperator, "#{__dir__}/minitest/assert_operator"
|
|
25
|
+
register_cop :AssertPredicate, "#{__dir__}/minitest/assert_predicate"
|
|
26
|
+
register_cop :AssertRaisesCompoundBody, "#{__dir__}/minitest/assert_raises_compound_body"
|
|
27
|
+
register_cop :AssertRaisesWithRegexpArgument, "#{__dir__}/minitest/assert_raises_with_regexp_argument"
|
|
28
|
+
register_cop :AssertWithExpectedArgument, "#{__dir__}/minitest/assert_with_expected_argument"
|
|
29
|
+
register_cop :AssertionInLifecycleHook, "#{__dir__}/minitest/assertion_in_lifecycle_hook"
|
|
30
|
+
register_cop :AssertKindOf, "#{__dir__}/minitest/assert_kind_of"
|
|
31
|
+
register_cop :AssertNil, "#{__dir__}/minitest/assert_nil"
|
|
32
|
+
register_cop :AssertIncludes, "#{__dir__}/minitest/assert_includes"
|
|
33
|
+
register_cop :AssertInstanceOf, "#{__dir__}/minitest/assert_instance_of"
|
|
34
|
+
register_cop :AssertMatch, "#{__dir__}/minitest/assert_match"
|
|
35
|
+
register_cop :AssertOutput, "#{__dir__}/minitest/assert_output"
|
|
36
|
+
register_cop :AssertPathExists, "#{__dir__}/minitest/assert_path_exists"
|
|
37
|
+
register_cop :AssertRespondTo, "#{__dir__}/minitest/assert_respond_to"
|
|
38
|
+
register_cop :AssertSame, "#{__dir__}/minitest/assert_same"
|
|
39
|
+
register_cop :AssertSilent, "#{__dir__}/minitest/assert_silent"
|
|
40
|
+
register_cop :AssertTruthy, "#{__dir__}/minitest/assert_truthy"
|
|
41
|
+
register_cop :DuplicateTestRun, "#{__dir__}/minitest/duplicate_test_run"
|
|
42
|
+
register_cop :EmptyLineBeforeAssertionMethods, "#{__dir__}/minitest/empty_line_before_assertion_methods"
|
|
43
|
+
register_cop :Focus, "#{__dir__}/minitest/focus"
|
|
44
|
+
register_cop :NonExecutableTestMethod, "#{__dir__}/minitest/non_executable_test_method"
|
|
45
|
+
register_cop :RedundantMessageArgument, "#{__dir__}/minitest/redundant_message_argument"
|
|
46
|
+
register_cop :ReturnInTestMethod, "#{__dir__}/minitest/return_in_test_method"
|
|
47
|
+
register_cop :TestFileName, "#{__dir__}/minitest/test_file_name"
|
|
48
|
+
register_cop :GlobalExpectations, "#{__dir__}/minitest/global_expectations"
|
|
49
|
+
register_cop :LifecycleHooksOrder, "#{__dir__}/minitest/lifecycle_hooks_order"
|
|
50
|
+
register_cop :LiteralAsActualArgument, "#{__dir__}/minitest/literal_as_actual_argument"
|
|
51
|
+
register_cop :MultipleAssertions, "#{__dir__}/minitest/multiple_assertions"
|
|
52
|
+
register_cop :NoAssertions, "#{__dir__}/minitest/no_assertions"
|
|
53
|
+
register_cop :NoTestCases, "#{__dir__}/minitest/no_test_cases"
|
|
54
|
+
register_cop :NonPublicTestMethod, "#{__dir__}/minitest/non_public_test_method"
|
|
55
|
+
register_cop :RefuteEmpty, "#{__dir__}/minitest/refute_empty"
|
|
56
|
+
register_cop :RefuteFalse, "#{__dir__}/minitest/refute_false"
|
|
57
|
+
register_cop :RefuteEqual, "#{__dir__}/minitest/refute_equal"
|
|
58
|
+
register_cop :RefuteInDelta, "#{__dir__}/minitest/refute_in_delta"
|
|
59
|
+
register_cop :RefuteIncludes, "#{__dir__}/minitest/refute_includes"
|
|
60
|
+
register_cop :RefuteInstanceOf, "#{__dir__}/minitest/refute_instance_of"
|
|
61
|
+
register_cop :RefuteKindOf, "#{__dir__}/minitest/refute_kind_of"
|
|
62
|
+
register_cop :RefuteMatch, "#{__dir__}/minitest/refute_match"
|
|
63
|
+
register_cop :RefuteNil, "#{__dir__}/minitest/refute_nil"
|
|
64
|
+
register_cop :RefuteOperator, "#{__dir__}/minitest/refute_operator"
|
|
65
|
+
register_cop :RefutePathExists, "#{__dir__}/minitest/refute_path_exists"
|
|
66
|
+
register_cop :RefutePredicate, "#{__dir__}/minitest/refute_predicate"
|
|
67
|
+
register_cop :RefuteRespondTo, "#{__dir__}/minitest/refute_respond_to"
|
|
68
|
+
register_cop :RefuteSame, "#{__dir__}/minitest/refute_same"
|
|
69
|
+
register_cop :SkipEnsure, "#{__dir__}/minitest/skip_ensure"
|
|
70
|
+
register_cop :SkipWithoutReason, "#{__dir__}/minitest/skip_without_reason"
|
|
71
|
+
register_cop :TestMethodName, "#{__dir__}/minitest/test_method_name"
|
|
72
|
+
register_cop :UnreachableAssertion, "#{__dir__}/minitest/unreachable_assertion"
|
|
73
|
+
register_cop :UnspecifiedException, "#{__dir__}/minitest/unspecified_exception"
|
|
74
|
+
register_cop :UselessAssertion, "#{__dir__}/minitest/useless_assertion"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -1,64 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require_relative '
|
|
7
|
-
require_relative 'mixin/minitest_exploration_helpers'
|
|
8
|
-
require_relative 'mixin/nil_assertion_handleable'
|
|
9
|
-
require_relative 'mixin/predicate_assertion_handleable'
|
|
10
|
-
require_relative 'minitest/assert_empty'
|
|
11
|
-
require_relative 'minitest/assert_empty_literal'
|
|
12
|
-
require_relative 'minitest/assert_equal'
|
|
13
|
-
require_relative 'minitest/assert_in_delta'
|
|
14
|
-
require_relative 'minitest/assert_operator'
|
|
15
|
-
require_relative 'minitest/assert_predicate'
|
|
16
|
-
require_relative 'minitest/assert_raises_compound_body'
|
|
17
|
-
require_relative 'minitest/assert_raises_with_regexp_argument'
|
|
18
|
-
require_relative 'minitest/assert_with_expected_argument'
|
|
19
|
-
require_relative 'minitest/assertion_in_lifecycle_hook'
|
|
20
|
-
require_relative 'minitest/assert_kind_of'
|
|
21
|
-
require_relative 'minitest/assert_nil'
|
|
22
|
-
require_relative 'minitest/assert_includes'
|
|
23
|
-
require_relative 'minitest/assert_instance_of'
|
|
24
|
-
require_relative 'minitest/assert_match'
|
|
25
|
-
require_relative 'minitest/assert_output'
|
|
26
|
-
require_relative 'minitest/assert_path_exists'
|
|
27
|
-
require_relative 'minitest/assert_respond_to'
|
|
28
|
-
require_relative 'minitest/assert_same'
|
|
29
|
-
require_relative 'minitest/assert_silent'
|
|
30
|
-
require_relative 'minitest/assert_truthy'
|
|
31
|
-
require_relative 'minitest/duplicate_test_run'
|
|
32
|
-
require_relative 'minitest/empty_line_before_assertion_methods'
|
|
33
|
-
require_relative 'minitest/focus'
|
|
34
|
-
require_relative 'minitest/non_executable_test_method'
|
|
35
|
-
require_relative 'minitest/redundant_message_argument'
|
|
36
|
-
require_relative 'minitest/return_in_test_method'
|
|
37
|
-
require_relative 'minitest/test_file_name'
|
|
38
|
-
require_relative 'minitest/global_expectations'
|
|
39
|
-
require_relative 'minitest/lifecycle_hooks_order'
|
|
40
|
-
require_relative 'minitest/literal_as_actual_argument'
|
|
41
|
-
require_relative 'minitest/multiple_assertions'
|
|
42
|
-
require_relative 'minitest/no_assertions'
|
|
43
|
-
require_relative 'minitest/no_test_cases'
|
|
44
|
-
require_relative 'minitest/non_public_test_method'
|
|
45
|
-
require_relative 'minitest/refute_empty'
|
|
46
|
-
require_relative 'minitest/refute_false'
|
|
47
|
-
require_relative 'minitest/refute_equal'
|
|
48
|
-
require_relative 'minitest/refute_in_delta'
|
|
49
|
-
require_relative 'minitest/refute_includes'
|
|
50
|
-
require_relative 'minitest/refute_instance_of'
|
|
51
|
-
require_relative 'minitest/refute_kind_of'
|
|
52
|
-
require_relative 'minitest/refute_match'
|
|
53
|
-
require_relative 'minitest/refute_nil'
|
|
54
|
-
require_relative 'minitest/refute_operator'
|
|
55
|
-
require_relative 'minitest/refute_path_exists'
|
|
56
|
-
require_relative 'minitest/refute_predicate'
|
|
57
|
-
require_relative 'minitest/refute_respond_to'
|
|
58
|
-
require_relative 'minitest/refute_same'
|
|
59
|
-
require_relative 'minitest/skip_ensure'
|
|
60
|
-
require_relative 'minitest/skip_without_reason'
|
|
61
|
-
require_relative 'minitest/test_method_name'
|
|
62
|
-
require_relative 'minitest/unreachable_assertion'
|
|
63
|
-
require_relative 'minitest/unspecified_exception'
|
|
64
|
-
require_relative 'minitest/useless_assertion'
|
|
3
|
+
# @deprecated This file is deprecated. Cops are registered for lazy loading in
|
|
4
|
+
# `rubocop/cop/minitest`; this file is kept for compatibility with code that
|
|
5
|
+
# requires it directly.
|
|
6
|
+
require_relative 'minitest'
|
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
|
23
23
|
must_output must_pattern_match must_raise must_be_silent must_throw wont_pattern_match
|
|
24
24
|
].freeze
|
|
25
25
|
|
|
26
|
-
MATCHER_METHODS = VALUE_MATCHERS + BLOCK_MATCHERS
|
|
26
|
+
MATCHER_METHODS = (VALUE_MATCHERS + BLOCK_MATCHERS).to_set.freeze
|
|
27
27
|
|
|
28
28
|
ASSERTION_PREFIXES = %i[assert refute].freeze
|
|
29
29
|
|
|
@@ -59,9 +59,16 @@ module RuboCop
|
|
|
59
59
|
|
|
60
60
|
# Support Active Support's `test 'example' { ... }` method.
|
|
61
61
|
# https://api.rubyonrails.org/classes/ActiveSupport/Testing/Declarative.html
|
|
62
|
-
|
|
62
|
+
test_methods + test_blocks(class_node)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_blocks(node, found = [])
|
|
66
|
+
return found if node.type?(:any_def)
|
|
67
|
+
|
|
68
|
+
found << node if node.block_type? && test_block?(node)
|
|
69
|
+
node.each_child_node { |child| test_blocks(child, found) }
|
|
63
70
|
|
|
64
|
-
|
|
71
|
+
found
|
|
65
72
|
end
|
|
66
73
|
|
|
67
74
|
def test_method?(def_node, visibility_check: true)
|
|
@@ -123,8 +123,11 @@ module RuboCop
|
|
|
123
123
|
# end
|
|
124
124
|
# end
|
|
125
125
|
#
|
|
126
|
-
# rubocop:disable Metrics/ModuleLength
|
|
126
|
+
# rubocop:disable-next Metrics/ModuleLength
|
|
127
127
|
module AssertOffense
|
|
128
|
+
VALID_CONSTANT_NAME = /\A[A-Z]\w*(::[A-Z]\w*)*\z/.freeze
|
|
129
|
+
private_constant :VALID_CONSTANT_NAME
|
|
130
|
+
|
|
128
131
|
PLUGIN_INTEGRATION_MUTEX = Mutex.new
|
|
129
132
|
private_constant :PLUGIN_INTEGRATION_MUTEX
|
|
130
133
|
|
|
@@ -192,7 +195,7 @@ module RuboCop
|
|
|
192
195
|
return unless test_class_name
|
|
193
196
|
|
|
194
197
|
cop_name = test_class_name.delete_suffix('Test')
|
|
195
|
-
return
|
|
198
|
+
return unless cop_name.match?(VALID_CONSTANT_NAME)
|
|
196
199
|
|
|
197
200
|
constant_from(Object, cop_name) || constant_from(RuboCop::Cop::Minitest, cop_name.split('::').last)
|
|
198
201
|
end
|
|
@@ -404,6 +407,5 @@ module RuboCop
|
|
|
404
407
|
ENV.fetch('PARSER_ENGINE', :parser_whitequark).to_sym
|
|
405
408
|
end
|
|
406
409
|
end
|
|
407
|
-
# rubocop:enable Metrics/ModuleLength
|
|
408
410
|
end
|
|
409
411
|
end
|
data/lib/rubocop-minitest.rb
CHANGED
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.41.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bozhidar Batsov
|
|
@@ -31,7 +31,7 @@ dependencies:
|
|
|
31
31
|
requirements:
|
|
32
32
|
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: 1.
|
|
34
|
+
version: 1.89.0
|
|
35
35
|
- - "<"
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
37
|
version: '2.0'
|
|
@@ -41,7 +41,7 @@ dependencies:
|
|
|
41
41
|
requirements:
|
|
42
42
|
- - ">="
|
|
43
43
|
- !ruby/object:Gem::Version
|
|
44
|
-
version: 1.
|
|
44
|
+
version: 1.89.0
|
|
45
45
|
- - "<"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '2.0'
|
|
@@ -76,6 +76,7 @@ files:
|
|
|
76
76
|
- README.md
|
|
77
77
|
- config/default.yml
|
|
78
78
|
- lib/rubocop-minitest.rb
|
|
79
|
+
- lib/rubocop/cop/minitest.rb
|
|
79
80
|
- lib/rubocop/cop/minitest/assert_empty.rb
|
|
80
81
|
- lib/rubocop/cop/minitest/assert_empty_literal.rb
|
|
81
82
|
- lib/rubocop/cop/minitest/assert_equal.rb
|
|
@@ -152,7 +153,7 @@ metadata:
|
|
|
152
153
|
homepage_uri: https://docs.rubocop.org/rubocop-minitest/
|
|
153
154
|
changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
|
|
154
155
|
source_code_uri: https://github.com/rubocop/rubocop-minitest
|
|
155
|
-
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.
|
|
156
|
+
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.41
|
|
156
157
|
bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
|
|
157
158
|
rubygems_mfa_required: 'true'
|
|
158
159
|
default_lint_roller_plugin: RuboCop::Minitest::Plugin
|