rubocop-minitest 0.23.0 → 0.23.1

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: c6e9ec7344a17911ca56ab072c8b89337ffc3836d113e9ffea4036d9681b7066
4
+ data.tar.gz: 5c0e810d17f4a1a125c3012a102c9401d368d0c803098b1afa9c43c54f00247b
5
5
  SHA512:
6
- metadata.gz: 60a86b10b510ca5da0d49d647ff5e20d8296e6fbb89214b3e2cb371eaf3096d4e866b3ebafeac446ae7ee6e0d2a139eadbcc77a4e23c144c10332acdef92f552
7
- data.tar.gz: 31acd00dd4c8cbe95e50926694a1c844cb21c1ac6c9695d6a9fa120e9d936b16a7869f44552bcc413e737bf4983be67a2481935940fb5515422e5d14a2b4f0bf
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?(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
+
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.args_type? || node.parent.basic_conditional?
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")
@@ -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.1'
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.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-10-30 00:00:00.000000000 Z
13
+ date: 2022-11-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop