rubocop-minitest 0.23.0 → 0.23.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee4acdf54fd339c943921f0bb7ba2e99cd652d2be3e14c8a1c835436e14aa605
|
4
|
+
data.tar.gz: d33499947d46061e36757f06fbd92666c45dc3efa7600124f0d2cdec62178c92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63bf17a69865c62245a43499c72c721c66aa7c4bb8d2f18e9c187ab7d5c5d4b6c47b8511db19a77d7b697d13883f4af430ad435c3f3f31e9503678b843883b93
|
7
|
+
data.tar.gz: a22a130e89bf44ef0a6b457caf0877e001197bea8a8e34bd099525d880c97e05baf06b9dbe1b76e57ae114bc6ec3b0579b6ade84720238b9c54e4d6a160a9b7d
|
@@ -18,25 +18,40 @@ module RuboCop
|
|
18
18
|
#
|
19
19
|
class EmptyLineBeforeAssertionMethods < Base
|
20
20
|
include MinitestExplorationHelpers
|
21
|
+
include RangeHelp
|
21
22
|
extend AutoCorrector
|
22
23
|
|
23
24
|
MSG = 'Add empty line before assertion.'
|
24
25
|
|
26
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
25
27
|
def on_send(node)
|
26
|
-
return unless assertion_method
|
27
|
-
return unless (previous_line_node =
|
28
|
-
return if
|
28
|
+
return unless (assertion_method = assertion_method(node))
|
29
|
+
return unless (previous_line_node = assertion_method.left_sibling)
|
30
|
+
return if node.parent.resbody_type?
|
31
|
+
return if accept_previous_line?(previous_line_node, assertion_method)
|
29
32
|
|
30
33
|
previous_line_node = previous_line_node.arguments.last if use_heredoc_argument?(previous_line_node)
|
31
|
-
return
|
34
|
+
return if use_assertion_method_at_last_of_block?(previous_line_node)
|
35
|
+
return unless no_empty_line?(previous_line_node, assertion_method)
|
32
36
|
|
33
|
-
register_offense(
|
37
|
+
register_offense(assertion_method, previous_line_node)
|
34
38
|
end
|
39
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
35
40
|
|
36
41
|
private
|
37
42
|
|
43
|
+
def assertion_method(node)
|
44
|
+
return node if assertion_method?(node)
|
45
|
+
return unless (parent = node.parent)
|
46
|
+
return unless parent.block_type?
|
47
|
+
return if parent.method?(:test)
|
48
|
+
|
49
|
+
node.parent if parent.body && assertion_method?(parent.body)
|
50
|
+
end
|
51
|
+
|
38
52
|
def accept_previous_line?(previous_line_node, node)
|
39
|
-
return true if previous_line_node.
|
53
|
+
return true if !previous_line_node.is_a?(RuboCop::AST::Node) ||
|
54
|
+
previous_line_node.args_type? || node.parent.basic_conditional?
|
40
55
|
|
41
56
|
previous_line_node.send_type? && assertion_method?(previous_line_node)
|
42
57
|
end
|
@@ -45,6 +60,16 @@ module RuboCop
|
|
45
60
|
node.respond_to?(:arguments) && heredoc?(node.arguments.last)
|
46
61
|
end
|
47
62
|
|
63
|
+
def use_assertion_method_at_last_of_block?(node)
|
64
|
+
return false if !node.block_type? || !node.body
|
65
|
+
|
66
|
+
if node.body.begin_type?
|
67
|
+
assertion_method?(node.body.children.last)
|
68
|
+
else
|
69
|
+
assertion_method?(node.body)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
48
73
|
def heredoc?(last_argument)
|
49
74
|
last_argument.respond_to?(:heredoc?) && last_argument.heredoc?
|
50
75
|
end
|
@@ -64,7 +89,7 @@ module RuboCop
|
|
64
89
|
range = if heredoc?(previous_line_node)
|
65
90
|
previous_line_node.loc.heredoc_end
|
66
91
|
else
|
67
|
-
previous_line_node
|
92
|
+
range_by_whole_lines(previous_line_node.source_range, include_final_newline: true)
|
68
93
|
end
|
69
94
|
|
70
95
|
corrector.insert_after(range, "\n")
|
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.23.
|
4
|
+
version: 0.23.2
|
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: 2022-
|
13
|
+
date: 2022-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|