rubocop-rails 2.17.0 → 2.17.1
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 +4 -4
- data/lib/rubocop/cop/rails/http_status.rb +1 -6
- data/lib/rubocop/cop/rails/pluck.rb +9 -4
- data/lib/rubocop/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d21ae5d8d1539043fce111139db7f488f0fa4b5c8bc62d2e29ab73d209a4619
|
4
|
+
data.tar.gz: 48a66d61c7bbba386b076f04adba40076a020342c60e0e7665ee2d2c3c93be6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 945db96e9abac04c69f4d96f30626042424faedff229dc2784bcd0a56dfdcfe3a2bbbf65104346d85673ff6479c11dcc70d1ab533347a78fec6d058fa0c523c0
|
7
|
+
data.tar.gz: 11454cf0df5f0ea170d3a4e2ba911b7e8e559f775dedced95031bd426923e7ea7d6ef33578a6c16060dca4b6a4ed69fac4ae0047595cd7b7794ee1c8f30366c1
|
@@ -12,7 +12,6 @@ module RuboCop
|
|
12
12
|
# render plain: 'foo/bar', status: 304
|
13
13
|
# redirect_to root_url, status: 301
|
14
14
|
# head 200
|
15
|
-
# get '/foobar', to: redirect('/foobar/baz', status: 301)
|
16
15
|
#
|
17
16
|
# # good
|
18
17
|
# render :foo, status: :ok
|
@@ -20,7 +19,6 @@ module RuboCop
|
|
20
19
|
# render plain: 'foo/bar', status: :not_modified
|
21
20
|
# redirect_to root_url, status: :moved_permanently
|
22
21
|
# head :ok
|
23
|
-
# get '/foobar', to: redirect('/foobar/baz', status: :moved_permanently)
|
24
22
|
#
|
25
23
|
# @example EnforcedStyle: numeric
|
26
24
|
# # bad
|
@@ -29,7 +27,6 @@ module RuboCop
|
|
29
27
|
# render plain: 'foo/bar', status: :not_modified
|
30
28
|
# redirect_to root_url, status: :moved_permanently
|
31
29
|
# head :ok
|
32
|
-
# get '/foobar', to: redirect('/foobar/baz', status: :moved_permanently)
|
33
30
|
#
|
34
31
|
# # good
|
35
32
|
# render :foo, status: 200
|
@@ -37,20 +34,18 @@ module RuboCop
|
|
37
34
|
# render plain: 'foo/bar', status: 304
|
38
35
|
# redirect_to root_url, status: 301
|
39
36
|
# head 200
|
40
|
-
# get '/foobar', to: redirect('/foobar/baz', status: 301)
|
41
37
|
#
|
42
38
|
class HttpStatus < Base
|
43
39
|
include ConfigurableEnforcedStyle
|
44
40
|
extend AutoCorrector
|
45
41
|
|
46
|
-
RESTRICT_ON_SEND = %i[render redirect_to head
|
42
|
+
RESTRICT_ON_SEND = %i[render redirect_to head].freeze
|
47
43
|
|
48
44
|
def_node_matcher :http_status, <<~PATTERN
|
49
45
|
{
|
50
46
|
(send nil? {:render :redirect_to} _ $hash)
|
51
47
|
(send nil? {:render :redirect_to} $hash)
|
52
48
|
(send nil? :head ${int sym} ...)
|
53
|
-
(send nil? :redirect _ $hash)
|
54
49
|
}
|
55
50
|
PATTERN
|
56
51
|
|
@@ -26,15 +26,16 @@ module RuboCop
|
|
26
26
|
minimum_target_rails_version 5.0
|
27
27
|
|
28
28
|
def_node_matcher :pluck_candidate?, <<~PATTERN
|
29
|
-
({block numblock} (send _ {:map :collect}) $_argument (send
|
29
|
+
({block numblock} (send _ {:map :collect}) $_argument (send lvar :[] $_key))
|
30
30
|
PATTERN
|
31
31
|
|
32
32
|
def on_block(node)
|
33
|
-
pluck_candidate?(node) do |argument,
|
33
|
+
pluck_candidate?(node) do |argument, key|
|
34
34
|
match = if node.block_type?
|
35
|
-
argument.children.first.source
|
35
|
+
block_argument = argument.children.first.source
|
36
|
+
use_block_argument_in_key?(block_argument, key)
|
36
37
|
else # numblock
|
37
|
-
argument == 1 &&
|
38
|
+
argument == 1 && use_block_argument_in_key?('_1', key)
|
38
39
|
end
|
39
40
|
next unless match
|
40
41
|
|
@@ -50,6 +51,10 @@ module RuboCop
|
|
50
51
|
|
51
52
|
private
|
52
53
|
|
54
|
+
def use_block_argument_in_key?(block_argument, key)
|
55
|
+
key.each_descendant(:lvar).none? { |lvar| block_argument == lvar.source }
|
56
|
+
end
|
57
|
+
|
53
58
|
def offense_range(node)
|
54
59
|
node.send_node.loc.selector.join(node.loc.end)
|
55
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.17.
|
4
|
+
version: 2.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-10-
|
13
|
+
date: 2022-10-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|