rubocop-minitest 0.23.1 → 0.24.0

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: c6e9ec7344a17911ca56ab072c8b89337ffc3836d113e9ffea4036d9681b7066
4
- data.tar.gz: 5c0e810d17f4a1a125c3012a102c9401d368d0c803098b1afa9c43c54f00247b
3
+ metadata.gz: b0a695c307538885f790b2efe35af28113a4f76baf8ba870ae41d870a54b31fe
4
+ data.tar.gz: 40f94eb2dfa3d962e9ffba5dc989d281ae74f81ec3cbfac442e15095ac3d612c
5
5
  SHA512:
6
- metadata.gz: bd836b3634c13de72ccdabd10cd16cd2f8bd4bf342a6b2ebae47c2784236706b2eb9d232126f0b6b75113af2f9b3e9d98707652342989f5c6900b62859c30ea8
7
- data.tar.gz: 10dbb5f63df667ff8935d1616ac6508b40c858d3468b6bae010301b8ced80a0ca0ec30032d10b639fd9c575fd4ca59666ff63853f717f4ad9a5377c1e6c750f7
6
+ metadata.gz: 04c9af1d29a613536c03c372fac160ad7df0d32e68354f765bfbb178dfcca27b670da7f55bce7923dbbc048c227346f9656b31b8f641ba07254a7bf61c2a6d10
7
+ data.tar.gz: 9e3c8090307fa86ba39e2b917e583815616e4ae82bbb32d36cadcaa7f1eca3ca293d8907b71bfaa3bebf9e643fd5380040983802f624094a4f1776794c98b838
data/config/default.yml CHANGED
@@ -239,6 +239,11 @@ Minitest/SkipEnsure:
239
239
  Enabled: pending
240
240
  VersionAdded: '0.20'
241
241
 
242
+ Minitest/SkipWithoutReason:
243
+ Description: 'Checks for skipped tests missing the skipping reason.'
244
+ Enabled: pending
245
+ VersionAdded: '0.24'
246
+
242
247
  Minitest/TestMethodName:
243
248
  Description: 'This cop enforces that test method names start with `test_` prefix.'
244
249
  Enabled: 'pending'
@@ -43,8 +43,10 @@ module RuboCop
43
43
  def assertion_method(node)
44
44
  return node if assertion_method?(node)
45
45
  return unless (parent = node.parent)
46
+ return unless parent.block_type?
47
+ return if parent.method?(:test)
46
48
 
47
- node.parent if parent.block_type? && parent.body && assertion_method?(parent.body)
49
+ node.parent if parent.body && assertion_method?(parent.body)
48
50
  end
49
51
 
50
52
  def accept_previous_line?(previous_line_node, node)
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Minitest
6
+ # Checks for skipped tests missing the skipping reason.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # skip
11
+ # skip('')
12
+ #
13
+ # # bad
14
+ # if condition?
15
+ # skip
16
+ # else
17
+ # skip
18
+ # end
19
+ #
20
+ # # good
21
+ # skip("Reason why the test was skipped")
22
+ #
23
+ # # good
24
+ # skip if condition?
25
+ #
26
+ class SkipWithoutReason < Base
27
+ MSG = 'Add a reason explaining why the test is skipped.'
28
+
29
+ RESTRICT_ON_SEND = %i[skip].freeze
30
+
31
+ def on_send(node)
32
+ return if node.receiver || !blank_argument?(node)
33
+
34
+ conditional_node = conditional_parent(node)
35
+ return if conditional_node && !only_skip_branches?(conditional_node)
36
+
37
+ return if node.parent&.resbody_type?
38
+
39
+ add_offense(node)
40
+ end
41
+
42
+ private
43
+
44
+ def blank_argument?(node)
45
+ message = node.first_argument
46
+ message.nil? || (message.str_type? && message.value == '')
47
+ end
48
+
49
+ def conditional_parent(node)
50
+ return unless (parent = node.parent)
51
+
52
+ if parent.if_type? || parent.case_type?
53
+ parent
54
+ elsif parent.when_type?
55
+ parent.parent
56
+ end
57
+ end
58
+
59
+ def only_skip_branches?(node)
60
+ branches = node.branches.compact
61
+ branches.size > 1 && branches.all? { |branch| branch.send_type? && branch.method?(:skip) }
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -44,6 +44,7 @@ require_relative 'minitest/refute_path_exists'
44
44
  require_relative 'minitest/refute_predicate'
45
45
  require_relative 'minitest/refute_respond_to'
46
46
  require_relative 'minitest/skip_ensure'
47
+ require_relative 'minitest/skip_without_reason'
47
48
  require_relative 'minitest/test_method_name'
48
49
  require_relative 'minitest/unreachable_assertion'
49
50
  require_relative 'minitest/unspecified_exception'
@@ -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.1'
7
+ STRING = '0.24.0'
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.1
4
+ version: 0.24.0
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-11-07 00:00:00.000000000 Z
13
+ date: 2022-11-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -97,6 +97,7 @@ files:
97
97
  - lib/rubocop/cop/minitest/refute_predicate.rb
98
98
  - lib/rubocop/cop/minitest/refute_respond_to.rb
99
99
  - lib/rubocop/cop/minitest/skip_ensure.rb
100
+ - lib/rubocop/cop/minitest/skip_without_reason.rb
100
101
  - lib/rubocop/cop/minitest/test_method_name.rb
101
102
  - lib/rubocop/cop/minitest/unreachable_assertion.rb
102
103
  - lib/rubocop/cop/minitest/unspecified_exception.rb
@@ -119,7 +120,7 @@ metadata:
119
120
  homepage_uri: https://docs.rubocop.org/rubocop-minitest/
120
121
  changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
121
122
  source_code_uri: https://github.com/rubocop/rubocop-minitest
122
- documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.23
123
+ documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.24
123
124
  bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
124
125
  rubygems_mfa_required: 'true'
125
126
  post_install_message:
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  - !ruby/object:Gem::Version
138
139
  version: '0'
139
140
  requirements: []
140
- rubygems_version: 3.3.7
141
+ rubygems_version: 3.3.26
141
142
  signing_key:
142
143
  specification_version: 4
143
144
  summary: Automatic Minitest code style checking tool.