rubocop-rspec 3.2.0 → 3.3.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: 47c427b063cba22b4601d8244b18db288081f95889e287be82473e9148748c2e
4
- data.tar.gz: 9d9543614cb00ee6cf4c94c750ce2368a4e34dae73f1a778e3fc9a7470698526
3
+ metadata.gz: 3ca108a17fe360c345896a230b0bec34f36430cfff3eb7b06d9fd28fa302da06
4
+ data.tar.gz: 8eaf93b36c0cf29b2718e86fc8d99e85601f517966d008fd00d53f4315cd1745
5
5
  SHA512:
6
- metadata.gz: 04fb1fe03b1fb818c7ee43d937fbb394e93a91e70c0cc00c06d259c53210ebb6b5243b584342838de566e99d0263d60b975113362b3a6306acf31f46ea2ed0ff
7
- data.tar.gz: 66daeeaff0d894825dfcf0dc836b0fc614490b358b508ddaacc98652c37f0dc6e9c29e38222493e21a662f848a20efce503fe25a349b7a16fcc3693b9ecac4a1
6
+ metadata.gz: f3375145facfb2e91f2cfee6949544947756e965f23fd713a09aba5f301b8558dc40be1b9cc3a66cb629c2b14f643a8bfb9aab12bff509dcfbcb2f9b05e801ac
7
+ data.tar.gz: 75ea9be799c2868fbc4b7333b20d95ecf3934f0d8d38339c9c412010b037811cb2d45b2c3e494e01ea6f1be3619ac39290c22af5b1b76cc75a3ec0e0c3a9f6c3
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 3.3.0 (2024-12-12)
6
+
7
+ - Deprecate `top_level_group?` method from `TopLevelGroup` mixin as all of its callers were intentionally removed from `Rubocop/RSpec`. ([@corsonknowles])
8
+ - Fix false positive for RSpec/EmptyMetadata for splat kwargs. ([@pirj])
9
+
5
10
  ## 3.2.0 (2024-10-26)
6
11
 
7
12
  - Fix `RSpec/VoidExpect` to only operate inside an example block. ([@corsonknowles])
@@ -740,7 +745,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
740
745
  ## 1.13.0 (2017-03-07)
741
746
 
742
747
  - Add repeated 'it' detection to `RSpec/ExampleWording` cop. ([@dgollahon])
743
- - Add \[observed_nesting/max_nesting\] info to `RSpec/NestedGroups` messages. ([@dgollahon])
748
+ - Add [observed_nesting/max_nesting] info to `RSpec/NestedGroups` messages. ([@dgollahon])
744
749
  - Add `RSpec/ItBehavesLike` cop. ([@dgollahon])
745
750
  - Add `RSpec/SharedContext` cop. ([@Darhazer])
746
751
  - `RSpec/MultipleExpectations`: Count aggregate_failures block as single expectation. ([@Darhazer])
@@ -69,15 +69,13 @@ module RuboCop
69
69
  end
70
70
 
71
71
  def check_for_unused_proxy(block, proxy)
72
- name, = *proxy
73
-
74
72
  find_arg_usage(block) do |usage|
75
- return if usage.include?(s(:lvar, name))
73
+ return if usage.include?(s(:lvar, proxy.name))
76
74
  end
77
75
 
78
76
  add_offense(
79
77
  proxy,
80
- message: format(MSG_UNUSED_ARG, arg: name)
78
+ message: format(MSG_UNUSED_ARG, arg: proxy.name)
81
79
  )
82
80
  end
83
81
 
@@ -21,6 +21,7 @@ module RuboCop
21
21
 
22
22
  def on_metadata(_symbols, hash)
23
23
  return unless hash&.pairs&.empty?
24
+ return if hash.children.any?(&:kwsplat_type?)
24
25
 
25
26
  add_offense(hash) do |corrector|
26
27
  remove_empty_metadata(corrector, hash)
@@ -7,6 +7,10 @@ module RuboCop
7
7
  module TopLevelGroup
8
8
  extend RuboCop::NodePattern::Macros
9
9
 
10
+ DEPRECATED_MODULE_METHOD_WARNING =
11
+ 'top_level_group? is deprecated and will be ' \
12
+ 'removed in the next major version of rubocop_rspec.'
13
+
10
14
  def on_new_investigation
11
15
  super
12
16
 
@@ -28,7 +32,10 @@ module RuboCop
28
32
 
