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

False positive Naming/MemoizedInstanceVariableName #9205

Closed
sashazykov opened this issue Dec 10, 2020 · 0 comments · Fixed by #9210
Closed

False positive Naming/MemoizedInstanceVariableName #9205

sashazykov opened this issue Dec 10, 2020 · 0 comments · Fixed by #9210

Comments

@sashazykov
Copy link

class Test
  def self.inherited(klass)
    klass.define_method(:values) do
      @values ||= do_something
    end
  end

  inherited(self)
end

Expected behavior

Memoized variable @values matches method name values.

Actual behavior

Rebocop reports an offence:

Naming/MemoizedInstanceVariableName: Memoized variable @values does not match method name inherited. Use @inherited instead.

RuboCop version

bundle exec rubocop -V
1.6.1 (using Parser 2.7.2.0, rubocop-ast 1.3.0, running on ruby 2.6.6 x86_64-linux-musl)
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Dec 11, 2020
koic added a commit that referenced this issue Dec 11, 2020
[Fix #9205] Update `Naming/MemoizedInstanceVariableName` to handle dynamically defined methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant