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

Allow use of instance variables for memoization in Rails/HelperInstanceVariable #311

Closed
mvz opened this issue Jul 27, 2020 · 1 comment · Fixed by #316
Closed

Allow use of instance variables for memoization in Rails/HelperInstanceVariable #311

mvz opened this issue Jul 27, 2020 · 1 comment · Fixed by #316
Labels
enhancement New feature or request

Comments

@mvz
Copy link
Contributor

mvz commented Jul 27, 2020

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

When I use memoization in a helper method, it gets flagged by Rails/HelperInstanceVariable.

Describe the solution you'd like

I'd like Rails/HelperInstanceVariable to accept assignment to instance variables for memoization purposes, i.e., it should allow methods like the following:

def foo
  @foo ||= expensive_calculation_of_foo(bar, baz)
end

Describe alternatives you've considered

I considered moving the method elsewhere, but it doesn't make sense for its location to be dependent on using memoization or not.

Additional context

N/A

@andyw8
Copy link
Contributor

andyw8 commented Jul 27, 2020

👍 This seems reasonable.

@koic koic added the enhancement New feature or request label Jul 29, 2020
koic added a commit to koic/rubocop-rails that referenced this issue Jul 31, 2020
…ation

Fixes rubocop#311

This PR makes `Rails/HelperInstanceVariable` aware of memoization.
@koic koic closed this as completed in #316 Aug 1, 2020
koic added a commit that referenced this issue Aug 1, 2020
…_of_memoization

[Fix #311] Make `Rails/HelperInstanceVariable` aware of memoization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants