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: 27c1c1e73140c8a3b7a03627a9e7a8772a91468924a78a55ef9d7eb1de01c41b
4
- data.tar.gz: b04c7e1341cbe6792b360ef49fc495a0534dbbc817cc1c3643465018c5ef7776
3
+ metadata.gz: ee4acdf54fd339c943921f0bb7ba2e99cd652d2be3e14c8a1c835436e14aa605
4
+ data.tar.gz: d33499947d46061e36757f06fbd92666c45dc3efa7600124f0d2cdec62178c92
5
5
  SHA512:
6
- metadata.gz: 60a86b10b510ca5da0d49d647ff5e20d8296e6fbb89214b3e2cb371eaf3096d4e866b3ebafeac446ae7ee6e0d2a139eadbcc77a4e23c144c10332acdef92f552
7
- data.tar.gz: 31acd00dd4c8cbe95e50926694a1c844cb21c1ac6c9695d6a9fa120e9d936b16a7869f44552bcc413e737bf4983be67a2481935940fb5515422e5d14a2b4f0bf
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?(node)
27
- return unless (previous_line_node = node.left_sibling)
28
- return if accept_previous_line?(previous_line_node, node)
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 unless no_empty_line?(previous_line_node, node)
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(node, previous_line_node)
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.args_type? || node.parent.basic_conditional?
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")
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Minitest
5
5
  # This module holds the RuboCop Minitest version information.
6
6
  module Version
7
- STRING = '0.23.0'
7
+ STRING = '0.23.2'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
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.0
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-10-30 00:00:00.000000000 Z
13
+ date: 2022-11-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop