rubocop-minitest 0.34.1 → 0.34.3

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: 8e59babe7e9ae552aee440a3e5eb5767af585357899d8f4fbac8f54247494b87
4
- data.tar.gz: 4f61d9b471cdda223fbd1fe239656b2a47e5216a2903588ce05f5a4909d5fb21
3
+ metadata.gz: afd3efb3693514e425f01041e37235e7e78fd0259689c6e638a8d567c0bd4692
4
+ data.tar.gz: c6886e41faf35b0b801394e71b07c550359ff94bff8a074b8df5bd872db588f6
5
5
  SHA512:
6
- metadata.gz: 7d14b60b50dacf5f28470b18ea5d03c19507e21063bf54a971b67a5b4d10255e048bcf75052f4645aa049a25ff54dd6f8022255b5c11bdef650c63f84fa4ed1f
7
- data.tar.gz: 3e3389f3ba19ea5a8c08ee1b57c5eb9d8da15b17c1b80d36c21470bd096a6753e9108c7de8d84ebb0f702b797310af241e401a16ea2207dc12d4891135c5efa9
6
+ metadata.gz: 35a275c7a0e6d17dab0a838ebe10f4a913d0d6fa854b6836129a35a8765d2f49d672a5cbb2dd1286fff3f71437eea297aa09e74539f618ff278c17359467da67
7
+ data.tar.gz: 7db0be71cbcebc36bf79fd2002d773a608c78333436d4b01d5fda05255683fde98c845e0267ab4ba8a54c400df52c4a53c53eee0f4eda5649d9bf55acd1c77ef
@@ -37,7 +37,7 @@ module RuboCop
37
37
  private
38
38
 
39
39
  def multi_statement_begin?(node)
40
- node.begin_type? && node.children.size > 1
40
+ node&.begin_type? && node.children.size > 1
41
41
  end
42
42
  end
43
43
  end
@@ -53,22 +53,34 @@ module RuboCop
53
53
  def assertions_count(node)
54
54
  return 0 unless node.is_a?(RuboCop::AST::Node)
55
55
 
56
- assertions =
57
- case node.type
58
- when :if, :case, :case_match
59
- assertions_count_in_branches(node.branches)
60
- when :rescue
61
- assertions_count(node.body) + assertions_count_in_branches(node.branches)
62
- when :block, :numblock
63
- assertions_count(node.body)
64
- else
65
- node.each_child_node.sum { |child| assertions_count(child) }
66
- end
67
-
56
+ assertions = assertions_count_based_on_type(node)
68
57
  assertions += 1 if assertion_method?(node)
69
58
  assertions
70
59
  end
71
60
 
61
+ def assertions_count_based_on_type(node)
62
+ case node.type
63
+ when :if, :case, :case_match
64
+ assertions_count_in_branches(node.branches)
65
+ when :rescue
66
+ assertions_count(node.body) + assertions_count_in_branches(node.branches)
67
+ when :block, :numblock
68
+ assertions_count(node.body)
69
+ when *RuboCop::AST::Node::ASSIGNMENTS
70
+ assertions_count_in_assignment(node)
71
+ else
72
+ node.each_child_node.sum { |child| assertions_count(child) }
73
+ end
74
+ end
75
+
76
+ def assertions_count_in_assignment(node)
77
+ # checking the direct expression is handled by assertion_method?
78
+ return 0 unless node.expression.block_type? || node.expression.numblock_type?
79
+
80
+ # this will only trigger the branches for :block and :numblock type nodes
81
+ assertions_count_based_on_type(node.expression)
82
+ end
83
+
72
84
  def assertions_count_in_branches(branches)
73
85
  branches.map { |branch| assertions_count(branch) }.max
74
86
  end
@@ -99,8 +99,9 @@ module RuboCop
99
99
  end
100
100
  end
101
101
 
102
- # rubocop:disable Metrics/CyclomaticComplexity
102
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
103
103
  def assertion_method?(node)
104
+ return false unless node
104
105
  return assertion_method?(node.expression) if node.assignment? && node.respond_to?(:expression)
105
106
  return false if !node.send_type? && !node.block_type? && !node.numblock_type?
106
107
 
@@ -110,7 +111,7 @@ module RuboCop
110
111
  method_name.start_with?(prefix) || node.method?(:flunk)
111
112
  end
112
113
  end
113
- # rubocop:enable Metrics/CyclomaticComplexity
114
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
114
115
 
115
116
  def lifecycle_hook_method?(node)
116
117
  node.def_type? && LIFECYCLE_HOOK_METHODS.include?(node.method_name)
@@ -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.34.1'
7
+ STRING = '0.34.3'
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.34.1
4
+ version: 0.34.3
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: 2023-12-16 00:00:00.000000000 Z
13
+ date: 2024-01-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop