Skip to content

Commit 3d44d7b

Browse files
committed
Fix rubocop issues
1 parent 184ce98 commit 3d44d7b

File tree

9 files changed

+24
-16
lines changed

9 files changed

+24
-16
lines changed

.rubocop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ Layout/EmptyLinesAroundBlockBody:
7373
Exclude:
7474
- '**/*_spec.rb'
7575

76+
Rails/ActionControllerTestCase:
77+
Enabled: false
78+
79+
Rails/I18nLocaleTexts:
80+
Exclude:
81+
- '**/test/support/*.rb'
82+
7683
Rails/HelperInstanceVariable:
7784
Enabled: false
7885

app/controllers/crud_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def new
4040
assign_attributes if params[model_identifier]
4141
end
4242

43+
# GET /entries/1/edit
44+
#
45+
# Display a form to edit an exisiting entry of this model.
46+
def edit; end
47+
4348
# POST /entries
4449
# POST /entries.json
4550
#
@@ -63,11 +68,6 @@ def create(**options, &block)
6368
end
6469
end
6570

66-
# GET /entries/1/edit
67-
#
68-
# Display a form to edit an exisiting entry of this model.
69-
def edit; end
70-
7171
# PUT /entries/1
7272
# PUT /entries/1.json
7373
#

app/controllers/dry_crud/generic_model.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ module GenericModel
1313
included do
1414
helper_method :model_class, :models_label, :path_args
1515

16-
private
17-
1816
delegate :model_class, :models_label, :model_identifier, to: 'self.class'
1917
end
2018

app/controllers/dry_crud/render_callbacks.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ module Prepends
1515

1616
# Helper method to run +before_render+ callbacks and render the action.
1717
# If a callback renders or redirects, the action is not rendered.
18-
def render(*args, &block)
19-
options = _normalize_render(*args, &block)
18+
def render(...)
19+
options = _normalize_render(...)
2020
callback = "render_#{options[:template]}"
2121

2222
run_callbacks(callback) if respond_to?(:"_#{callback}_callbacks", true)
2323

24-
super(*args, &block) unless performed?
24+
super(...) unless performed?
2525
end
2626

2727
private

app/helpers/actions_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def show_action_link(path = nil)
3030
# Uses the current +entry+ if no path is given.
3131
def edit_action_link(path = nil)
3232
path ||= path_args(entry)
33-
path = path.is_a?(String) ? path : edit_polymorphic_path(path)
33+
path = edit_polymorphic_path(path) unless path.is_a?(String)
3434
action_link(ti('link.edit'), 'pencil', path)
3535
end
3636

@@ -47,15 +47,15 @@ def destroy_action_link(path = nil)
4747
# Uses the current +model_class+ if no path is given.
4848
def index_action_link(path = nil, url_options = { returning: true })
4949
path ||= path_args(model_class)
50-
path = path.is_a?(String) ? path : polymorphic_path(path, url_options)
50+
path = polymorphic_path(path, url_options) unless path.is_a?(String)
5151
action_link(ti('link.list'), 'list', path)
5252
end
5353

5454
# Standard add action to given path.
5555
# Uses the current +model_class+ if no path is given.
5656
def add_action_link(path = nil, url_options = {})
5757
path ||= path_args(model_class)
58-
path = path.is_a?(String) ? path : new_polymorphic_path(path, url_options)
58+
path = new_polymorphic_path(path, url_options) unless path.is_a?(String)
5959
action_link(ti('link.add'), 'plus', path)
6060
end
6161

app/helpers/dry_crud/form/builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def respond_to_missing?(name, include_private = false)
267267
def labeled_field_method?(name)
268268
prefix = 'labeled_'
269269
if name.to_s.start_with?(prefix)
270-
field_method = name.to_s[prefix.size..-1]
270+
field_method = name.to_s[prefix.size..]
271271
field_method if respond_to?(field_method)
272272
end
273273
end

app/helpers/dry_crud/table/actions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def edit_action_col(**html_options, &block)
4444
action_col do |entry|
4545
path = action_path(entry, &block)
4646
if path
47-
path = path.is_a?(String) ? path : edit_polymorphic_path(path)
47+
path = edit_polymorphic_path(path) unless path.is_a?(String)
4848
table_action_link('pencil', path, **html_options.clone)
4949
end
5050
end

lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def set_companions
9292
# handle the called callbacks
9393
def method_missing(sym, *_args)
9494
if sym.to_s.starts_with?(HANDLE_PREFIX)
95-
called_callback(sym.to_s[HANDLE_PREFIX.size..-1].to_sym)
95+
called_callback(sym.to_s[HANDLE_PREFIX.size..].to_sym)
9696
else
9797
super
9898
end

test/templates/test/.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Layout/ParameterAlignment:
3737
Layout/SpaceBeforeFirstArg:
3838
Enabled: false
3939

40+
Rails/ActionControllerTestCase:
41+
Enabled: false
42+
4043
Rails/OutputSafety:
4144
Enabled: false
4245

0 commit comments

Comments
 (0)