Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration option to Rails::HelperInstanceVariable to allow instance variables as default method arguments #1132

Open
rmm5t opened this issue Sep 26, 2023 · 0 comments

Comments

@rmm5t
Copy link
Contributor

rmm5t commented Sep 26, 2023

Is your feature request related to a problem? Please describe.

I generally agree with the Rails::HelperInstanceVariable cop, but I believe there are reasonable scenarios where an instance variable can (and perhaps should) be used as a default argument to a helper method.

Here's a contrived example:

  def widget_title(widget = @widget)
    "#{widget.name} (#{widget.size})"
  end

Describe the solution you'd like

I'd like to be able to keep the Rails::HelperInstanceVariable cop in play for instance variables within the helper method body, but allow instance variables as default arguments.

Rails/HelperInstanceVariable:
  AllowArguments: true               # or something similar

Is this something that rubocop-rails team might consider if a PR was submitted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant