Skip to content

Commit 380f9dc

Browse files
committed
Lint touched files and regenerate .rubocop_todo.yml
1 parent 3cf3b27 commit 380f9dc

File tree

4 files changed

+172
-202
lines changed

4 files changed

+172
-202
lines changed

.rubocop_todo.yml

+13-89
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config --exclude-limit 10000`
3-
# on 2025-03-01 10:06:34 UTC using RuboCop version 1.73.1.
3+
# on 2025-03-04 09:53:10 UTC using RuboCop version 1.73.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -15,20 +15,6 @@ Layout/ArgumentAlignment:
1515
- 'bin/console'
1616
- 'spec/inertia/response_spec.rb'
1717

18-
# Offense count: 9
19-
# This cop supports safe autocorrection (--autocorrect).
20-
Layout/BlockEndNewline:
21-
Exclude:
22-
- 'spec/inertia/rendering_spec.rb'
23-
24-
# Offense count: 2
25-
# This cop supports safe autocorrection (--autocorrect).
26-
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
27-
# SupportedStyles: case, end
28-
Layout/CaseIndentation:
29-
Exclude:
30-
- 'lib/inertia_rails/renderer.rb'
31-
3218
# Offense count: 1
3319
# This cop supports safe autocorrection (--autocorrect).
3420
Layout/EmptyLineAfterGuardClause:
@@ -49,14 +35,6 @@ Layout/EmptyLinesAroundBlockBody:
4935
Exclude:
5036
- 'spec/inertia/rails_mimic_spec.rb'
5137

52-
# Offense count: 1
53-
# This cop supports safe autocorrection (--autocorrect).
54-
# Configuration parameters: EnforcedStyleAlignWith, Severity.
55-
# SupportedStylesAlignWith: keyword, variable, start_of_line
56-
Layout/EndAlignment:
57-
Exclude:
58-
- 'lib/inertia_rails/renderer.rb'
59-
6038
# Offense count: 3
6139
# This cop supports safe autocorrection (--autocorrect).
6240
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
@@ -76,16 +54,11 @@ Layout/FirstArgumentIndentation:
7654

7755
# Offense count: 2
7856
# This cop supports safe autocorrection (--autocorrect).
79-
# Configuration parameters: IndentationWidth.
57+
# Configuration parameters: EnforcedStyle, IndentationWidth.
8058
# SupportedStyles: special_inside_parentheses, consistent, align_braces
8159
Layout/FirstHashElementIndentation:
82-
EnforcedStyle: consistent
83-
84-
# Offense count: 9
85-
# This cop supports safe autocorrection (--autocorrect).
86-
Layout/MultilineBlockLayout:
8760
Exclude:
88-
- 'spec/inertia/rendering_spec.rb'
61+
- 'spec/inertia/rspec_helper_spec.rb'
8962

9063
# Offense count: 4
9164
# This cop supports safe autocorrection (--autocorrect).
@@ -116,18 +89,17 @@ Layout/SpaceInsideArrayLiteralBrackets:
11689
- 'spec/dummy/app/controllers/inertia_test_controller.rb'
11790
- 'spec/dummy/config/environments/production.rb'
11891

119-
# Offense count: 13
92+
# Offense count: 5
12093
# This cop supports safe autocorrection (--autocorrect).
12194
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
12295
# SupportedStyles: space, no_space
12396
# SupportedStylesForEmptyBraces: space, no_space
12497
Layout/SpaceInsideBlockBraces:
12598
Exclude:
12699
- 'spec/inertia/error_sharing_spec.rb'
127-
- 'spec/inertia/rendering_spec.rb'
128100
- 'spec/inertia/request_spec.rb'
129101

130-
# Offense count: 122
102+
# Offense count: 106
131103
# This cop supports safe autocorrection (--autocorrect).
132104
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
133105
# SupportedStyles: space, no_space, compact
@@ -141,7 +113,6 @@ Layout/SpaceInsideHashLiteralBraces:
141113
- 'spec/inertia/conditional_sharing_spec.rb'
142114
- 'spec/inertia/middleware_spec.rb'
143115
- 'spec/inertia/rails_mimic_spec.rb'
144-
- 'spec/inertia/rendering_spec.rb'
145116
- 'spec/inertia/request_spec.rb'
146117
- 'spec/inertia/rspec_helper_spec.rb'
147118
- 'spec/inertia/sharing_spec.rb'
@@ -193,12 +164,6 @@ Lint/SymbolConversion:
193164
Exclude:
194165
- 'spec/inertia/rails_mimic_spec.rb'
195166

196-
# Offense count: 1
197-
# Configuration parameters: AllowKeywordBlockArguments.
198-
Lint/UnderscorePrefixedVariableName:
199-
Exclude:
200-
- 'lib/inertia_rails/renderer.rb'
201-
202167
# Offense count: 1
203168
# This cop supports safe autocorrection (--autocorrect).
204169
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
@@ -230,7 +195,7 @@ Naming/VariableNumber:
230195
Exclude:
231196
- 'spec/dummy/app/controllers/inertia_test_controller.rb'
232197

233-
# Offense count: 25
198+
# Offense count: 10
234199
# This cop supports safe autocorrection (--autocorrect).
235200
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
236201
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
@@ -242,7 +207,7 @@ Style/BlockDelimiters:
242207
- 'lib/inertia_rails/controller.rb'
243208
- 'spec/inertia/action_filter_spec.rb'
244209
- 'spec/inertia/conditional_sharing_spec.rb'
245-
- 'spec/inertia/rendering_spec.rb'
210+
- 'spec/inertia/rails_mimic_spec.rb'
246211
- 'spec/inertia/request_spec.rb'
247212
- 'spec/inertia/rspec_helper_spec.rb'
248213
- 'spec/inertia/sharing_spec.rb'
@@ -255,26 +220,11 @@ Style/ClassAndModuleChildren:
255220
Exclude:
256221
- 'lib/inertia_rails/helper.rb'
257222

258-
# Offense count: 2
223+
# Offense count: 1
259224
# This cop supports safe autocorrection (--autocorrect).
260225
Style/ColonMethodCall:
261226
Exclude:
262227
- 'spec/inertia/error_sharing_spec.rb'
263-
- 'spec/inertia/rendering_spec.rb'
264-
265-
# Offense count: 1
266-
# This cop supports safe autocorrection (--autocorrect).
267-
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
268-
# SupportedStyles: assign_to_condition, assign_inside_condition
269-
Style/ConditionalAssignment:
270-
Exclude:
271-
- 'lib/inertia_rails/renderer.rb'
272-
273-
# Offense count: 1
274-
# This cop supports safe autocorrection (--autocorrect).
275-
Style/EachWithObject:
276-
Exclude:
277-
- 'lib/inertia_rails/renderer.rb'
278228

279229
# Offense count: 1
280230
# This cop supports safe autocorrection (--autocorrect).
@@ -305,7 +255,7 @@ Style/ExpandPathArguments:
305255
Exclude:
306256
- 'spec/rails_helper.rb'
307257

308-
# Offense count: 71
258+
# Offense count: 69
309259
# This cop supports unsafe autocorrection (--autocorrect-all).
310260
# Configuration parameters: EnforcedStyle.
311261
# SupportedStyles: always, always_true, never
@@ -314,7 +264,6 @@ Style/FrozenStringLiteralComment:
314264
- '**/*.arb'
315265
- 'app/controllers/inertia_rails/static_controller.rb'
316266
- 'bin/console'
317-
- 'lib/inertia_rails.rb'
318267
- 'lib/inertia_rails/controller.rb'
319268
- 'lib/inertia_rails/engine.rb'
320269
- 'lib/inertia_rails/helper.rb'
@@ -374,7 +323,6 @@ Style/FrozenStringLiteralComment:
374323
- 'spec/inertia/lazy_prop_spec.rb'
375324
- 'spec/inertia/middleware_spec.rb'
376325
- 'spec/inertia/rails_mimic_spec.rb'
377-
- 'spec/inertia/rendering_spec.rb'
378326
- 'spec/inertia/request_spec.rb'
379327
- 'spec/inertia/response_spec.rb'
380328
- 'spec/inertia/rspec_helper_spec.rb'
@@ -445,12 +393,6 @@ Style/MutableConstant:
445393
Exclude:
446394
- 'lib/inertia_rails/version.rb'
447395

448-
# Offense count: 2
449-
# This cop supports safe autocorrection (--autocorrect).
450-
Style/NegatedIfElseCondition:
451-
Exclude:
452-
- 'lib/inertia_rails/renderer.rb'
453-
454396
# Offense count: 2
455397
# This cop supports safe autocorrection (--autocorrect).
456398
Style/NestedModifier:
@@ -490,12 +432,6 @@ Style/RedundantReturn:
490432
Exclude:
491433
- 'spec/dummy/app/controllers/inertia_session_continuity_test_controller.rb'
492434

493-
# Offense count: 1
494-
# This cop supports safe autocorrection (--autocorrect).
495-
Style/RescueModifier:
496-
Exclude:
497-
- 'lib/inertia_rails/renderer.rb'
498-
499435
# Offense count: 1
500436
# This cop supports safe autocorrection (--autocorrect).
501437
# Configuration parameters: AllowIfMethodIsEmpty.
@@ -510,7 +446,7 @@ Style/SoleNestedConditional:
510446
Exclude:
511447
- 'lib/inertia_rails/controller.rb'
512448

513-
# Offense count: 82
449+
# Offense count: 78
514450
# This cop supports safe autocorrection (--autocorrect).
515451
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
516452
# SupportedStyles: single_quotes, double_quotes
@@ -521,7 +457,6 @@ Style/StringLiterals:
521457
- 'lib/inertia_rails/engine.rb'
522458
- 'lib/inertia_rails/helper.rb'
523459
- 'lib/inertia_rails/middleware.rb'
524-
- 'lib/inertia_rails/renderer.rb'
525460
- 'lib/inertia_rails/rspec.rb'
526461
- 'lib/inertia_rails/version.rb'
527462
- 'lib/patches/better_errors.rb'
@@ -543,14 +478,6 @@ Style/StringLiterals:
543478
- 'spec/rails_helper.rb'
544479
- 'spec/spec_helper.rb'
545480

546-
# Offense count: 1
547-
# This cop supports safe autocorrection (--autocorrect).
548-
# Configuration parameters: EnforcedStyle.
549-
# SupportedStyles: single_quotes, double_quotes
550-
Style/StringLiteralsInInterpolation:
551-
Exclude:
552-
- 'lib/inertia_rails/renderer.rb'
553-
554481
# Offense count: 2
555482
# This cop supports safe autocorrection (--autocorrect).
556483
# Configuration parameters: .
@@ -559,16 +486,14 @@ Style/SymbolArray:
559486
EnforcedStyle: percent
560487
MinSize: 3
561488

562-
# Offense count: 14
489+
# Offense count: 3
563490
# This cop supports safe autocorrection (--autocorrect).
564491
# Configuration parameters: EnforcedStyleForMultiline.
565492
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
566493
Style/TrailingCommaInArguments:
567494
Exclude:
568-
- 'lib/inertia_rails.rb'
569495
- 'spec/dummy/app/controllers/inertia_config_test_controller.rb'
570496
- 'spec/dummy/app/controllers/inertia_rails_mimic_controller.rb'
571-
- 'spec/inertia/rendering_spec.rb'
572497

573498
# Offense count: 22
574499
# This cop supports safe autocorrection (--autocorrect).
@@ -586,16 +511,15 @@ Style/TrailingCommaInHashLiteral:
586511
- 'spec/inertia/response_spec.rb'
587512
- 'spec/inertia/rspec_helper_spec.rb'
588513

589-
# Offense count: 2
514+
# Offense count: 1
590515
# This cop supports safe autocorrection (--autocorrect).
591516
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
592517
# SupportedStyles: percent, brackets
593518
Style/WordArray:
594519
Exclude:
595520
- 'lib/inertia_rails/middleware.rb'
596-
- 'spec/inertia/rendering_spec.rb'
597521

598-
# Offense count: 26
522+
# Offense count: 17
599523
# This cop supports safe autocorrection (--autocorrect).
600524
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
601525
# URISchemes: http, https

lib/inertia_rails.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'inertia_rails/renderer'
24
require 'inertia_rails/engine'
35

@@ -17,7 +19,7 @@
1719
view_data: options[:view_data],
1820
deep_merge: options[:deep_merge],
1921
encrypt_history: options[:encrypt_history],
20-
clear_history: options[:clear_history],
22+
clear_history: options[:clear_history]
2123
).render
2224
end
2325

lib/inertia_rails/renderer.rb

+29-23
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ class Renderer
1919
:clear_history
2020
)
2121

22-
def initialize(component, controller, request, response, render_method, props: nil, view_data: nil, deep_merge: nil, encrypt_history: nil, clear_history: nil)
23-
raise ArgumentError, 'Parameter `props` is not allowed when passing a Hash as the first argument' if component.is_a?(Hash) && !props.nil?
22+
def initialize(component, controller, request, response, render_method, props: nil, view_data: nil,
23+
deep_merge: nil, encrypt_history: nil, clear_history: nil)
24+
if component.is_a?(Hash) && !props.nil?
25+
raise ArgumentError,
26+
'Parameter `props` is not allowed when passing a Hash as the first argument'
27+
end
2428

2529
@controller = controller
2630
@configuration = controller.__send__(:inertia_configuration)
@@ -30,22 +34,26 @@ def initialize(component, controller, request, response, render_method, props: n
3034
@render_method = render_method
3135
@props = props || (component.is_a?(Hash) ? component : controller.__send__(:inertia_view_assigns))
3236
@view_data = view_data || {}
33-
@deep_merge = !deep_merge.nil? ? deep_merge : configuration.deep_merge_shared_data
34-
@encrypt_history = !encrypt_history.nil? ? encrypt_history : configuration.encrypt_history
37+
@deep_merge = deep_merge.nil? ? configuration.deep_merge_shared_data : deep_merge
38+
@encrypt_history = encrypt_history.nil? ? configuration.encrypt_history : encrypt_history
3539
@clear_history = clear_history || controller.session[:inertia_clear_history] || false
3640
end
3741

3842
def render
39-
if @response.headers["Vary"].blank?
40-
@response.headers["Vary"] = 'X-Inertia'
41-
else
42-
@response.headers["Vary"] = "#{@response.headers["Vary"]}, X-Inertia"
43-
end
43+
@response.headers['Vary'] = if @response.headers['Vary'].blank?
44+
'X-Inertia'
45+
else
46+
"#{@response.headers['Vary']}, X-Inertia"
47+
end
4448
if @request.headers['X-Inertia']
4549
@response.set_header('X-Inertia', 'true')
4650
@render_method.call json: page.to_json, status: @response.status, content_type: Mime[:json]
4751
else
48-
return render_ssr if configuration.ssr_enabled rescue nil
52+
begin
53+
return render_ssr if configuration.ssr_enabled
54+
rescue StandardError
55+
nil
56+
end
4957
@render_method.call template: 'inertia', layout: layout, locals: view_data.merge(page: page)
5058
end
5159
end
@@ -56,7 +64,7 @@ def render_ssr
5664
uri = URI("#{configuration.ssr_url}/render")
5765
res = JSON.parse(Net::HTTP.post(uri, page.to_json, 'Content-Type' => 'application/json').body)
5866

59-
controller.instance_variable_set("@_inertia_ssr_head", res['head'].join.html_safe)
67+
controller.instance_variable_set('@_inertia_ssr_head', res['head'].join.html_safe)
6068
@render_method.call html: res['body'].html_safe, layout: layout, locals: view_data.merge(page: page)
6169
end
6270

@@ -83,19 +91,19 @@ def merge_props(shared_data, props)
8391
end
8492

8593
def computed_props
86-
_props = merge_props(shared_data, props)
94+
merged_props = merge_props(shared_data, props)
8795

88-
deep_transform_props _props do |prop, path|
96+
deep_transform_props merged_props do |prop, path|
8997
next [DONT_KEEP_PROP] unless keep_prop?(prop, path)
9098

9199
transformed_prop = case prop
92-
when BaseProp
93-
prop.call(controller)
94-
when Proc
95-
controller.instance_exec(&prop)
96-
else
97-
prop
98-
end
100+
when BaseProp
101+
prop.call(controller)
102+
when Proc
103+
controller.instance_exec(&prop)
104+
else
105+
prop
106+
end
99107

100108
[KEEP_PROP, transformed_prop]
101109
end
@@ -121,7 +129,7 @@ def page
121129
end
122130

123131
def deep_transform_props(props, parent_path = [], &block)
124-
props.reduce({}) do |transformed_props, (key, prop)|
132+
props.each_with_object({}) do |(key, prop), transformed_props|
125133
current_path = parent_path + [key]
126134

127135
if prop.is_a?(Hash) && prop.any?
@@ -131,8 +139,6 @@ def deep_transform_props(props, parent_path = [], &block)
131139
action, transformed_prop = block.call(prop, current_path)
132140
transformed_props.merge!(key => transformed_prop) if action == KEEP_PROP
133141
end
134-
135-
transformed_props
136142
end
137143
end
138144

0 commit comments

Comments
 (0)