rubocop-rails 2.29.0 → 2.29.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/rails/duplicate_association.rb +8 -4
- data/lib/rubocop/cop/rails/file_path.rb +22 -2
- data/lib/rubocop/cop/rails/root_pathname_methods.rb +6 -1
- data/lib/rubocop/cop/rails/save_bang.rb +3 -2
- data/lib/rubocop/cop/rails/strong_parameters_expect.rb +2 -2
- 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: f6fa236fdf79709d4d0baec3c3ed01bc254e807dbd5ec39229374187b1d3d30c
|
4
|
+
data.tar.gz: 99b29d27dd97c1adc12efb3d60a55370f6c4ad363bd6de51ca11ac33f3b1cd8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 422221a038428edaf91477ef0ede6939023a686f3a62c14242efbfa1cb31be9d8f504eaf15ac103875696b5584b690cabcc86a4041b5c42cfd4480aa4ad27dbd
|
7
|
+
data.tar.gz: 8240dcae47150b3137a980e731d69133df5e54364b62014d296b51715b1e3f47077b828d4f256191c79d8a14121e0d5cce9b06857f54b632e398216290e31f29
|
@@ -63,11 +63,15 @@ module RuboCop
|
|
63
63
|
private
|
64
64
|
|
65
65
|
def register_offense(name, nodes, message_template)
|
66
|
-
nodes.
|
67
|
-
add_offense(node, message: format(message_template, name: name)) do |corrector|
|
68
|
-
next if same_line?(nodes.last, node)
|
66
|
+
last_node = nodes.last
|
69
67
|
|
70
|
-
|
68
|
+
nodes.each_with_index do |node, index|
|
69
|
+
add_offense(node, message: format(message_template, name: name)) do |corrector|
|
70
|
+
if index.zero?
|
71
|
+
corrector.replace(node, last_node.source)
|
72
|
+
else
|
73
|
+
corrector.remove(range_by_whole_lines(node.source_range, include_final_newline: true))
|
74
|
+
end
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -173,7 +173,17 @@ module RuboCop
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def autocorrect_file_join(corrector, node)
|
176
|
+
replace_receiver_with_rails_root(corrector, node)
|
177
|
+
remove_first_argument_with_comma(corrector, node)
|
178
|
+
process_arguments(corrector, node.arguments)
|
179
|
+
append_to_string_conversion(corrector, node)
|
180
|
+
end
|
181
|
+
|
182
|
+
def replace_receiver_with_rails_root(corrector, node)
|
176
183
|
corrector.replace(node.receiver, 'Rails.root')
|
184
|
+
end
|
185
|
+
|
186
|
+
def remove_first_argument_with_comma(corrector, node)
|
177
187
|
corrector.remove(
|
178
188
|
range_with_surrounding_space(
|
179
189
|
range_with_surrounding_comma(
|
@@ -183,9 +193,19 @@ module RuboCop
|
|
183
193
|
side: :right
|
184
194
|
)
|
185
195
|
)
|
186
|
-
|
187
|
-
|
196
|
+
end
|
197
|
+
|
198
|
+
def process_arguments(corrector, arguments)
|
199
|
+
arguments.each do |argument|
|
200
|
+
if argument.str_type?
|
201
|
+
corrector.replace(argument, argument.value.delete_prefix('/').inspect)
|
202
|
+
elsif argument.array_type?
|
203
|
+
corrector.replace(argument, "*#{argument.source}")
|
204
|
+
end
|
188
205
|
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def append_to_string_conversion(corrector, node)
|
189
209
|
corrector.insert_after(node, '.to_s')
|
190
210
|
end
|
191
211
|
|
@@ -237,7 +237,12 @@ module RuboCop
|
|
237
237
|
end
|
238
238
|
|
239
239
|
replacement = "#{path_replacement}.#{method}"
|
240
|
-
|
240
|
+
|
241
|
+
if args.any?
|
242
|
+
formatted_args = args.map { |arg| arg.array_type? ? "*#{arg.source}" : arg.source }
|
243
|
+
replacement += "(#{formatted_args.join(', ')})"
|
244
|
+
end
|
245
|
+
|
241
246
|
replacement
|
242
247
|
end
|
243
248
|
|
@@ -328,8 +328,9 @@ module RuboCop
|
|
328
328
|
end
|
329
329
|
|
330
330
|
def return_value_assigned?(node)
|
331
|
-
assignment = assignable_node(node).parent
|
332
|
-
|
331
|
+
return false unless (assignment = assignable_node(node).parent)
|
332
|
+
|
333
|
+
assignment.assignment?
|
333
334
|
end
|
334
335
|
|
335
336
|
def persist_method?(node, methods = RESTRICT_ON_SEND)
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
32
32
|
def_node_matcher :params_require_permit, <<~PATTERN
|
33
33
|
$(call
|
34
34
|
$(call
|
35
|
-
(send nil? :params) :require _) :permit
|
35
|
+
(send nil? :params) :require _) :permit _+)
|
36
36
|
PATTERN
|
37
37
|
|
38
38
|
def_node_matcher :params_permit_require, <<~PATTERN
|
@@ -59,7 +59,7 @@ module RuboCop
|
|
59
59
|
end
|
60
60
|
|
61
61
|
add_offense(range, message: format(MSG, prefer: prefer)) do |corrector|
|
62
|
-
corrector.remove(require_method.
|
62
|
+
corrector.remove(require_method.receiver.source_range.end.join(require_method.source_range.end))
|
63
63
|
corrector.replace(permit_method.loc.selector, 'expect')
|
64
64
|
if replace_argument
|
65
65
|
corrector.insert_before(permit_method.first_argument, "#{require_key(require_method)}[")
|
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.29.
|
4
|
+
version: 2.29.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
- Yuji Nakayama
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-01-
|
12
|
+
date: 2025-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|