rubocop-rspec 2.24.1 → 2.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/rubocop/cop/rspec/example_length.rb +11 -5
- data/lib/rubocop/cop/rspec/metadata_style.rb +5 -0
- data/lib/rubocop/cop/rspec/mixin/metadata.rb +3 -3
- data/lib/rubocop/cop/rspec/rails/http_status.rb +12 -18
- data/lib/rubocop/cop/rspec/spec_file_path_format.rb +5 -5
- data/lib/rubocop/cop/rspec/void_expect.rb +1 -1
- data/lib/rubocop/rspec/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afb5cf0c88af50530fc023549eb7e9083db3ca2314553f1fca912ea2a3c47bdb
|
4
|
+
data.tar.gz: ba30f926d9cd3056e786f724140ac4358af527496b2e783fcc5c8e541adc9d13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd7955549b3b95b481eb5dea24b98f72e1b802546f8e090695a782a20b0ee8d1d0bcca9a6089f3a46718c5a14967de6c8473709ecea72d8aa5eae85e2cb5bd6f
|
7
|
+
data.tar.gz: 2beb193cf65884c363c2ece1a3a7ba5db39eecc3a579724bd39f29696ab29276def06261363b6a6290d378743e0b79d414e056b65f0a8a9e2e4215a417d9b978
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 2.25.0 (2023-10-27)
|
6
|
+
|
7
|
+
- Add support single quoted string and percent string and heredoc for `RSpec/Rails/HttpStatus`. ([@ydah])
|
8
|
+
- Change to be inline disable for `RSpec/SpecFilePathFormat` like `RSpec/FilePath`. ([@ydah])
|
9
|
+
- Fix a false positive for `RSpec/MetadataStyle` with example groups having multiple string arguments. ([@franzliedke])
|
10
|
+
|
5
11
|
## 2.24.1 (2023-09-23)
|
6
12
|
|
7
13
|
- Fix an error when using `RSpec/FilePath` and revert to enabled by default. If you have already moved to `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`, disable `RSpec/FilePath` explicitly as `Enabled: false`. The `RSpec/FilePath` before migration and the `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat` as the target are available respectively. ([@ydah])
|
@@ -839,6 +845,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
839
845
|
[@faucct]: https://github.com/faucct
|
840
846
|
[@foton]: https://github.com/foton
|
841
847
|
[@francois-ferrandis]: https://github.com/francois-ferrandis
|
848
|
+
[@franzliedke]: https://github.com/franzliedke
|
842
849
|
[@g-rath]: https://github.com/G-Rath
|
843
850
|
[@geniou]: https://github.com/geniou
|
844
851
|
[@gsamokovarov]: https://github.com/gsamokovarov
|
@@ -26,11 +26,12 @@ module RuboCop
|
|
26
26
|
# expect(result).to be(true)
|
27
27
|
# end
|
28
28
|
#
|
29
|
-
# You can set
|
30
|
-
# Available are: 'array', 'hash', and '
|
31
|
-
# will be counted as one line regardless of
|
29
|
+
# You can set constructs you want to fold with `CountAsOne`.
|
30
|
+
# Available are: 'array', 'hash', 'heredoc', and 'method_call'.
|
31
|
+
# Each construct will be counted as one line regardless of
|
32
|
+
# its actual size.
|
32
33
|
#
|
33
|
-
# @example CountAsOne: ['array', 'heredoc']
|
34
|
+
# @example CountAsOne: ['array', 'heredoc', 'method_call']
|
34
35
|
#
|
35
36
|
# it do
|
36
37
|
# array = [ # +1
|
@@ -46,7 +47,12 @@ module RuboCop
|
|
46
47
|
# Heredoc
|
47
48
|
# content.
|
48
49
|
# HEREDOC
|
49
|
-
#
|
50
|
+
#
|
51
|
+
# foo( # +1
|
52
|
+
# 1,
|
53
|
+
# 2
|
54
|
+
# )
|
55
|
+
# end # 6 points
|
50
56
|
#
|
51
57
|
class ExampleLength < Base
|
52
58
|
include CodeLength
|
@@ -45,6 +45,11 @@ module RuboCop
|
|
45
45
|
PATTERN
|
46
46
|
|
47
47
|
def on_metadata(symbols, hash)
|
48
|
+
# RSpec example groups accept two string arguments. In such a case,
|
49
|
+
# the rspec_metadata matcher will interpret the second string
|
50
|
+
# argument as a metadata symbol.
|
51
|
+
symbols.shift if symbols.first&.str_type?
|
52
|
+
|
48
53
|
symbols.each do |symbol|
|
49
54
|
on_metadata_symbol(symbol)
|
50
55
|
end
|
@@ -30,12 +30,12 @@ module RuboCop
|
|
30
30
|
def on_block(node)
|
31
31
|
rspec_configure(node) do |block_var|
|
32
32
|
metadata_in_block(node, block_var) do |metadata_arguments|
|
33
|
-
|
33
|
+
on_metadata_arguments(metadata_arguments)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
rspec_metadata(node) do |metadata_arguments|
|
38
|
-
|
38
|
+
on_metadata_arguments(metadata_arguments)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
alias on_numblock on_block
|
@@ -46,7 +46,7 @@ module RuboCop
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def
|
49
|
+
def on_metadata_arguments(metadata_arguments)
|
50
50
|
*symbols, last = metadata_arguments
|
51
51
|
hash = nil
|
52
52
|
case last&.type
|
@@ -66,6 +66,8 @@ module RuboCop
|
|
66
66
|
|
67
67
|
def on_send(node)
|
68
68
|
http_status(node) do |arg|
|
69
|
+
return if arg.str_type? && arg.heredoc?
|
70
|
+
|
69
71
|
checker = checker_class.new(arg)
|
70
72
|
return unless checker.offensive?
|
71
73
|
|
@@ -105,6 +107,10 @@ module RuboCop
|
|
105
107
|
format(MSG, prefer: prefer, current: current)
|
106
108
|
end
|
107
109
|
|
110
|
+
def current
|
111
|
+
offense_range.source
|
112
|
+
end
|
113
|
+
|
108
114
|
def offense_range
|
109
115
|
node
|
110
116
|
end
|
@@ -129,10 +135,6 @@ module RuboCop
|
|
129
135
|
symbol.inspect
|
130
136
|
end
|
131
137
|
|
132
|
-
def current
|
133
|
-
node.value.inspect
|
134
|
-
end
|
135
|
-
|
136
138
|
private
|
137
139
|
|
138
140
|
def symbol
|
@@ -140,7 +142,7 @@ module RuboCop
|
|
140
142
|
end
|
141
143
|
|
142
144
|
def number
|
143
|
-
node.
|
145
|
+
node.value.to_i
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
@@ -154,10 +156,6 @@ module RuboCop
|
|
154
156
|
number.to_s
|
155
157
|
end
|
156
158
|
|
157
|
-
def current
|
158
|
-
symbol.inspect
|
159
|
-
end
|
160
|
-
|
161
159
|
private
|
162
160
|
|
163
161
|
def symbol
|
@@ -190,10 +188,6 @@ module RuboCop
|
|
190
188
|
end
|
191
189
|
end
|
192
190
|
|
193
|
-
def current
|
194
|
-
offense_range.source
|
195
|
-
end
|
196
|
-
|
197
191
|
private
|
198
192
|
|
199
193
|
def symbol
|
@@ -201,15 +195,15 @@ module RuboCop
|
|
201
195
|
end
|
202
196
|
|
203
197
|
def number
|
204
|
-
node.
|
198
|
+
node.value.to_i
|
205
199
|
end
|
206
200
|
|
207
201
|
def normalize_str
|
208
|
-
|
209
|
-
if
|
210
|
-
::Rack::Utils::SYMBOL_TO_STATUS_CODE.key(
|
202
|
+
str = node.value.to_s
|
203
|
+
if str.match?(/\A\d+\z/)
|
204
|
+
::Rack::Utils::SYMBOL_TO_STATUS_CODE.key(str.to_i)
|
211
205
|
else
|
212
|
-
|
206
|
+
str
|
213
207
|
end
|
214
208
|
end
|
215
209
|
end
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
|
42
42
|
# @!method example_group_arguments(node)
|
43
43
|
def_node_matcher :example_group_arguments, <<~PATTERN
|
44
|
-
(block (send #rspec? #ExampleGroups.all $_ $...) ...)
|
44
|
+
(block $(send #rspec? #ExampleGroups.all $_ $...) ...)
|
45
45
|
PATTERN
|
46
46
|
|
47
47
|
# @!method metadata_key_value(node)
|
@@ -50,16 +50,16 @@ module RuboCop
|
|
50
50
|
def on_top_level_example_group(node)
|
51
51
|
return unless top_level_groups.one?
|
52
52
|
|
53
|
-
example_group_arguments(node) do |class_name, arguments|
|
53
|
+
example_group_arguments(node) do |send_node, class_name, arguments|
|
54
54
|
next if !class_name.const_type? || ignore_metadata?(arguments)
|
55
55
|
|
56
|
-
ensure_correct_file_path(class_name, arguments)
|
56
|
+
ensure_correct_file_path(send_node, class_name, arguments)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
private
|
61
61
|
|
62
|
-
def ensure_correct_file_path(class_name, arguments)
|
62
|
+
def ensure_correct_file_path(send_node, class_name, arguments)
|
63
63
|
pattern = correct_path_pattern(class_name, arguments)
|
64
64
|
return if filename_ends_with?(pattern)
|
65
65
|
|
@@ -67,7 +67,7 @@ module RuboCop
|
|
67
67
|
# expression pattern to resemble a glob pattern for clearer error
|
68
68
|
# messages.
|
69
69
|
suffix = pattern.sub('.*', '*').sub('[^/]*', '*').sub('\.', '.')
|
70
|
-
|
70
|
+
add_offense(send_node, message: format(MSG, suffix: suffix))
|
71
71
|
end
|
72
72
|
|
73
73
|
def ignore_metadata?(arguments)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Backus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-10-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
21
|
+
version: '1.40'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '1.
|
28
|
+
version: '1.40'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rubocop-capybara
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
251
|
requirements: []
|
252
|
-
rubygems_version: 3.4.
|
252
|
+
rubygems_version: 3.4.17
|
253
253
|
signing_key:
|
254
254
|
specification_version: 4
|
255
255
|
summary: Code style checking for RSpec files
|