rubocop-minitest 0.10.3 → 0.13.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 +0 -3
- data/.github/ISSUE_TEMPLATE/bug_report.md +5 -1
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +97 -52
- data/CONTRIBUTING.md +3 -3
- data/Gemfile +2 -2
- data/README.md +4 -4
- data/Rakefile +1 -1
- data/bin/console +2 -0
- data/config/default.yml +15 -4
- data/docs/antora.yml +1 -1
- data/docs/modules/ROOT/pages/cops.adoc +2 -0
- data/docs/modules/ROOT/pages/cops_minitest.adoc +71 -7
- data/docs/modules/ROOT/pages/index.adoc +1 -1
- data/legacy-docs/cops_minitest.md +16 -16
- data/legacy-docs/index.md +1 -1
- data/lib/rubocop/cop/minitest/assert_empty.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_empty_literal.rb +12 -16
- data/lib/rubocop/cop/minitest/assert_equal.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_in_delta.rb +4 -1
- data/lib/rubocop/cop/minitest/assert_includes.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_instance_of.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_kind_of.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_match.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_nil.rb +5 -11
- data/lib/rubocop/cop/minitest/assert_output.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_path_exists.rb +6 -12
- data/lib/rubocop/cop/minitest/assert_respond_to.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_silent.rb +8 -6
- data/lib/rubocop/cop/minitest/assert_truthy.rb +5 -11
- data/lib/rubocop/cop/minitest/assert_with_expected_argument.rb +41 -0
- data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +1 -1
- data/lib/rubocop/cop/minitest/global_expectations.rb +6 -7
- data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +15 -14
- data/lib/rubocop/cop/minitest/multiple_assertions.rb +2 -2
- data/lib/rubocop/cop/minitest/no_assertions.rb +48 -0
- data/lib/rubocop/cop/minitest/refute_empty.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_equal.rb +6 -7
- data/lib/rubocop/cop/minitest/refute_false.rb +15 -22
- data/lib/rubocop/cop/minitest/refute_in_delta.rb +4 -1
- data/lib/rubocop/cop/minitest/refute_includes.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_instance_of.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_kind_of.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_match.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_nil.rb +4 -8
- data/lib/rubocop/cop/minitest/refute_path_exists.rb +6 -12
- data/lib/rubocop/cop/minitest/refute_respond_to.rb +1 -1
- data/lib/rubocop/cop/minitest/test_method_name.rb +9 -8
- data/lib/rubocop/cop/minitest/unspecified_exception.rb +1 -1
- data/lib/rubocop/cop/minitest_cops.rb +2 -0
- data/lib/rubocop/cop/mixin/in_delta_mixin.rb +5 -15
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +12 -12
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +14 -4
- data/lib/rubocop/minitest/version.rb +1 -1
- data/mkdocs.yml +1 -1
- data/relnotes/v0.1.0.md +1 -1
- data/relnotes/v0.10.0.md +12 -12
- data/relnotes/v0.10.1.md +1 -1
- data/relnotes/v0.10.2.md +1 -1
- data/relnotes/v0.10.3.md +1 -1
- data/relnotes/v0.11.0.md +16 -0
- data/relnotes/v0.11.1.md +5 -0
- data/relnotes/v0.12.0.md +10 -0
- data/relnotes/v0.12.1.md +5 -0
- data/relnotes/v0.13.0.md +5 -0
- data/relnotes/v0.2.0.md +4 -4
- data/relnotes/v0.2.1.md +1 -1
- data/relnotes/v0.3.0.md +6 -6
- data/relnotes/v0.4.0.md +5 -5
- data/relnotes/v0.4.1.md +1 -1
- data/relnotes/v0.5.0.md +1 -1
- data/relnotes/v0.5.1.md +1 -1
- data/relnotes/v0.6.0.md +1 -1
- data/relnotes/v0.6.1.md +2 -2
- data/relnotes/v0.6.2.md +1 -1
- data/relnotes/v0.7.0.md +5 -5
- data/relnotes/v0.8.0.md +4 -4
- data/relnotes/v0.8.1.md +1 -1
- data/relnotes/v0.9.0.md +3 -3
- data/rubocop-minitest.gemspec +5 -5
- data/tasks/cops_documentation.rake +10 -12
- metadata +17 -10
data/docs/antora.yml
CHANGED
@@ -27,10 +27,12 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide].
|
|
27
27
|
* xref:cops_minitest.adoc#minitestassertrespondto[Minitest/AssertRespondTo]
|
28
28
|
* xref:cops_minitest.adoc#minitestassertsilent[Minitest/AssertSilent]
|
29
29
|
* xref:cops_minitest.adoc#minitestasserttruthy[Minitest/AssertTruthy]
|
30
|
+
* xref:cops_minitest.adoc#minitestassertwithexpectedargument[Minitest/AssertWithExpectedArgument]
|
30
31
|
* xref:cops_minitest.adoc#minitestassertioninlifecyclehook[Minitest/AssertionInLifecycleHook]
|
31
32
|
* xref:cops_minitest.adoc#minitestglobalexpectations[Minitest/GlobalExpectations]
|
32
33
|
* xref:cops_minitest.adoc#minitestliteralasactualargument[Minitest/LiteralAsActualArgument]
|
33
34
|
* xref:cops_minitest.adoc#minitestmultipleassertions[Minitest/MultipleAssertions]
|
35
|
+
* xref:cops_minitest.adoc#minitestnoassertions[Minitest/NoAssertions]
|
34
36
|
* xref:cops_minitest.adoc#minitestrefuteempty[Minitest/RefuteEmpty]
|
35
37
|
* xref:cops_minitest.adoc#minitestrefuteequal[Minitest/RefuteEqual]
|
36
38
|
* xref:cops_minitest.adoc#minitestrefutefalse[Minitest/RefuteFalse]
|
@@ -41,19 +41,19 @@ assert_empty(object, 'message')
|
|
41
41
|
| Yes
|
42
42
|
| Yes (Unsafe)
|
43
43
|
| 0.5
|
44
|
-
| 0.
|
44
|
+
| 0.11
|
45
45
|
|===
|
46
46
|
|
47
47
|
This cop enforces the test to use `assert_empty`
|
48
|
-
instead of using `
|
48
|
+
instead of using `assert_equal([], object)`.
|
49
49
|
|
50
50
|
=== Examples
|
51
51
|
|
52
52
|
[source,ruby]
|
53
53
|
----
|
54
54
|
# bad
|
55
|
-
|
56
|
-
|
55
|
+
assert_equal([], object)
|
56
|
+
assert_equal({}, object)
|
57
57
|
|
58
58
|
# good
|
59
59
|
assert_empty(object)
|
@@ -215,7 +215,7 @@ assert_kind_of(Class, object, 'message')
|
|
215
215
|
|
216
216
|
=== References
|
217
217
|
|
218
|
-
* https://github.com/rubocop
|
218
|
+
* https://github.com/rubocop/minitest-style-guide#assert-kind-of
|
219
219
|
|
220
220
|
== Minitest/AssertMatch
|
221
221
|
|
@@ -407,7 +407,7 @@ assert_silent { puts object.do_something }
|
|
407
407
|
|
408
408
|
=== References
|
409
409
|
|
410
|
-
* https://github.com/rubocop
|
410
|
+
* https://github.com/rubocop/minitest-style-guide#assert-silent
|
411
411
|
|
412
412
|
== Minitest/AssertTruthy
|
413
413
|
|
@@ -441,6 +441,38 @@ assert(actual, 'message')
|
|
441
441
|
|
442
442
|
* https://minitest.rubystyle.guide#assert-truthy
|
443
443
|
|
444
|
+
== Minitest/AssertWithExpectedArgument
|
445
|
+
|
446
|
+
|===
|
447
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
448
|
+
|
449
|
+
| Pending
|
450
|
+
| No
|
451
|
+
| No
|
452
|
+
| 0.11
|
453
|
+
| -
|
454
|
+
|===
|
455
|
+
|
456
|
+
This cop tries to detect when a user accidentally used
|
457
|
+
`assert` when they meant to use `assert_equal`.
|
458
|
+
|
459
|
+
It is marked as unsafe because it is not possible to determine
|
460
|
+
whether the second argument of `assert` is a message or not.
|
461
|
+
|
462
|
+
=== Examples
|
463
|
+
|
464
|
+
[source,ruby]
|
465
|
+
----
|
466
|
+
# bad
|
467
|
+
assert(3, my_list.length)
|
468
|
+
assert(expected, actual)
|
469
|
+
|
470
|
+
# good
|
471
|
+
assert_equal(3, my_list.length)
|
472
|
+
assert_equal(expected, actual)
|
473
|
+
assert(foo, 'message')
|
474
|
+
----
|
475
|
+
|
444
476
|
== Minitest/AssertionInLifecycleHook
|
445
477
|
|
446
478
|
|===
|
@@ -593,6 +625,38 @@ end
|
|
593
625
|
| Integer
|
594
626
|
|===
|
595
627
|
|
628
|
+
== Minitest/NoAssertions
|
629
|
+
|
630
|
+
|===
|
631
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
632
|
+
|
633
|
+
| Disabled
|
634
|
+
| Yes
|
635
|
+
| No
|
636
|
+
| 0.12
|
637
|
+
| -
|
638
|
+
|===
|
639
|
+
|
640
|
+
This cop checks if test cases contain any assertion calls.
|
641
|
+
|
642
|
+
=== Examples
|
643
|
+
|
644
|
+
[source,ruby]
|
645
|
+
----
|
646
|
+
# bad
|
647
|
+
class FooTest < Minitest::Test
|
648
|
+
def test_the_truth
|
649
|
+
end
|
650
|
+
end
|
651
|
+
|
652
|
+
# good
|
653
|
+
class FooTest < Minitest::Test
|
654
|
+
def test_the_truth
|
655
|
+
assert true
|
656
|
+
end
|
657
|
+
end
|
658
|
+
----
|
659
|
+
|
596
660
|
== Minitest/RefuteEmpty
|
597
661
|
|
598
662
|
|===
|
@@ -817,7 +881,7 @@ refute_kind_of(Class, object, 'message')
|
|
817
881
|
|
818
882
|
=== References
|
819
883
|
|
820
|
-
* https://github.com/rubocop
|
884
|
+
* https://github.com/rubocop/minitest-style-guide#refute-kind-of
|
821
885
|
|
822
886
|
== Minitest/RefuteMatch
|
823
887
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
= RuboCop Minitest
|
2
2
|
|
3
|
-
A https://github.com/rubocop
|
3
|
+
A https://github.com/rubocop/rubocop[RuboCop] extension focused on enforcing Minitest best practices and coding conventions.
|
4
4
|
|
5
5
|
It's based on the community-driven https://minitest.rubystyle.guide[Minitest style guide].
|
@@ -23,7 +23,7 @@ assert_empty(object, 'message')
|
|
23
23
|
|
24
24
|
### References
|
25
25
|
|
26
|
-
* [https://github.com/rubocop
|
26
|
+
* [https://github.com/rubocop/minitest-style-guide#assert-empty](https://github.com/rubocop/minitest-style-guide#assert-empty)
|
27
27
|
|
28
28
|
## Minitest/AssertEmptyLiteral
|
29
29
|
|
@@ -66,7 +66,7 @@ assert_equal("rubocop-minitest", actual)
|
|
66
66
|
|
67
67
|
### References
|
68
68
|
|
69
|
-
* [https://github.com/rubocop
|
69
|
+
* [https://github.com/rubocop/minitest-style-guide#assert-equal-arguments-order](https://github.com/rubocop/minitest-style-guide#assert-equal-arguments-order)
|
70
70
|
|
71
71
|
## Minitest/AssertIncludes
|
72
72
|
|
@@ -91,7 +91,7 @@ assert_includes(collection, object, 'message')
|
|
91
91
|
|
92
92
|
### References
|
93
93
|
|
94
|
-
* [https://github.com/rubocop
|
94
|
+
* [https://github.com/rubocop/minitest-style-guide#assert-includes](https://github.com/rubocop/minitest-style-guide#assert-includes)
|
95
95
|
|
96
96
|
## Minitest/AssertInstanceOf
|
97
97
|
|
@@ -116,7 +116,7 @@ assert_instance_of(Class, object, 'message')
|
|
116
116
|
|
117
117
|
### References
|
118
118
|
|
119
|
-
* [https://github.com/rubocop
|
119
|
+
* [https://github.com/rubocop/minitest-style-guide#assert-instance-of](https://github.com/rubocop/minitest-style-guide#assert-instance-of)
|
120
120
|
|
121
121
|
## Minitest/AssertMatch
|
122
122
|
|
@@ -141,7 +141,7 @@ assert_match(matcher, string, 'message')
|
|
141
141
|
|
142
142
|
### References
|
143
143
|
|
144
|
-
* [https://github.com/rubocop
|
144
|
+
* [https://github.com/rubocop/minitest-style-guide#assert-match](https://github.com/rubocop/minitest-style-guide#assert-match)
|
145
145
|
|
146
146
|
## Minitest/AssertNil
|
147
147
|
|
@@ -166,7 +166,7 @@ assert_nil(actual, 'message')
|
|
166
166
|
|
167
167
|
### References
|
168
168
|
|
169
|
-
* [https://github.com/rubocop
|
169
|
+
* [https://github.com/rubocop/minitest-style-guide#assert-nil](https://github.com/rubocop/minitest-style-guide#assert-nil)
|
170
170
|
|
171
171
|
## Minitest/AssertRespondTo
|
172
172
|
|
@@ -193,7 +193,7 @@ assert_respond_to(self, :do_something)
|
|
193
193
|
|
194
194
|
### References
|
195
195
|
|
196
|
-
* [https://github.com/rubocop
|
196
|
+
* [https://github.com/rubocop/minitest-style-guide#assert-responds-to-method](https://github.com/rubocop/minitest-style-guide#assert-responds-to-method)
|
197
197
|
|
198
198
|
## Minitest/AssertTruthy
|
199
199
|
|
@@ -218,7 +218,7 @@ assert(actual, 'message')
|
|
218
218
|
|
219
219
|
### References
|
220
220
|
|
221
|
-
* [https://github.com/rubocop
|
221
|
+
* [https://github.com/rubocop/minitest-style-guide#assert-truthy](https://github.com/rubocop/minitest-style-guide#assert-truthy)
|
222
222
|
|
223
223
|
## Minitest/GlobalExpectations
|
224
224
|
|
@@ -266,7 +266,7 @@ refute_empty(object, 'message')
|
|
266
266
|
|
267
267
|
### References
|
268
268
|
|
269
|
-
* [https://github.com/rubocop
|
269
|
+
* [https://github.com/rubocop/minitest-style-guide#refute-empty](https://github.com/rubocop/minitest-style-guide#refute-empty)
|
270
270
|
|
271
271
|
## Minitest/RefuteEqual
|
272
272
|
|
@@ -290,7 +290,7 @@ refute_equal("rubocop-minitest", actual)
|
|
290
290
|
|
291
291
|
### References
|
292
292
|
|
293
|
-
* [https://github.com/rubocop
|
293
|
+
* [https://github.com/rubocop/minitest-style-guide#refute-equal](https://github.com/rubocop/minitest-style-guide#refute-equal)
|
294
294
|
|
295
295
|
## Minitest/RefuteFalse
|
296
296
|
|
@@ -318,7 +318,7 @@ refute(actual, 'message')
|
|
318
318
|
|
319
319
|
### References
|
320
320
|
|
321
|
-
* [https://github.com/rubocop
|
321
|
+
* [https://github.com/rubocop/minitest-style-guide#refute-false](https://github.com/rubocop/minitest-style-guide#refute-false)
|
322
322
|
|
323
323
|
## Minitest/RefuteIncludes
|
324
324
|
|
@@ -343,7 +343,7 @@ refute_includes(collection, object, 'message')
|
|
343
343
|
|
344
344
|
### References
|
345
345
|
|
346
|
-
* [https://github.com/rubocop
|
346
|
+
* [https://github.com/rubocop/minitest-style-guide#refute-includes](https://github.com/rubocop/minitest-style-guide#refute-includes)
|
347
347
|
|
348
348
|
## Minitest/RefuteInstanceOf
|
349
349
|
|
@@ -368,7 +368,7 @@ refute_instance_of(Class, object, 'message')
|
|
368
368
|
|
369
369
|
### References
|
370
370
|
|
371
|
-
* [https://github.com/rubocop
|
371
|
+
* [https://github.com/rubocop/minitest-style-guide#refute-instance-of](https://github.com/rubocop/minitest-style-guide#refute-instance-of)
|
372
372
|
|
373
373
|
## Minitest/RefuteMatch
|
374
374
|
|
@@ -393,7 +393,7 @@ refute_match(matcher, string, 'message')
|
|
393
393
|
|
394
394
|
### References
|
395
395
|
|
396
|
-
* [https://github.com/rubocop
|
396
|
+
* [https://github.com/rubocop/minitest-style-guide#refute-match](https://github.com/rubocop/minitest-style-guide#refute-match)
|
397
397
|
|
398
398
|
## Minitest/RefuteNil
|
399
399
|
|
@@ -418,7 +418,7 @@ refute_nil(actual, 'message')
|
|
418
418
|
|
419
419
|
### References
|
420
420
|
|
421
|
-
* [https://github.com/rubocop
|
421
|
+
* [https://github.com/rubocop/minitest-style-guide#refute-nil](https://github.com/rubocop/minitest-style-guide#refute-nil)
|
422
422
|
|
423
423
|
## Minitest/RefuteRespondTo
|
424
424
|
|
@@ -445,4 +445,4 @@ refute_respond_to(self, :do_something)
|
|
445
445
|
|
446
446
|
### References
|
447
447
|
|
448
|
-
* [https://github.com/rubocop
|
448
|
+
* [https://github.com/rubocop/minitest-style-guide#refute-respond-to](https://github.com/rubocop/minitest-style-guide#refute-respond-to)
|
data/legacy-docs/index.md
CHANGED
@@ -1 +1 @@
|
|
1
|
-
A [RuboCop](https://github.com/rubocop
|
1
|
+
A [RuboCop](https://github.com/rubocop/rubocop) extension focused on enforcing Minitest best practices and coding conventions.
|
@@ -4,42 +4,38 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module Minitest
|
6
6
|
# This cop enforces the test to use `assert_empty`
|
7
|
-
# instead of using `
|
7
|
+
# instead of using `assert_equal([], object)`.
|
8
8
|
#
|
9
9
|
# @example
|
10
10
|
# # bad
|
11
|
-
#
|
12
|
-
#
|
11
|
+
# assert_equal([], object)
|
12
|
+
# assert_equal({}, object)
|
13
13
|
#
|
14
14
|
# # good
|
15
15
|
# assert_empty(object)
|
16
16
|
#
|
17
|
-
class AssertEmptyLiteral <
|
17
|
+
class AssertEmptyLiteral < Base
|
18
18
|
include ArgumentRangeHelper
|
19
|
+
extend AutoCorrector
|
19
20
|
|
20
21
|
MSG = 'Prefer using `assert_empty(%<arguments>s)` over ' \
|
21
|
-
'`
|
22
|
+
'`assert_equal(%<literal>s, %<arguments>s)`.'
|
23
|
+
RESTRICT_ON_SEND = %i[assert_equal].freeze
|
22
24
|
|
23
|
-
def_node_matcher :
|
24
|
-
(send nil? :
|
25
|
+
def_node_matcher :assert_equal_with_empty_literal, <<~PATTERN
|
26
|
+
(send nil? :assert_equal ${hash array} $...)
|
25
27
|
PATTERN
|
26
28
|
|
27
29
|
def on_send(node)
|
28
|
-
|
30
|
+
assert_equal_with_empty_literal(node) do |literal, matchers|
|
29
31
|
return unless literal.values.empty?
|
30
32
|
|
31
33
|
args = matchers.map(&:source).join(', ')
|
32
34
|
|
33
35
|
message = format(MSG, literal: literal.source, arguments: args)
|
34
|
-
add_offense(node, message: message)
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def autocorrect(node)
|
39
|
-
assert_with_empty_literal(node) do |_literal, matchers|
|
40
|
-
object = matchers.first
|
36
|
+
add_offense(node, message: message) do |corrector|
|
37
|
+
object = matchers.first
|
41
38
|
|
42
|
-
lambda do |corrector|
|
43
39
|
corrector.replace(node.loc.selector, 'assert_empty')
|
44
40
|
corrector.replace(first_and_second_arguments_range(node), object.source)
|
45
41
|
end
|
@@ -15,8 +15,11 @@ module RuboCop
|
|
15
15
|
# assert_in_delta(0.2, actual)
|
16
16
|
# assert_in_delta(0.2, actual, 0.001, 'message')
|
17
17
|
#
|
18
|
-
class AssertInDelta <
|
18
|
+
class AssertInDelta < Base
|
19
19
|
include InDeltaMixin
|
20
|
+
extend AutoCorrector
|
21
|
+
|
22
|
+
RESTRICT_ON_SEND = %i[assert_equal].freeze
|
20
23
|
|
21
24
|
def_node_matcher :equal_floats_call, <<~PATTERN
|
22
25
|
(send nil? :assert_equal $_ $_ $...)
|
@@ -15,7 +15,7 @@ module RuboCop
|
|
15
15
|
# assert_includes(collection, object)
|
16
16
|
# assert_includes(collection, object, 'message')
|
17
17
|
#
|
18
|
-
class AssertIncludes <
|
18
|
+
class AssertIncludes < Base
|
19
19
|
extend MinitestCopRule
|
20
20
|
|
21
21
|
define_rule :assert, target_method: :include?, preferred_method: :assert_includes
|
@@ -15,7 +15,7 @@ module RuboCop
|
|
15
15
|
# assert_instance_of(Class, object)
|
16
16
|
# assert_instance_of(Class, object, 'message')
|
17
17
|
#
|
18
|
-
class AssertInstanceOf <
|
18
|
+
class AssertInstanceOf < Base
|
19
19
|
extend MinitestCopRule
|
20
20
|
|
21
21
|
define_rule :assert, target_method: :instance_of?, inverse: true
|
@@ -15,11 +15,13 @@ module RuboCop
|
|
15
15
|
# assert_nil(actual)
|
16
16
|
# assert_nil(actual, 'message')
|
17
17
|
#
|
18
|
-
class AssertNil <
|
18
|
+
class AssertNil < Base
|
19
19
|
include ArgumentRangeHelper
|
20
|
+
extend AutoCorrector
|
20
21
|
|
21
22
|
MSG = 'Prefer using `assert_nil(%<arguments>s)` over ' \
|
22
23
|
'`assert_equal(nil, %<arguments>s)`.'
|
24
|
+
RESTRICT_ON_SEND = %i[assert_equal].freeze
|
23
25
|
|
24
26
|
def_node_matcher :assert_equal_with_nil, <<~PATTERN
|
25
27
|
(send nil? :assert_equal nil $_ $...)
|
@@ -31,17 +33,9 @@ module RuboCop
|
|
31
33
|
|
32
34
|
arguments = [actual.source, message&.source].compact.join(', ')
|
33
35
|
|
34
|
-
add_offense(node, message: format(MSG, arguments: arguments))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def autocorrect(node)
|
39
|
-
lambda do |corrector|
|
40
|
-
assert_equal_with_nil(node) do |actual|
|
36
|
+
add_offense(node, message: format(MSG, arguments: arguments)) do |corrector|
|
41
37
|
corrector.replace(node.loc.selector, 'assert_nil')
|
42
|
-
corrector.replace(
|
43
|
-
first_and_second_arguments_range(node), actual.source
|
44
|
-
)
|
38
|
+
corrector.replace(first_and_second_arguments_range(node), actual.source)
|
45
39
|
end
|
46
40
|
end
|
47
41
|
end
|