rubocop-minitest 0.23.0 → 0.23.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6e9ec7344a17911ca56ab072c8b89337ffc3836d113e9ffea4036d9681b7066
|
4
|
+
data.tar.gz: 5c0e810d17f4a1a125c3012a102c9401d368d0c803098b1afa9c43c54f00247b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd836b3634c13de72ccdabd10cd16cd2f8bd4bf342a6b2ebae47c2784236706b2eb9d232126f0b6b75113af2f9b3e9d98707652342989f5c6900b62859c30ea8
|
7
|
+
data.tar.gz: 10dbb5f63df667ff8935d1616ac6508b40c858d3468b6bae010301b8ced80a0ca0ec30032d10b639fd9c575fd4ca59666ff63853f717f4ad9a5377c1e6c750f7
|
@@ -18,25 +18,38 @@ 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
|
+
|
47
|
+
node.parent if parent.block_type? && parent.body && assertion_method?(parent.body)
|
48
|
+
end
|
49
|
+
|
38
50
|
def accept_previous_line?(previous_line_node, node)
|
39
|
-
return true if previous_line_node.
|
51
|
+
return true if !previous_line_node.is_a?(RuboCop::AST::Node) ||
|
52
|
+
previous_line_node.args_type? || node.parent.basic_conditional?
|
40
53
|
|
41
54
|
previous_line_node.send_type? && assertion_method?(previous_line_node)
|
42
55
|
end
|
@@ -45,6 +58,16 @@ module RuboCop
|
|
45
58
|
node.respond_to?(:arguments) && heredoc?(node.arguments.last)
|
46
59
|
end
|
47
60
|
|
61
|
+
def use_assertion_method_at_last_of_block?(node)
|
62
|
+
return false if !node.block_type? || !node.body
|
63
|
+
|
64
|
+
if node.body.begin_type?
|
65
|
+
assertion_method?(node.body.children.last)
|
66
|
+
else
|
67
|
+
assertion_method?(node.body)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
48
71
|
def heredoc?(last_argument)
|
49
72
|
last_argument.respond_to?(:heredoc?) && last_argument.heredoc?
|
50
73
|
end
|
@@ -64,7 +87,7 @@ module RuboCop
|
|
64
87
|
range = if heredoc?(previous_line_node)
|
65
88
|
previous_line_node.loc.heredoc_end
|
66
89
|
else
|
67
|
-
previous_line_node
|
90
|
+
range_by_whole_lines(previous_line_node.source_range, include_final_newline: true)
|
68
91
|
end
|
69
92
|
|
70
93
|
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.1
|
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-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|