Skip to content

Commit

Permalink
Fix rubocop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
codez committed Oct 31, 2023
1 parent 30bac26 commit 00cdd2e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ Layout/EmptyLinesAroundBlockBody:
Exclude:
- '**/*_spec.rb'

Rails/ActionControllerTestCase:
Enabled: false

Rails/I18nLocaleTexts:
Exclude:
- '**/test/support/*.rb'

Rails/HelperInstanceVariable:
Enabled: false

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/crud_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def new
assign_attributes if params[model_identifier]
end

# GET /entries/1/edit
#
# Display a form to edit an exisiting entry of this model.
def edit; end

# POST /entries
# POST /entries.json
#
Expand All @@ -63,11 +68,6 @@ def create(**options, &block)
end
end

# GET /entries/1/edit
#
# Display a form to edit an exisiting entry of this model.
def edit; end

# PUT /entries/1
# PUT /entries/1.json
#
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/dry_crud/generic_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ module GenericModel
included do
helper_method :model_class, :models_label, :path_args

private

delegate :model_class, :models_label, :model_identifier, to: 'self.class'
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/dry_crud/render_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ module Prepends

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

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

super(*args, &block) unless performed?
super(...) unless performed?
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/actions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def show_action_link(path = nil)
# Uses the current +entry+ if no path is given.
def edit_action_link(path = nil)
path ||= path_args(entry)
path = path.is_a?(String) ? path : edit_polymorphic_path(path)
path = edit_polymorphic_path(path) unless path.is_a?(String)
action_link(ti('link.edit'), 'pencil', path)
end

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

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

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/dry_crud/form/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def respond_to_missing?(name, include_private = false)
def labeled_field_method?(name)
prefix = 'labeled_'
if name.to_s.start_with?(prefix)
field_method = name.to_s[prefix.size..-1]
field_method = name.to_s[prefix.size..]
field_method if respond_to?(field_method)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/dry_crud/table/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def edit_action_col(**html_options, &block)
action_col do |entry|
path = action_path(entry, &block)
if path
path = path.is_a?(String) ? path : edit_polymorphic_path(path)
path = edit_polymorphic_path(path) unless path.is_a?(String)
table_action_link('pencil', path, **html_options.clone)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def set_companions
# handle the called callbacks
def method_missing(sym, *_args)
if sym.to_s.starts_with?(HANDLE_PREFIX)
called_callback(sym.to_s[HANDLE_PREFIX.size..-1].to_sym)
called_callback(sym.to_s[HANDLE_PREFIX.size..].to_sym)
else
super
end
Expand Down
3 changes: 3 additions & 0 deletions test/templates/test/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Layout/ParameterAlignment:
Layout/SpaceBeforeFirstArg:
Enabled: false

Rails/ActionControllerTestCase:
Enabled: false

Rails/OutputSafety:
Enabled: false

Expand Down

0 comments on commit 00cdd2e

Please sign in to comment.