29
33
  def on_top_level_group(_node); end
30
34
 
35
+ # @private
36
+ # @deprecated All callers of this method have been removed.
31
37
  def top_level_group?(node)
38
+ warn DEPRECATED_MODULE_METHOD_WARNING, uplevel: 1
32
39
  top_level_groups.include?(node)
33
40
  end
34
41
 
@@ -67,11 +67,10 @@ module RuboCop
67
67
  end
68
68
 
69
69
  def autocorrect_hash_arg(corrector, arg)
70
- key, value = *arg.children.first
71
-
72
- corrector.replace(arg, key_to_arg(key))
70
+ pair = arg.pairs.first
71
+ corrector.replace(arg, key_to_arg(pair.key))
73
72
  corrector.insert_after(arg.parent.loc.end,
74
- ".and_return(#{value.source})")
73
+ ".and_return(#{pair.value.source})")
75
74
  end
76
75
 
77
76
  def autocorrect_array_arg(corrector, arg)
@@ -14,8 +14,9 @@ module RuboCop
14
14
  # expect(foo).to receive(:bar).with(42)
15
15
  #
16
16
  class StubbedMock < Base
17
- MSG = 'Prefer `%<replacement>s` over `%<method_name>s` when ' \
17
+ MSG = 'Prefer %<replacement>s over `%<method_name>s` when ' \
18
18
  'configuring a response.'
19
+ RESTRICT_ON_SEND = %i[to].freeze
19
20
 
20
21
  # @!method message_expectation?(node)
21
22
  # Match message expectation matcher
@@ -133,8 +134,6 @@ module RuboCop
133
134
  }
134
135
  PATTERN
135
136
 
136
- RESTRICT_ON_SEND = %i[to].freeze
137
-
138
137
  def on_send(node)
139
138
  expectation(node) do |expectation, method_name, matcher|
140
139
  on_expectation(expectation, method_name, matcher)
@@ -155,19 +154,23 @@ module RuboCop
155
154
  end
156
155
 
157
156
  def msg(method_name)
158
- format(MSG,
159
- method_name: method_name,
160
- replacement: replacement(method_name))
157
+ format(
158
+ MSG,
159
+ method_name: method_name,
160
+ replacement: replacement(method_name)
161
+ )
161
162
  end
162
163
 
163
164
  def replacement(method_name)
164
165
  case method_name
165
166
  when :expect
166
- :allow
167
+ '`allow`'
167
168
  when :is_expected
168
- 'allow(subject)'
169
+ '`allow(subject)`'
169
170
  when :expect_any_instance_of
170
- :allow_any_instance_of
171
+ '`allow_any_instance_of`'
172
+ else
173
+ 'an allow statement'
171
174
  end
172
175
  end
173
176
  end
@@ -64,7 +64,6 @@ module RuboCop
64
64
  def find_expect_to(node)
65
65
  node.each_ancestor.find do |ancestor|
66
66
  break if ancestor.block_type?
67
- next unless ancestor.send_type?
68
67
 
69
68
  expect_to?(ancestor)
70
69
  end
@@ -45,7 +45,7 @@ module RuboCop
45
45
  private
46
46
 
47
47
  def valid_scope?(node)
48
- node&.sym_type? && Language::HookScopes.all(node.value)
48
+ node.sym_type? && Language::HookScopes.all(node.value)
49
49
  end
50
50
 
51
51
  def transform_metadata(meta)
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module RSpec
5
5
  # Version information for the RSpec RuboCop plugin.
6
6
  module Version
7
- STRING = '3.2.0'
7
+ STRING = '3.3.0'
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Backus
8
8
  - Ian MacLeod
9
9
  - Nils Gemeinhardt
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-10-26 00:00:00.000000000 Z
13
+ date: 2024-12-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -193,7 +193,7 @@ metadata:
193
193
  changelog_uri: https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md
194
194
  documentation_uri: https://docs.rubocop.org/rubocop-rspec/
195
195
  rubygems_mfa_required: 'true'
196
- post_install_message:
196
+ post_install_message:
197
197
  rdoc_options: []
198
198
  require_paths:
199
199
  - lib
@@ -208,8 +208,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.5.16
212
- signing_key:
211
+ rubygems_version: 3.5.22
212
+ signing_key:
213
213
  specification_version: 4
214
214
  summary: Code style checking for RSpec files
215
215
  test_files: []